Skip to content

Commit 49e435e

Browse files
committed
Add metadata to sidebar
1 parent db3bbd5 commit 49e435e

2 files changed

Lines changed: 55 additions & 7 deletions

File tree

packages/ui/src/components/ConfigureSSO/ConfigureSSO.tsx

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import type { __experimental_ConfigureSSOProps } from '@clerk/shared/types';
22
import React from 'react';
33

4-
import { withCoreUserGuard } from '@/contexts';
5-
import { Flow, localizationKeys } from '@/customizables';
4+
import { useEnvironment, withCoreUserGuard } from '@/contexts';
5+
import { Col, Flex, Flow, localizationKeys, Text } from '@/customizables';
6+
import { ApplicationLogo } from '@/elements/ApplicationLogo';
67
import { withCardStateProvider } from '@/elements/contexts';
78
import { NavBar, NavbarContextProvider } from '@/elements/Navbar';
89
import { ProfileCard } from '@/elements/ProfileCard';
910
import { Route, Switch } from '@/router';
11+
import { useOrganization } from '@clerk/shared/react/index';
1012

1113
const ConfigureSSOInternal = () => {
1214
return (
@@ -24,13 +26,39 @@ const ConfigureSSOInternal = () => {
2426

2527
const AuthenticatedContent = withCoreUserGuard(() => {
2628
const contentRef = React.useRef<HTMLDivElement>(null);
29+
const { applicationName } = useEnvironment().displayConfig;
30+
const { organizationSettings } = useEnvironment();
31+
2732
return (
2833
<ProfileCard.Root
2934
sx={t => ({ display: 'grid', gridTemplateColumns: '1fr 3fr', height: t.sizes.$176, overflow: 'hidden' })}
3035
>
31-
{/* TODO -> Display application + organization information */}
3236
<NavbarContextProvider contentRef={contentRef}>
3337
<NavBar
38+
header={
39+
<Flex
40+
sx={t => ({
41+
gap: t.space.$2,
42+
padding: `${t.space.$none} ${t.space.$3}`,
43+
maxWidth: '100%',
44+
})}
45+
>
46+
<ApplicationLogo
47+
sx={t => ({ width: t.space.$9, height: t.space.$9, borderRadius: t.radii.$md, overflow: 'hidden' })}
48+
/>
49+
50+
<Col sx={t => ({ gap: t.space.$0x5, minWidth: 0 })}>
51+
<Text
52+
as='p'
53+
truncate
54+
>
55+
{applicationName}
56+
</Text>
57+
{organizationSettings.enabled && <OrganizationSubtitle />}
58+
</Col>
59+
</Flex>
60+
}
61+
titleSx={t => ({ fontSize: t.fontSizes.$lg })}
3462
title={localizationKeys('configureSSO.navbar.title')}
3563
routes={[]}
3664
contentRef={contentRef}
@@ -41,5 +69,18 @@ const AuthenticatedContent = withCoreUserGuard(() => {
4169
);
4270
});
4371

72+
const OrganizationSubtitle = () => {
73+
const { organization } = useOrganization();
74+
return (
75+
<Text
76+
as='span'
77+
truncate
78+
sx={t => ({ color: t.colors.$colorMutedForeground })}
79+
>
80+
{organization?.name}
81+
</Text>
82+
);
83+
};
84+
4485
export const ConfigureSSO: React.ComponentType<__experimental_ConfigureSSOProps> =
4586
withCardStateProvider(ConfigureSSOInternal);

packages/ui/src/elements/Navbar.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { ElementDescriptor, ElementId } from '../customizables/elementDescr
77
import { useNavigateToFlowStart, usePopover } from '../hooks';
88
import { Menu } from '../icons';
99
import { useRouter } from '../router';
10-
import type { PropsOfComponent } from '../styledSystem';
10+
import type { PropsOfComponent, ThemableCssProp } from '../styledSystem';
1111
import { animations, common, mqu } from '../styledSystem';
1212
import { colors } from '../utils/colors';
1313
import { Card } from './Card';
@@ -44,14 +44,15 @@ export type NavbarRoute = {
4444
};
4545
type NavBarProps = {
4646
title: LocalizationKey;
47+
titleSx?: ThemableCssProp;
4748
description?: LocalizationKey;
4849
contentRef: React.RefObject<HTMLDivElement>;
4950
routes: NavbarRoute[];
5051
header?: React.ReactNode;
5152
};
5253

5354
export const NavBar = (props: NavBarProps) => {
54-
const { contentRef, title, description, routes, header } = props;
55+
const { contentRef, title, titleSx, description, routes, header } = props;
5556
const { close } = useNavbarContext();
5657
const { navigate } = useRouter();
5758
const { navigateToFlowStart } = useNavigateToFlowStart();
@@ -126,6 +127,7 @@ export const NavBar = (props: NavBarProps) => {
126127
<>
127128
<NavbarContainer
128129
title={title}
130+
titleSx={titleSx}
129131
description={description}
130132
>
131133
{header}
@@ -140,9 +142,13 @@ export const NavBar = (props: NavBarProps) => {
140142
};
141143

142144
const NavbarContainer = (
143-
props: React.PropsWithChildren<{ title: LocalizationKey | string; description?: LocalizationKey | string }>,
145+
props: React.PropsWithChildren<{
146+
title: LocalizationKey | string;
147+
titleSx?: ThemableCssProp;
148+
description?: LocalizationKey | string;
149+
}>,
144150
) => {
145-
const { title, description } = props;
151+
const { title, titleSx, description } = props;
146152
return (
147153
<Col
148154
elementDescriptor={descriptors.navbar}
@@ -172,6 +178,7 @@ const NavbarContainer = (
172178
>
173179
<Heading
174180
as='h1'
181+
sx={titleSx}
175182
localizationKey={title}
176183
/>
177184

0 commit comments

Comments
 (0)