Skip to content

Commit 86d9c2f

Browse files
refactor(ui): Extract OAuth LogoGroup components (#8282)
1 parent 529cf73 commit 86d9c2f

6 files changed

Lines changed: 295 additions & 181 deletions

File tree

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
import { Box, Text, descriptors } from '@/ui/customizables';
2+
import { common } from '@/ui/styledSystem';
3+
import { colors } from '@/ui/utils/colors';
4+
import type { ComponentProps } from 'react';
5+
6+
export function ListGroup({ children, sx, ...props }: Omit<ComponentProps<typeof Box>, 'elementDescriptor'>) {
7+
return (
8+
<Box
9+
{...props}
10+
sx={[
11+
t => ({
12+
textAlign: 'start',
13+
borderWidth: t.borderWidths.$normal,
14+
borderStyle: t.borderStyles.$solid,
15+
borderColor: t.colors.$borderAlpha100,
16+
borderRadius: t.radii.$lg,
17+
overflow: 'hidden',
18+
}),
19+
sx,
20+
]}
21+
elementDescriptor={descriptors.listGroup}
22+
>
23+
{children}
24+
</Box>
25+
);
26+
}
27+
28+
export function ListGroupHeader({ children, sx, ...props }: Omit<ComponentProps<typeof Box>, 'elementDescriptor'>) {
29+
return (
30+
<Box
31+
{...props}
32+
sx={[
33+
t => ({
34+
padding: t.space.$3,
35+
background: common.mergedColorsBackground(
36+
colors.setAlpha(t.colors.$colorBackground, 1),
37+
t.colors.$neutralAlpha50,
38+
),
39+
}),
40+
sx,
41+
]}
42+
elementDescriptor={descriptors.listGroupHeader}
43+
>
44+
{children}
45+
</Box>
46+
);
47+
}
48+
49+
export function ListGroupHeaderTitle(props: Omit<ComponentProps<typeof Text>, 'elementDescriptor'>) {
50+
return (
51+
<Text
52+
{...props}
53+
variant='subtitle'
54+
elementDescriptor={descriptors.listGroupHeaderTitle}
55+
/>
56+
);
57+
}
58+
59+
export function ListGroupContent({
60+
children,
61+
sx,
62+
...props
63+
}: Omit<ComponentProps<typeof Box>, 'as' | 'elementDescriptor'>) {
64+
return (
65+
<Box
66+
{...props}
67+
as='ul'
68+
sx={[t => ({ margin: t.sizes.$none, padding: t.sizes.$none }), sx]}
69+
elementDescriptor={descriptors.listGroupContent}
70+
>
71+
{children}
72+
</Box>
73+
);
74+
}
75+
76+
export function ListGroupItem({
77+
children,
78+
sx,
79+
...props
80+
}: Omit<ComponentProps<typeof Box>, 'as' | 'elementDescriptor'>) {
81+
return (
82+
<Box
83+
{...props}
84+
as='li'
85+
sx={[
86+
t => ({
87+
display: 'flex',
88+
alignItems: 'baseline',
89+
paddingInline: t.space.$3,
90+
paddingBlock: t.space.$2,
91+
borderTopWidth: t.borderWidths.$normal,
92+
borderTopStyle: t.borderStyles.$solid,
93+
borderTopColor: t.colors.$borderAlpha100,
94+
'&::before': {
95+
content: '""',
96+
display: 'inline-block',
97+
width: t.space.$1,
98+
height: t.space.$1,
99+
background: t.colors.$colorMutedForeground,
100+
borderRadius: t.radii.$circle,
101+
transform: 'translateY(-0.1875rem)',
102+
marginInlineEnd: t.space.$2,
103+
flexShrink: 0,
104+
},
105+
}),
106+
sx,
107+
]}
108+
elementDescriptor={descriptors.listGroupItem}
109+
>
110+
{children}
111+
</Box>
112+
);
113+
}
114+
115+
export function ListGroupItemLabel(props: Omit<ComponentProps<typeof Text>, 'elementDescriptor'>) {
116+
return (
117+
<Text
118+
{...props}
119+
variant='subtitle'
120+
elementDescriptor={descriptors.listGroupItemLabel}
121+
/>
122+
);
123+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import { descriptors, Flex } from '@/ui/customizables';
2+
import type { ComponentProps } from 'react';
3+
import type { ThemableCssProp } from '@/ui/styledSystem';
4+
import { Box, Icon } from '@/ui/customizables';
5+
import { LockDottedCircle } from '@/ui/icons';
6+
import { colors } from '@/ui/utils/colors';
7+
import { common } from '@/ui/styledSystem';
8+
9+
export function LogoGroup({ children }: { children: React.ReactNode }) {
10+
return (
11+
<Flex
12+
justify='center'
13+
align='center'
14+
gap={4}
15+
sx={t => ({
16+
marginBlockEnd: t.space.$6,
17+
})}
18+
elementDescriptor={descriptors.logoGroup}
19+
>
20+
{children}
21+
</Flex>
22+
);
23+
}
24+
25+
export function LogoGroupItem({ children, sx, ...props }: ComponentProps<typeof Flex>) {
26+
return (
27+
<Flex
28+
{...props}
29+
sx={[{ flex: 1 }, sx]}
30+
elementDescriptor={descriptors.logoGroupItem}
31+
>
32+
{children}
33+
</Flex>
34+
);
35+
}
36+
37+
export function LogoGroupIcon({ size = 'md', sx }: { size?: 'sm' | 'md'; sx?: ThemableCssProp }) {
38+
const scale: ThemableCssProp = t => {
39+
const value = size === 'sm' ? t.space.$6 : t.space.$12;
40+
return {
41+
width: value,
42+
height: value,
43+
};
44+
};
45+
46+
return (
47+
<Box
48+
sx={t => [
49+
{
50+
background: common.mergedColorsBackground(
51+
colors.setAlpha(t.colors.$colorBackground, 1),
52+
t.colors.$neutralAlpha50,
53+
),
54+
borderRadius: t.radii.$circle,
55+
borderWidth: t.borderWidths.$normal,
56+
borderStyle: t.borderStyles.$solid,
57+
borderColor: t.colors.$borderAlpha100,
58+
display: 'flex',
59+
alignItems: 'center',
60+
justifyContent: 'center',
61+
},
62+
scale,
63+
sx,
64+
]}
65+
elementDescriptor={descriptors.logoGroupIcon}
66+
>
67+
<Icon
68+
icon={LockDottedCircle}
69+
sx={t => ({
70+
color: t.colors.$primary500,
71+
})}
72+
/>
73+
</Box>
74+
);
75+
}
76+
77+
export function LogoGroupSeparator() {
78+
return (
79+
<Box
80+
as='svg'
81+
// @ts-ignore - valid SVG attribute
82+
fill='none'
83+
viewBox='0 0 16 2'
84+
height={2}
85+
aria-hidden
86+
sx={t => ({
87+
color: t.colors.$colorMutedForeground,
88+
})}
89+
elementDescriptor={descriptors.logoGroupSeparator}
90+
>
91+
<path
92+
stroke='currentColor'
93+
strokeDasharray='0.1 4'
94+
strokeLinecap='round'
95+
strokeWidth='2'
96+
d='M1 1h14'
97+
/>
98+
</Box>
99+
);
100+
}

0 commit comments

Comments
 (0)