Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions packages/ui/src/components/OAuthConsent/ListGroup.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { Box, descriptors } from '@/ui/customizables';
import { Text } from '@/ui/customizables';
Comment thread
alexcarpenter marked this conversation as resolved.
Outdated
import { common } from '@/ui/styledSystem';
import { colors } from '@/ui/utils/colors';
import type { ComponentProps } from 'react';

export function ListGroup({ children, sx, ...props }: Omit<ComponentProps<typeof Box>, 'elementDescriptor'>) {
return (
<Box
{...props}
sx={[
t => ({
textAlign: 'start',
borderWidth: t.borderWidths.$normal,
borderStyle: t.borderStyles.$solid,
borderColor: t.colors.$borderAlpha100,
borderRadius: t.radii.$lg,
overflow: 'hidden',
}),
sx,
]}
elementDescriptor={descriptors.listGroup}
>
{children}
</Box>
);
}

export function ListGroupHeader({ children, sx, ...props }: Omit<ComponentProps<typeof Box>, 'elementDescriptor'>) {
return (
<Box
{...props}
sx={[
t => ({
padding: t.space.$3,
background: common.mergedColorsBackground(
colors.setAlpha(t.colors.$colorBackground, 1),
t.colors.$neutralAlpha50,
),
}),
sx,
]}
elementDescriptor={descriptors.listGroupHeader}
>
{children}
</Box>
);
}

export function ListGroupHeaderTitle(props: Omit<ComponentProps<typeof Text>, 'elementDescriptor'>) {
return (
<Text
{...props}
variant='subtitle'
elementDescriptor={descriptors.listGroupHeaderTitle}
/>
);
}

export function ListGroupContent({
children,
sx,
...props
}: Omit<ComponentProps<typeof Box>, 'as' | 'elementDescriptor'>) {
return (
<Box
{...props}
as='ul'
sx={[t => ({ margin: t.sizes.$none, padding: t.sizes.$none }), sx]}
elementDescriptor={descriptors.listGroupContent}
>
{children}
</Box>
);
}

export function ListGroupItem({
children,
sx,
...props
}: Omit<ComponentProps<typeof Box>, 'as' | 'elementDescriptor'>) {
return (
<Box
{...props}
as='li'
sx={[
t => ({
display: 'flex',
alignItems: 'baseline',
paddingInline: t.space.$3,
paddingBlock: t.space.$2,
borderTopWidth: t.borderWidths.$normal,
borderTopStyle: t.borderStyles.$solid,
borderTopColor: t.colors.$borderAlpha100,
'&::before': {
content: '""',
display: 'inline-block',
width: t.space.$1,
height: t.space.$1,
background: t.colors.$colorMutedForeground,
borderRadius: t.radii.$circle,
transform: 'translateY(-0.1875rem)',
marginInlineEnd: t.space.$2,
flexShrink: 0,
},
}),
sx,
]}
elementDescriptor={descriptors.listGroupItem}
>
{children}
</Box>
);
}

export function ListGroupItemLabel(props: Omit<ComponentProps<typeof Text>, 'elementDescriptor'>) {
return (
<Text
{...props}
variant='subtitle'
elementDescriptor={descriptors.listGroupItemLabel}
/>
);
}
90 changes: 24 additions & 66 deletions packages/ui/src/components/OAuthConsent/OAuthConsent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ import { common } from '@/ui/styledSystem';
import { colors } from '@/ui/utils/colors';
import { LogoGroup, LogoGroupItem, LogoGroupIcon, LogoGroupSeparator } from './LogoGroup';
import { OrgSelect } from './OrgSelect';
import {
ListGroup,
ListGroupContent,
ListGroupHeader,
ListGroupHeaderTitle,
ListGroupItem,
ListGroupItemLabel,
} from './ListGroup';

const OFFLINE_ACCESS_SCOPE = 'offline_access';

Expand Down Expand Up @@ -121,76 +129,26 @@ export function OAuthConsentInternal() {
</Header.Root>

{selectOptions.length > 0 && (
<Box>
<OrgSelect
options={selectOptions}
value={selectedValue}
onChange={setSelectedValue}
/>
</Box>
<OrgSelect
options={selectOptions}
value={selectedValue}
onChange={setSelectedValue}
/>
)}

<Box
sx={t => ({
textAlign: 'start',
borderWidth: t.borderWidths.$normal,
borderStyle: t.borderStyles.$solid,
borderColor: t.colors.$borderAlpha100,
borderRadius: t.radii.$lg,
overflow: 'hidden',
})}
>
<Box
sx={t => ({
padding: t.space.$3,
background: common.mergedColorsBackground(
colors.setAlpha(t.colors.$colorBackground, 1),
t.colors.$neutralAlpha50,
),
})}
>
<Text
variant='subtitle'
localizationKey={`This will allow ${oAuthApplicationName} access to:`}
/>
</Box>
<Box
as='ul'
sx={t => ({ margin: t.sizes.$none, padding: t.sizes.$none })}
>
<ListGroup>
<ListGroupHeader>
<ListGroupHeaderTitle localizationKey={`This will allow ${oAuthApplicationName} access to:`} />
</ListGroupHeader>
<ListGroupContent>
{displayedScopes.map(item => (
<Box
key={item.scope}
sx={t => ({
display: 'flex',
alignItems: 'baseline',
paddingInline: t.space.$3,
paddingBlock: t.space.$2,
borderTopWidth: t.borderWidths.$normal,
borderTopStyle: t.borderStyles.$solid,
borderTopColor: t.colors.$borderAlpha100,
'&::before': {
content: '""',
display: 'inline-block',
width: t.space.$1,
height: t.space.$1,
background: t.colors.$colorMutedForeground,
borderRadius: t.radii.$circle,
transform: 'translateY(-0.1875rem)',
marginInlineEnd: t.space.$2,
flexShrink: 0,
},
})}
as='li'
>
<Text
variant='subtitle'
localizationKey={item.description || item.scope || ''}
/>
</Box>
<ListGroupItem key={item.scope}>
<ListGroupItemLabel>{item.description || item.scope || ''}</ListGroupItemLabel>
</ListGroupItem>
))}
</Box>
</Box>
</ListGroupContent>
</ListGroup>

<Alert colorScheme='warning'>
<Text
colorScheme='warning'
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/components/OAuthConsent/OrgSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export function OrgSelect({ options, value, onChange }: OrgSelectProps) {
sx={theme => ({
inlineSize: 'min(100%, 16rem)',
paddingInline: theme.space.$3,
marginInline: 'auto',
})}
>
<Image
Expand Down
7 changes: 7 additions & 0 deletions packages/ui/src/customizables/elementDescriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ export const APPEARANCE_KEYS = containsAllElementsConfigKeys([
'logoGroupIcon',
'logoGroupSeparator',

'listGroup',
'listGroupHeader',
'listGroupHeaderTitle',
'listGroupContent',
'listGroupItem',
'listGroupItemLabel',

'header',
'headerTitle',
'headerSubtitle',
Expand Down
7 changes: 7 additions & 0 deletions packages/ui/src/internal/appearance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ export type ElementsConfig = {
logoGroupIcon: WithOptions;
logoGroupSeparator: WithOptions;

listGroup: WithOptions;
listGroupHeader: WithOptions;
listGroupHeaderTitle: WithOptions;
listGroupContent: WithOptions;
listGroupItem: WithOptions;
listGroupItemLabel: WithOptions;

header: WithOptions;
headerTitle: WithOptions;
headerSubtitle: WithOptions;
Expand Down
Loading