Skip to content

Commit 9f674ac

Browse files
committed
feat: add logout icon and integrate it into LogoutCard and PageHeader for improved user experience
1 parent 133f9b4 commit 9f674ac

File tree

7 files changed

+49
-17
lines changed

7 files changed

+49
-17
lines changed

src/Assets/IconV2/ic-logout.svg

Lines changed: 3 additions & 0 deletions
Loading

src/Shared/Components/Header/PageHeader.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import Tippy from '@tippyjs/react'
1919
import './pageHeader.css'
2020
import ReactGA from 'react-ga4'
2121
import { ReactComponent as ICMediumPaintBucket } from '@IconsV2/ic-medium-paintbucket.svg'
22-
import { ReactComponent as DropDownIcon } from '@Icons/ic-chevron-down.svg'
22+
import { ReactComponent as ICCaretDown } from '@Icons/ic-caret-down.svg'
2323
import { ReactComponent as Close } from '@Icons/ic-close.svg'
2424
import { ReactComponent as Question } from '@Icons/ic-help-outline.svg'
25-
import { getRandomColor, TippyCustomized, TippyTheme } from '../../../Common'
25+
import { getAlphabetIcon, TippyCustomized, TippyTheme } from '../../../Common'
2626
import LogoutCard from '../LogoutCard'
2727
import { setActionWithExpiry, handlePostHogEventUpdate } from './utils'
2828
import { InstallationType, ServerInfo, PageHeaderType } from './types'
@@ -143,9 +143,9 @@ const PageHeader = ({
143143
<span className="fs-13 cn-9" data-testid="go-to-get-started">
144144
Help
145145
</span>
146-
<DropDownIcon
146+
<ICCaretDown
147147
style={{ ['--rotateBy' as any]: `${180 * Number(showHelpCard)}deg` }}
148-
className="fcn-9 icon-dim-20 rotate pointer"
148+
className="scn-7 icon-dim-16 rotate pointer"
149149
/>
150150
</div>
151151
{!window._env_.K8S_CLIENT && (
@@ -164,14 +164,17 @@ const PageHeader = ({
164164
arrow
165165
onClose={handleCloseSwitchThemeLocationTippyChange}
166166
>
167-
<div
168-
className="logout-card__initial cursor fs-13 icon-dim-24 flex logout-card__initial--nav"
169-
onClick={onClickLogoutButton}
170-
style={{ backgroundColor: getRandomColor(email) }}
167+
<button
168+
type="button"
171169
data-testid="profile-button"
170+
onClick={onClickLogoutButton}
171+
className="dc__transparent flex p-4 dc__gap-4 br-18 bg__secondary border__secondary"
172172
>
173-
{email[0]}
174-
</div>
173+
{getAlphabetIcon(email, 'm-0-imp')}
174+
<ICCaretDown
175+
className={`scn-7 icon-dim-16 ${showLogOutCard ? 'dc__flip-180' : ''} dc__transition--transform`}
176+
/>
177+
</button>
175178
</TippyCustomized>
176179
)}
177180
</>
@@ -285,7 +288,7 @@ const PageHeader = ({
285288
)}
286289
{showLogOutCard && (
287290
<LogoutCard
288-
className="logout-card__more-option"
291+
className="logout-card__more-option mt-8"
289292
userFirstLetter={email}
290293
setShowLogOutCard={setShowLogOutCard}
291294
showLogOutCard={showLogOutCard}

src/Shared/Components/Icon/Icon.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { ReactComponent as ICJobColor } from '@IconsV2/ic-job-color.svg'
4343
import { ReactComponent as ICK8sJob } from '@IconsV2/ic-k8s-job.svg'
4444
import { ReactComponent as ICLdap } from '@IconsV2/ic-ldap.svg'
4545
import { ReactComponent as ICLoginDevtronLogo } from '@IconsV2/ic-login-devtron-logo.svg'
46+
import { ReactComponent as ICLogout } from '@IconsV2/ic-logout.svg'
4647
import { ReactComponent as ICMediumPaintbucket } from '@IconsV2/ic-medium-paintbucket.svg'
4748
import { ReactComponent as ICMicrosoft } from '@IconsV2/ic-microsoft.svg'
4849
import { ReactComponent as ICMissing } from '@IconsV2/ic-missing.svg'
@@ -111,6 +112,7 @@ export const iconMap = {
111112
'ic-k8s-job': ICK8sJob,
112113
'ic-ldap': ICLdap,
113114
'ic-login-devtron-logo': ICLoginDevtronLogo,
115+
'ic-logout': ICLogout,
114116
'ic-medium-paintbucket': ICMediumPaintbucket,
115117
'ic-microsoft': ICMicrosoft,
116118
'ic-missing': ICMissing,

src/Shared/Components/LogoutCard.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { useHistory } from 'react-router-dom'
1919
import { useMainContext } from '@Shared/Providers'
2020
import { getRandomColor, stopPropagation } from '../../Common'
2121
import { ThemeSwitcher } from './ThemeSwitcher'
22+
import { Icon } from './Icon'
2223

2324
interface LogoutCardType {
2425
className: string
@@ -27,6 +28,9 @@ interface LogoutCardType {
2728
showLogOutCard: boolean
2829
}
2930

31+
export const LOGOUT_CARD_BASE_BUTTON_CLASS =
32+
'dc__unset-button-styles dc__content-space px-12 py-6 fs-13 fw-4 lh-20 cursor w-100 flex left br-4'
33+
3034
const LogoutCard = ({ className, userFirstLetter, setShowLogOutCard, showLogOutCard }: LogoutCardType) => {
3135
const history = useHistory()
3236
const { viewIsPipelineRBACConfiguredNode } = useMainContext()
@@ -55,18 +59,19 @@ const LogoutCard = ({ className, userFirstLetter, setShowLogOutCard, showLogOutC
5559
{userFirstLetter[0]}
5660
</p>
5761
</div>
58-
<div className="dc__border-top-n1 py-4">
62+
<div className="dc__border-top-n1 py-4 px-4 flexbox-col">
5963
<ThemeSwitcher onChange={toggleLogoutCard} />
6064

6165
{viewIsPipelineRBACConfiguredNode}
6266

6367
<button
64-
className="dc__unset-button-styles px-12 py-6 fs-13 fw-4 lh-20 cr-5 dc__hover-n50 cursor w-100 flex left"
68+
className={`${LOGOUT_CARD_BASE_BUTTON_CLASS} cr-5 dc__hover-r50`}
6569
data-testid="logout-button"
6670
onClick={onLogout}
6771
type="button"
6872
>
6973
Logout
74+
<Icon name="ic-logout" color="R500" />
7075
</button>
7176
</div>
7277
</div>

src/Shared/Components/ThemeSwitcher/ThemeSwitcher.component.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { useTheme } from '@Shared/Providers'
17+
import { getThemePreferenceText, useTheme } from '@Shared/Providers'
18+
import { ReactComponent as ICCaretLeftSmall } from '@Icons/ic-caret-left-small.svg'
1819
import { ThemeSwitcherProps } from './types'
20+
import { LOGOUT_CARD_BASE_BUTTON_CLASS } from '../LogoutCard'
1921

2022
const ThemeSwitcher = ({ onChange }: ThemeSwitcherProps) => {
21-
const { handleThemeSwitcherDialogVisibilityChange } = useTheme()
23+
const { handleThemeSwitcherDialogVisibilityChange, themePreference } = useTheme()
2224

2325
if (!window._env_.FEATURE_EXPERIMENTAL_THEMING_ENABLE) {
2426
return null
@@ -33,10 +35,14 @@ const ThemeSwitcher = ({ onChange }: ThemeSwitcherProps) => {
3335
<button
3436
type="button"
3537
data-testid="open-theme-switcher-dialog"
36-
className="dc__transparent fs-13 fw-4 lh-20 cn-9 dc__hover-n50 w-100"
38+
className={`${LOGOUT_CARD_BASE_BUTTON_CLASS} dc__hover-n50`}
3739
onClick={handleShowThemeSwitcherDialog}
3840
>
3941
Theme
42+
<div className="flexbox dc__gap-4 dc__align-items-center">
43+
<span className="cn-7 fs-13 fw-4 lh-20">{getThemePreferenceText(themePreference)}</span>
44+
<ICCaretLeftSmall className="dc__flip-180 icon-16 dc__no-shrink scn-7" />
45+
</div>
4046
</button>
4147
)
4248
}

src/Shared/Providers/ThemeProvider/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616

1717
export * from './ThemeProvider'
1818
export { AppThemeType } from './types'
19-
export { getComponentSpecificThemeClass, getAppThemeForAutoPreference } from './utils'
19+
export { getComponentSpecificThemeClass, getAppThemeForAutoPreference, getThemePreferenceText } from './utils'

src/Shared/Providers/ThemeProvider/utils.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,16 @@ export const getThemeConfigFromLocalStorage = (): ThemeConfigType => {
6868
}
6969

7070
export const getComponentSpecificThemeClass = (appTheme: AppThemeType) => `component-specific-theme__${appTheme}`
71+
72+
export const getThemePreferenceText = (themePreference: ThemePreferenceType): string => {
73+
switch (themePreference) {
74+
case 'auto':
75+
return `System (${getAppThemeForAutoPreference() === AppThemeType.dark ? 'Dark' : 'Light'})`
76+
case AppThemeType.dark:
77+
return 'Dark'
78+
case AppThemeType.light:
79+
return 'Light'
80+
default:
81+
return null
82+
}
83+
}

0 commit comments

Comments
 (0)