Skip to content

Commit 1cfc533

Browse files
authored
fix: sidebar styles refactoring + light theme (#1208)
1 parent edf5911 commit 1cfc533

38 files changed

+633
-342
lines changed

apps/design-system/src/App.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import { FC } from 'react'
2-
import { createBrowserRouter, Link, Navigate, RouterProvider } from 'react-router-dom'
2+
import {
3+
createBrowserRouter,
4+
Link,
5+
Navigate,
6+
NavLink,
7+
Outlet,
8+
RouterProvider,
9+
useMatches,
10+
useSearchParams
11+
} from 'react-router-dom'
312

413
import ComponentPage from '@/pages/component-page'
514
import ViewPreview from '@/pages/view-preview/view-preview'
@@ -19,7 +28,15 @@ const App: FC = () => {
1928

2029
return (
2130
<ThemeProvider {...themeStore}>
22-
<RouterContextProvider Link={Link}>
31+
<RouterContextProvider
32+
Link={Link}
33+
NavLink={NavLink}
34+
Outlet={Outlet}
35+
navigate={router.navigate}
36+
location={{ ...window.location, state: {}, key: '' }}
37+
useSearchParams={useSearchParams}
38+
useMatches={useMatches}
39+
>
2340
<RouterProvider router={router} />
2441
</RouterContextProvider>
2542
</ThemeProvider>

apps/design-system/src/pages/view-preview/app-view-wrapper.tsx

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,51 @@ export const AppViewWrapper: FC<PropsWithChildren<AppViewWrapperProps>> = ({
2020
}) => {
2121
const [showMoreMenu, setShowMoreMenu] = useState(false)
2222
const [showSettingsMenu, setShowSettingsMenu] = useState(false)
23-
const [pinnedMenu, setPinnedMenu] = useState<NavbarItemType[]>([])
23+
const [pinnedMenu, setPinnedMenu] = useState<NavbarItemType[]>([
24+
{
25+
id: 0,
26+
iconName: 'repositories-gradient',
27+
title: 'Repositories',
28+
description: 'Integrated & familiar git experience.',
29+
to: '/pixel/repos',
30+
permanentlyPinned: true
31+
},
32+
{
33+
id: 1,
34+
iconName: 'pipelines-gradient',
35+
title: 'Pipelines',
36+
description: 'Up to 4X faster than other solutions.',
37+
to: '/pipelines',
38+
permanentlyPinned: true
39+
},
40+
{
41+
id: 3,
42+
iconName: 'database-gradient',
43+
title: 'Databases',
44+
description: 'Manage all your infrastructure.',
45+
to: '/databases'
46+
},
47+
{
48+
id: 7,
49+
iconName: 'dev-portal-gradient',
50+
title: 'Developer Portal',
51+
description: 'Built for developers, onboard in minutes.',
52+
to: '/developer/portal'
53+
},
54+
{
55+
id: 32,
56+
iconName: 'user',
57+
title: 'Users',
58+
to: '/admin/default-settings'
59+
},
60+
{
61+
id: 9,
62+
iconName: 'dev-insights-gradient',
63+
title: 'Developer Insights',
64+
description: 'Actionable insights on SDLC.',
65+
to: '/developer/insights'
66+
}
67+
])
2468
const [recentMenu] = useState<NavbarItemType[]>([])
2569
const { moreMenu, settingsMenu } = useRootViewWrapperStore()
2670

@@ -30,7 +74,6 @@ export const AppViewWrapper: FC<PropsWithChildren<AppViewWrapperProps>> = ({
3074

3175
const onToggleMoreMenu = useCallback(() => {
3276
setShowSettingsMenu(false)
33-
console.log('open more menu')
3477
setShowMoreMenu(current => !current)
3578
}, [])
3679

packages/ui/src/components/app-sidebar/app-sidebar.tsx

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
import { useState } from 'react'
22

3+
import {
4+
Icon,
5+
LanguageCode,
6+
LanguageDialog,
7+
LanguageInterface,
8+
languages,
9+
Sidebar,
10+
Spacer,
11+
ThemeDialog
12+
} from '@/components'
313
import { IThemeStore, useRouterContext } from '@/context'
414
import { TypesUser } from '@/types'
515
import { TranslationStore } from '@/views'
6-
import { Icon } from '@components/icon'
7-
import { LanguageCode, LanguageDialog, LanguageInterface, languages } from '@components/language-selector'
8-
import { Sidebar } from '@components/sidebar/sidebar'
9-
import { Spacer } from '@components/spacer'
10-
import { ThemeDialog } from '@components/theme-selector-v2'
1116

1217
import { SidebarItem } from './sidebar-item'
1318
import { SidebarSearchLegacy } from './sidebar-search-legacy'
@@ -69,16 +74,17 @@ export const AppSidebar = ({
6974

7075
return (
7176
<>
72-
<Sidebar.Root>
77+
<Sidebar.Root className="z-20">
7378
<Sidebar.Header>
7479
{showNewSearch ? (
7580
<SearchProvider t={t}>
7681
<SidebarSearch
82+
className="pb-3 pt-1.5"
7783
t={t}
7884
logo={
79-
<Link to="/" className="h-[58px] flex gap-2 items-center pl-3 justify-start">
80-
<Icon name="harness" size={20} className="text-foreground-accent" />
81-
<Icon name="harness-logo-text" size={68} className="text-foreground-1" />
85+
<Link to="/" className="flex h-[58px] items-center justify-start gap-0.5 pl-1">
86+
<Icon name="harness" size={18} className="text-sidebar-foreground-accent" />
87+
<Icon name="harness-logo-text" width={65} height={15} className="mb-px text-sidebar-foreground-1" />
8288
</Link>
8389
}
8490
/>
@@ -87,16 +93,16 @@ export const AppSidebar = ({
8793
<SidebarSearchLegacy
8894
t={t}
8995
logo={
90-
<Link className="flex items-center gap-1.5" to="/">
91-
<Icon name="harness" size={18} className="text-foreground-accent" />
92-
<Icon name="harness-logo-text" width={65} height={15} className="mb-0.5 text-foreground-1" />
96+
<Link className="flex items-center gap-0.5" to="/">
97+
<Icon name="harness" size={18} className="text-sidebar-foreground-accent" />
98+
<Icon name="harness-logo-text" width={65} height={15} className="mb-px text-sidebar-foreground-1" />
9399
</Link>
94100
}
95101
/>
96102
)}
97103
</Sidebar.Header>
98104
<Sidebar.Content>
99-
<Sidebar.Group className="px-2 pt-5">
105+
<Sidebar.Group>
100106
<Sidebar.GroupContent>
101107
<Sidebar.Menu>
102108
{pinnedMenuItems.map((item, index) => (
@@ -110,22 +116,20 @@ export const AppSidebar = ({
110116
/>
111117
))}
112118

113-
<Sidebar.MenuItem className="cursor-pointer">
119+
<Sidebar.MenuItem>
114120
<Sidebar.MenuButton asChild onClick={handleMoreMenu}>
115-
<div>
116-
<Icon name="ellipsis" size={12} className="text-icons-4 transition-colors hover:text-primary" />
117-
<span className="text-foreground-3 font-medium transition-colors hover:text-primary">
118-
{t('component:navbar.more', 'More')}
119-
</span>
120-
</div>
121+
<Sidebar.MenuItemText
122+
text={t('component:navbar.more', 'More')}
123+
icon={<Icon name="ellipsis" size={12} />}
124+
/>
121125
</Sidebar.MenuButton>
122126
</Sidebar.MenuItem>
123127
</Sidebar.Menu>
124128
</Sidebar.GroupContent>
125129
</Sidebar.Group>
126130

127131
{!!recentMenuItems.length && (
128-
<Sidebar.Group title="Recent" className="border-t px-2 pt-3">
132+
<Sidebar.Group title={t('component:navbar.recent', 'Recent')} className="border-t pt-2.5">
129133
<Sidebar.GroupLabel>{t('component:navbar.recent', 'Recent')}</Sidebar.GroupLabel>
130134
<Spacer size={2} />
131135
<Sidebar.GroupContent>
@@ -146,36 +150,32 @@ export const AppSidebar = ({
146150
</Sidebar.Group>
147151
)}
148152

149-
<Sidebar.Group className="border-t px-2 pt-5">
153+
<Sidebar.Group className="border-t">
150154
<Sidebar.GroupContent>
151155
<Sidebar.Menu>
152156
{!!currentUser?.admin && (
153157
<Sidebar.MenuItem>
154158
<Sidebar.MenuButton asChild onClick={() => navigate('/admin/default-settings')}>
155-
<div>
156-
<Icon name="account" size={12} className="text-icons-4 transition-colors hover:text-primary" />
157-
<span className="text-foreground-3 font-medium transition-colors hover:text-primary">
158-
{t('component:navbar.user-management', 'User Management')}
159-
</span>
160-
</div>
159+
<Sidebar.MenuItemText
160+
text={t('component:navbar.user-management', 'User Management')}
161+
icon={<Icon name="account" size={12} />}
162+
/>
161163
</Sidebar.MenuButton>
162164
</Sidebar.MenuItem>
163165
)}
164166
<Sidebar.MenuItem>
165167
<Sidebar.MenuButton asChild onClick={handleSettingsMenu}>
166-
<div>
167-
<Icon name="settings-1" size={12} className="text-icons-4 transition-colors hover:text-primary" />
168-
<span className="text-foreground-3 font-medium transition-colors hover:text-primary">
169-
{t('component:navbar.settings', 'Settings')}
170-
</span>
171-
</div>
168+
<Sidebar.MenuItemText
169+
text={t('component:navbar.settings', 'Settings')}
170+
icon={<Icon name="settings-1" size={12} />}
171+
/>
172172
</Sidebar.MenuButton>
173173
</Sidebar.MenuItem>
174174
</Sidebar.Menu>
175175
</Sidebar.GroupContent>
176176
</Sidebar.Group>
177177
</Sidebar.Content>
178-
<Sidebar.Footer className="border-t border-borders-1">
178+
<Sidebar.Footer className="border-t border-sidebar-border-1">
179179
<User
180180
user={currentUser}
181181
openThemeDialog={() => setOpenThemeDialog(true)}

packages/ui/src/components/app-sidebar/sidebar-item.tsx

Lines changed: 43 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1+
import { DropdownMenu, Icon, IconProps, Sidebar, Text } from '@/components'
12
import { useRouterContext } from '@/context'
2-
import { DropdownMenu } from '@components/dropdown-menu'
3-
import { Icon, IconProps } from '@components/icon'
4-
import { Sidebar } from '@components/sidebar/sidebar'
5-
import { Text } from '@components/text'
6-
import { cn } from '@utils/cn'
73
import { TFunction } from 'i18next'
84

95
interface NavbarItemType {
@@ -46,33 +42,41 @@ export const SidebarItem = ({
4642

4743
const dropdownItems = isRecent ? (
4844
<>
49-
<DropdownMenu.Item onSelect={handlePin} className="gap-2">
50-
<Icon name="pin" size={12} />
51-
<Text size={2} truncate>
52-
{t('component:navbar.pin')}
45+
<DropdownMenu.Item
46+
className="text-sidebar-foreground-6 data-[highlighted]:bg-sidebar-background-2 data-[highlighted]:text-sidebar-foreground-1"
47+
onSelect={handlePin}
48+
>
49+
<Text size={2} truncate color="inherit">
50+
{t('component:navbar.pin', 'Pin')}
5351
</Text>
5452
</DropdownMenu.Item>
55-
<DropdownMenu.Item onSelect={handleRemoveRecent} className="gap-2">
56-
<Icon name="trash" size={12} />
57-
<Text size={2} truncate>
58-
{t('component:navbar.remove')}
53+
<DropdownMenu.Item
54+
className="text-sidebar-foreground-6 data-[highlighted]:bg-sidebar-background-2 data-[highlighted]:text-sidebar-foreground-1"
55+
onSelect={handleRemoveRecent}
56+
>
57+
<Text size={2} truncate color="inherit">
58+
{t('component:navbar.remove', 'Remove')}
5959
</Text>
6060
</DropdownMenu.Item>
6161
</>
6262
) : (
6363
<>
64-
<DropdownMenu.Item onSelect={handleCustomNav} className="gap-2">
65-
<Icon name="list" size={12} />
66-
<Text size={2} truncate>
67-
{t('component:navbar.reorder')}
64+
<DropdownMenu.Item
65+
className="text-sidebar-foreground-6 data-[highlighted]:bg-sidebar-background-2 data-[highlighted]:text-sidebar-foreground-1"
66+
onSelect={handleCustomNav}
67+
>
68+
<Text size={2} truncate color="inherit">
69+
{t('component:navbar.reorder', 'Reorder')}
6870
</Text>
6971
</DropdownMenu.Item>
7072

7173
{!item.permanentlyPinned ? (
72-
<DropdownMenu.Item onSelect={handlePin} className="gap-2">
73-
<Icon name="unpin" size={12} />
74-
<Text size={2} truncate>
75-
{t('component:navbar.unpin')}
74+
<DropdownMenu.Item
75+
className="text-sidebar-foreground-6 data-[highlighted]:bg-sidebar-background-2 data-[highlighted]:text-sidebar-foreground-1"
76+
onSelect={handlePin}
77+
>
78+
<Text size={2} truncate color="inherit">
79+
{t('component:navbar.unpin', 'Unpin')}
7680
</Text>
7781
</DropdownMenu.Item>
7882
) : null}
@@ -83,42 +87,30 @@ export const SidebarItem = ({
8387
<Sidebar.MenuItem>
8488
<NavLink className="block" to={item.to || ''} end>
8589
{({ isActive }) => (
86-
<div
87-
className={cn('hover:bg-background-4 rounded text-foreground-3 transition-colors hover:text-primary', {
88-
'bg-background-4': isActive
89-
})}
90-
>
91-
<Sidebar.MenuButton asChild isActive={isActive}>
92-
<div className="gap-2.5">
93-
<Icon
94-
name={iconName!}
95-
size={12}
96-
className={cn({
97-
'text-primary': isActive
98-
})}
99-
/>
100-
<span
101-
className={cn('font-medium', {
102-
'text-primary': isActive
103-
})}
104-
>
105-
{item.title}
106-
</span>
107-
</div>
108-
</Sidebar.MenuButton>
109-
</div>
90+
<Sidebar.MenuButton asChild isActive={isActive}>
91+
<Sidebar.MenuItemText
92+
text={item.title}
93+
icon={iconName && <Icon name={iconName} size={12} />}
94+
active={isActive}
95+
/>
96+
</Sidebar.MenuButton>
11097
)}
11198
</NavLink>
11299

113100
<DropdownMenu.Root>
114-
<Sidebar.MenuAction>
115-
<DropdownMenu.Trigger asChild>
116-
<span className="absolute right-[-0.2rem] text-icons-4 opacity-0 hover:text-icons-2 focus:opacity-100 focus-visible:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 focus:outline-none focus:ring-0">
101+
<DropdownMenu.Trigger asChild>
102+
<Sidebar.MenuAction className="right-0 text-sidebar-icon-3 hover:text-sidebar-icon-1" showOnHover>
103+
<span>
117104
<Icon name="menu-dots" size={12} />
118105
</span>
119-
</DropdownMenu.Trigger>
120-
</Sidebar.MenuAction>
121-
<DropdownMenu.Content className="w-[128px]" align="end" sideOffset={-1} alignOffset={8}>
106+
</Sidebar.MenuAction>
107+
</DropdownMenu.Trigger>
108+
<DropdownMenu.Content
109+
className="w-[128px] border-sidebar-border-3 bg-sidebar-background-4"
110+
align="end"
111+
sideOffset={3}
112+
alignOffset={4}
113+
>
122114
{dropdownItems}
123115
</DropdownMenu.Content>
124116
</DropdownMenu.Root>

packages/ui/src/components/app-sidebar/sidebar-search-legacy.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ function SidebarSearchLegacy({ logo, t }: ProjectProps) {
2424
}
2525

2626
return (
27-
<div className="flex w-full flex-col place-items-start px-2 pb-3">
28-
<div className="flex h-[58px] items-center px-1">{logo}</div>
27+
<div className="flex w-full flex-col place-items-start pb-3 pt-1.5">
28+
<div className="flex h-[58px] items-center pl-1">{logo}</div>
2929
<SearchBox.Root
3030
width="full"
3131
placeholder={`${t('component:navbar.search', 'Search')}...`}
@@ -35,6 +35,7 @@ function SidebarSearchLegacy({ logo, t }: ProjectProps) {
3535
value=""
3636
onSearch={openSearchDialog}
3737
handleChange={openSearchDialog}
38+
theme="sidebar"
3839
/>
3940
<Dialog.Root open={isSearchDialogOpen} onOpenChange={closeSearchDialog}>
4041
<Dialog.Content className="h-[600px] max-w-[800px]">

0 commit comments

Comments
 (0)