Skip to content

Commit e54787a

Browse files
authored
feat: new light theme / inset theme for light and black theme (#1288)
1 parent ebed05f commit e54787a

File tree

23 files changed

+820
-649
lines changed

23 files changed

+820
-649
lines changed

apps/gitness/src/components-v2/breadcrumbs/breadcrumbs.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function Breadcrumbs() {
1616
{!isMFE ? (
1717
<>
1818
<Sidebar.Trigger className="text-topbar-foreground-2 hover:text-topbar-foreground-1 hover:bg-topbar-background-1 -ml-1" />
19-
<Separator orientation="vertical" className="bg-topbar-background-1 ml-1 mr-2 h-4" />
19+
<Separator orientation="vertical" className="bg-sidebar-background-1 ml-1 mr-2 h-4" />
2020
</>
2121
) : null}
2222
<Breadcrumb.Root className="select-none">
@@ -29,13 +29,13 @@ function Breadcrumbs() {
2929

3030
return (
3131
<Breadcrumb.Item key={match.pathname}>
32-
{!isFirst ? <Breadcrumb.Separator className="text-topbar-foreground-3" /> : null}
32+
{!isFirst && <Breadcrumb.Separator className="text-foreground-9" />}
3333
{isLast || !asLink ? (
34-
<Breadcrumb.Page className={isLast ? 'text-topbar-foreground-4' : 'text-topbar-foreground-3'}>
34+
<Breadcrumb.Page className={isLast ? 'text-foreground-3' : 'text-foreground-1'}>
3535
{breadcrumbContent}
3636
</Breadcrumb.Page>
3737
) : (
38-
<Breadcrumb.Link className="text-topbar-foreground-3" asChild>
38+
<Breadcrumb.Link className="text-foreground-4 hover:text-foreground-2" asChild>
3939
<Link to={match.pathname}>{breadcrumbContent}</Link>
4040
</Breadcrumb.Link>
4141
)}

packages/ui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@harnessio/ui",
33
"description": "Harness Canary UI component library",
4-
"version": "0.0.11",
4+
"version": "0.0.12",
55
"private": false,
66
"type": "module",
77
"main": "./dist/index.js",

packages/ui/src/components/alert-dialog.tsx

+17-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react'
22

33
import { Button, Icon } from '@/components'
44
import { buttonVariants } from '@/components/button'
5-
import { usePortal } from '@/context'
5+
import { usePortal, useTheme } from '@/context'
66
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
77
import { cn } from '@utils/cn'
88

@@ -19,17 +19,22 @@ interface AlertDialogOverlayProps extends React.ComponentPropsWithoutRef<typeof
1919
const AlertDialogOverlay = React.forwardRef<
2020
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
2121
AlertDialogOverlayProps
22-
>(({ className, onClick, ...props }, ref) => (
23-
<AlertDialogPrimitive.Overlay
24-
className={cn(
25-
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 bg-background-7/50 fixed inset-0 z-50',
26-
className
27-
)}
28-
{...props}
29-
ref={ref}
30-
onClick={onClick}
31-
/>
32-
))
22+
>(({ className, onClick, ...props }, ref) => {
23+
const { isLightTheme } = useTheme()
24+
25+
return (
26+
<AlertDialogPrimitive.Overlay
27+
className={cn(
28+
'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 bg-background-7/80 fixed inset-0 z-50',
29+
{ 'bg-background-10/60': isLightTheme },
30+
className
31+
)}
32+
{...props}
33+
ref={ref}
34+
onClick={onClick}
35+
/>
36+
)
37+
})
3338
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName
3439

3540
interface AlertDialogContentProps extends React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content> {

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export const AppSidebar = ({
120120
<Sidebar.MenuButton asChild onClick={handleMoreMenu}>
121121
<Sidebar.MenuItemText
122122
text={t('component:navbar.more', 'More')}
123-
icon={<Icon name="ellipsis" size={12} />}
123+
icon={<Icon name="ellipsis" size={14} />}
124124
/>
125125
</Sidebar.MenuButton>
126126
</Sidebar.MenuItem>
@@ -158,7 +158,7 @@ export const AppSidebar = ({
158158
<Sidebar.MenuButton asChild onClick={() => navigate('/admin/default-settings')}>
159159
<Sidebar.MenuItemText
160160
text={t('component:navbar.user-management', 'User Management')}
161-
icon={<Icon name="account" size={12} />}
161+
icon={<Icon name="account" size={14} />}
162162
/>
163163
</Sidebar.MenuButton>
164164
</Sidebar.MenuItem>
@@ -167,7 +167,7 @@ export const AppSidebar = ({
167167
<Sidebar.MenuButton asChild onClick={handleSettingsMenu}>
168168
<Sidebar.MenuItemText
169169
text={t('component:navbar.settings', 'Settings')}
170-
icon={<Icon name="settings-1" size={12} />}
170+
icon={<Icon name="settings-1" size={14} />}
171171
/>
172172
</Sidebar.MenuButton>
173173
</Sidebar.MenuItem>

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { DropdownMenu, Icon, IconProps, Sidebar, Text } from '@/components'
2-
import { useRouterContext } from '@/context'
2+
import { useRouterContext, useTheme } from '@/context'
3+
import { cn } from '@utils/cn'
34
import { TFunction } from 'i18next'
45

56
interface NavbarItemType {
@@ -29,6 +30,7 @@ export const SidebarItem = ({
2930
t
3031
}: NavbarItemProps) => {
3132
const { NavLink } = useRouterContext()
33+
const { isInset } = useTheme()
3234

3335
const iconName = item.iconName && (item.iconName.replace('-gradient', '') as IconProps['name'])
3436

@@ -90,7 +92,7 @@ export const SidebarItem = ({
9092
<Sidebar.MenuButton asChild isActive={isActive}>
9193
<Sidebar.MenuItemText
9294
text={item.title}
93-
icon={iconName && <Icon name={iconName} size={12} />}
95+
icon={iconName && <Icon name={iconName} size={14} />}
9496
active={isActive}
9597
/>
9698
</Sidebar.MenuButton>
@@ -99,7 +101,10 @@ export const SidebarItem = ({
99101

100102
<DropdownMenu.Root>
101103
<DropdownMenu.Trigger asChild>
102-
<Sidebar.MenuAction className="right-0 text-sidebar-icon-3 hover:text-sidebar-icon-1" showOnHover>
104+
<Sidebar.MenuAction
105+
className={cn('text-sidebar-icon-3 hover:text-sidebar-icon-1', isInset ? 'right-[3px]' : 'right-0')}
106+
showOnHover
107+
>
103108
<span>
104109
<Icon name="menu-dots" size={12} />
105110
</span>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function SidebarSearchLegacy({ logo, t }: ProjectProps) {
2525

2626
return (
2727
<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>
28+
<div className="mb-5 mt-3.5 flex items-center pl-2">{logo}</div>
2929
<SearchBox.Root
3030
width="full"
3131
placeholder={`${t('component:navbar.search', 'Search')}...`}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function SidebarSearch(props: SidebarSearchProps) {
4949
<Button
5050
variant="custom"
5151
size="icon"
52-
className="bg-sidebar-background-9 pointer-events-none absolute right-1.5 top-1/2 h-5 -translate-y-1/2 select-none rounded-sm border border-sidebar-border-5 p-0 px-1.5 text-sidebar-foreground-3"
52+
className="pointer-events-none absolute right-1.5 top-1/2 h-5 -translate-y-1/2 select-none rounded-sm border border-sidebar-border-5 bg-sidebar-background-9 p-0 px-1.5 text-sidebar-foreground-3"
5353
>
5454
<span className="size-full text-12">⌘K</span>
5555
</Button>

packages/ui/src/components/button-with-options.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const ButtonWithOptions = <T extends string>({
103103
buttonVariants({ theme, variant }),
104104
'relative h-[inherit] w-8 p-0 flex-shrink-0 rounded-l-none before:absolute before:left-0 before:h-[calc(100%-8px)] before:w-px',
105105
theme !== 'primary' && 'border-y border-r',
106-
separatorThemes[theme || 'default']
106+
separatorThemes[disabled ? 'disabled' : theme || 'default']
107107
)}
108108
disabled={disabled || loading}
109109
>

packages/ui/src/components/dialog.tsx

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Children, ComponentPropsWithoutRef, ElementRef, forwardRef, HTMLAttributes, isValidElement } from 'react'
22

33
import { Button, Icon } from '@/components'
4-
import { usePortal } from '@/context'
4+
import { usePortal, useTheme } from '@/context'
55
import * as DialogPrimitive from '@radix-ui/react-dialog'
66
import { cn } from '@utils/cn'
77

@@ -16,17 +16,22 @@ interface DialogOverlayProps extends ComponentPropsWithoutRef<typeof DialogPrimi
1616
}
1717

1818
const DialogOverlay = forwardRef<ElementRef<typeof DialogPrimitive.Overlay>, DialogOverlayProps>(
19-
({ className, onClick, ...props }, ref) => (
20-
<DialogPrimitive.Overlay
21-
ref={ref}
22-
className={cn(
23-
'fixed inset-0 z-50 bg-background-7/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
24-
className
25-
)}
26-
{...props}
27-
onClick={onClick}
28-
/>
29-
)
19+
({ className, onClick, ...props }, ref) => {
20+
const { isLightTheme } = useTheme()
21+
22+
return (
23+
<DialogPrimitive.Overlay
24+
ref={ref}
25+
className={cn(
26+
'fixed inset-0 z-50 bg-background-7/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
27+
{ 'bg-background-10/60': isLightTheme },
28+
className
29+
)}
30+
{...props}
31+
onClick={onClick}
32+
/>
33+
)
34+
}
3035
)
3136
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName
3237

packages/ui/src/components/language-selector/language-dialog.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const LanguageDialog: FC<LanguageDialogProps> = ({
4444
onChange(lang)
4545
}}
4646
>
47-
<div className="flex items-center gap-2">
47+
<div className="relative z-[1] flex items-center gap-2">
4848
<div className="flex size-6 items-center justify-center rounded bg-background-12 text-12 uppercase text-foreground-3">
4949
{lang.code}
5050
</div>
@@ -57,10 +57,10 @@ const LanguageDialog: FC<LanguageDialogProps> = ({
5757
{lang.name}
5858
</span>
5959
</div>
60-
{selectedLanguage === lang.code && <Icon className="text-icons-2" name="tick" size={12} />}
60+
{selectedLanguage === lang.code && <Icon className="relative z-[1] text-icons-2" name="tick" size={12} />}
6161
<span
6262
className={cn(
63-
'absolute -inset-x-2 -inset-y-1 rounded group-hover:bg-background-4',
63+
'absolute -inset-x-2 -inset-y-1 rounded -z-[1] group-hover:bg-background-4',
6464
selectedLanguage === lang.code && 'bg-background-4'
6565
)}
6666
aria-hidden

packages/ui/src/components/more-submenu.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Icon, NavbarSkeleton, ScrollArea, Sheet, Spacer } from '@/components'
2-
import { useRouterContext } from '@/context'
2+
import { useRouterContext, useTheme } from '@/context'
33
import { MenuGroupType } from '@components/app-sidebar/types'
4+
import { cn } from '@utils/cn'
45

56
interface MoreSubmenuProps {
67
showMoreMenu: boolean
@@ -10,10 +11,15 @@ interface MoreSubmenuProps {
1011

1112
export function MoreSubmenu({ showMoreMenu, handleMoreMenu, items }: MoreSubmenuProps) {
1213
const { NavLink } = useRouterContext()
14+
const { isInset } = useTheme()
15+
1316
return (
1417
<Sheet.Root modal={false} open={showMoreMenu}>
1518
<Sheet.Content
16-
className="inset-y-0 left-[220px] z-40 h-screen w-[328px] bg-transparent p-0"
19+
className={cn(
20+
'inset-y-0 z-40 h-screen w-[328px] bg-transparent p-0',
21+
isInset ? 'border-l left-[228px]' : 'left-[220px]'
22+
)}
1723
closeClassName="text-sidebar-icon-3 hover:text-sidebar-icon-1"
1824
side="left"
1925
onClick={handleMoreMenu}
@@ -23,7 +29,7 @@ export function MoreSubmenu({ showMoreMenu, handleMoreMenu, items }: MoreSubmenu
2329
<NavbarSkeleton.Root className="w-[328px]" isSubMenu>
2430
<NavbarSkeleton.Content className="overflow-hidden">
2531
<ScrollArea scrollThumbClassName="bg-sidebar-background-8">
26-
<Spacer size={9} />
32+
<Spacer size={10} />
2733
{items.map((group, group_idx) => (
2834
<NavbarSkeleton.Group
2935
key={group.groupId}

packages/ui/src/components/navbar-skeleton/group.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function Group({
2323
return (
2424
<div
2525
className={cn(
26-
'flex w-full flex-col px-3',
26+
'flex w-full flex-col px-2',
2727
{ 'border-borders-5 border-t pt-2.5': topBorder },
2828
{ 'border-sidebar-border-1': topBorder && isMainNav },
2929
isSubMenu ? 'pb-2.5 gap-y-0.5' : 'gap-1 pb-3',

packages/ui/src/components/navbar-skeleton/item.tsx

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { forwardRef, ReactElement } from 'react'
22

33
import { Icon, Text } from '@/components'
4+
import { useTheme } from '@/context/theme'
45
import { cn } from '@utils/cn'
56

67
export interface ItemProps {
@@ -16,12 +17,14 @@ export interface ItemProps {
1617

1718
export const Item = forwardRef<HTMLDivElement, ItemProps>(
1819
({ icon, text, description, active, submenuItem = false, className, isMainNav, ...props }, ref) => {
20+
const { isInset, isLightTheme } = useTheme()
21+
1922
if (submenuItem) {
2023
return (
2124
<div
2225
ref={ref}
2326
className={cn(
24-
'group relative grid cursor-pointer select-none grid-cols-[auto_1fr] items-center gap-3 pb-[0.6875rem] pt-[0.5625rem] py-2 px-3 rounded-md',
27+
'group relative grid cursor-pointer select-none grid-cols-[auto_1fr] items-center gap-3 pb-[0.6875rem] pt-[0.5625rem] py-2.5 px-3 rounded-md',
2528
{ 'gap-0': !icon },
2629
className
2730
)}
@@ -41,6 +44,7 @@ export const Item = forwardRef<HTMLDivElement, ItemProps>(
4144
className={cn(
4245
'sub-menu-icon-bg relative flex size-8 place-content-center place-items-center rounded border border-borders-1 bg-background-2',
4346
{ 'border-sidebar-border-3 bg-sidebar-background-7': isMainNav }
47+
// { 'border-sidebar-border-6 bg-sidebar-background-8': active && isLightTheme }
4448
)}
4549
>
4650
<Icon
@@ -63,6 +67,8 @@ export const Item = forwardRef<HTMLDivElement, ItemProps>(
6367
weight="medium"
6468
className={cn(
6569
'text-foreground-2 group-hover:text-foreground-1 z-10 w-full duration-0 ease-in-out',
70+
// { 'text-sidebar-foreground-2': isMainNav && (!isInset || isLightTheme) },
71+
// { 'text-sidebar-foreground-3': isMainNav && isInset && !isLightTheme },
6672
{ 'text-sidebar-foreground-2 group-hover:text-sidebar-foreground-1': isMainNav },
6773
{ 'text-foreground-1': active },
6874
{ 'text-sidebar-foreground-1': active && isMainNav }
@@ -90,18 +96,24 @@ export const Item = forwardRef<HTMLDivElement, ItemProps>(
9096
<div
9197
ref={ref}
9298
className={cn(
93-
'group flex cursor-pointer select-none gap-2.5 py-1.5 px-3 rounded-md',
94-
{ 'bg-background-4': active },
95-
{ 'bg-sidebar-background-3': active && isMainNav },
99+
'group relative grid cursor-pointer select-none grid-cols-[auto_1fr] gap-2.5 py-1.5 px-2.5 rounded-md',
96100
{ 'gap-0': !icon },
97101
className
98102
)}
99103
{...props}
100104
>
105+
<div
106+
className={cn(
107+
'absolute z-0 h-full w-full rounded-[4px] bg-transparent transition-colors',
108+
{ 'group-hover:bg-sidebar-background-2': isMainNav && (isLightTheme || isInset) },
109+
{ 'bg-background-4': active },
110+
{ 'bg-sidebar-background-3': active && isMainNav }
111+
)}
112+
/>
101113
{icon && (
102114
<div
103115
className={cn(
104-
'text-icons-4 group-hover:text-icons-2 relative z-10 mt-1 flex h-3 w-3 min-w-3 items-center duration-100 ease-in-out',
116+
'text-icons-4 group-hover:text-icons-2 relative z-10 flex h-3.5 w-3.5 min-w-3.5 mt-0.5 items-center duration-100 ease-in-out',
105117
{ 'text-sidebar-icon-3 group-hover:text-sidebar-icon-1': isMainNav },
106118
{ 'text-icons-2': active },
107119
{ 'text-sidebar-icon-1': active && isMainNav }
@@ -117,7 +129,7 @@ export const Item = forwardRef<HTMLDivElement, ItemProps>(
117129
size={2}
118130
weight="medium"
119131
className={cn(
120-
'text-foreground-3 group-hover:text-foreground-1 z-10 text-left duration-100 ease-in-out',
132+
'text-foreground-3 group-hover:text-foreground-1 relative z-10 text-left duration-100 ease-in-out',
121133
{ 'text-sidebar-foreground-2 group-hover:text-sidebar-foreground-1': isMainNav },
122134
{ 'text-foreground-1': active },
123135
{ 'text-sidebar-foreground-1': active && isMainNav }

0 commit comments

Comments
 (0)