Skip to content

Commit 3dda9d7

Browse files
committed
Display domain as sidebar footer
1 parent 95ec00a commit 3dda9d7

2 files changed

Lines changed: 38 additions & 4 deletions

File tree

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

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { useOrganization } from '@clerk/shared/react/index';
1+
import { useOrganization, useUser } from '@clerk/shared/react/index';
22
import React from 'react';
33

44
import { useEnvironment } from '@/contexts';
5-
import { Box, Col, Flex, Icon, localizationKeys, Text, useAppearance } from '@/customizables';
5+
import { Box, Col, Flex, Hr, Icon, localizationKeys, Text, useAppearance } from '@/customizables';
66
import { ApplicationLogo } from '@/elements/ApplicationLogo';
77
import { NavBar, NavbarContextProvider } from '@/elements/Navbar';
88
import { BoxIcon } from '@/icons';
@@ -77,6 +77,7 @@ export const ConfigureSSONavbar = ({ children, contentRef }: ConfigureSSONavbarP
7777
title={localizationKeys('configureSSO.navbar.title')}
7878
routes={[]}
7979
contentRef={contentRef}
80+
footer={<PrimaryEmailDomainFooter />}
8081
/>
8182
{children}
8283
</NavbarContextProvider>
@@ -100,3 +101,31 @@ const OrganizationSidebarSubtitle = (): JSX.Element | null => {
100101
</Text>
101102
);
102103
};
104+
105+
const PrimaryEmailDomainFooter = (): JSX.Element | null => {
106+
const { user } = useUser();
107+
const emailDomain = user?.primaryEmailAddress?.emailAddress.split('@')[1];
108+
109+
if (!emailDomain) {
110+
return null;
111+
}
112+
113+
return (
114+
<Col
115+
sx={t => ({
116+
gap: t.space.$6,
117+
padding: `${t.space.$none} ${t.space.$3}`,
118+
})}
119+
>
120+
<Hr sx={{ backgroundColor: 'borderAlpha100' }} />
121+
122+
<Text
123+
as='span'
124+
truncate
125+
sx={{ textDecoration: 'underline' }}
126+
>
127+
{emailDomain}
128+
</Text>
129+
</Col>
130+
);
131+
};

packages/ui/src/elements/Navbar.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ type NavBarProps = {
5050
contentRef: React.RefObject<HTMLDivElement>;
5151
routes: NavbarRoute[];
5252
header?: React.ReactNode;
53+
footer?: React.ReactNode;
5354
};
5455

5556
export const NavBar = (props: NavBarProps) => {
56-
const { contentRef, title, titleSx, containerSx, description, routes, header } = props;
57+
const { contentRef, title, titleSx, containerSx, description, routes, header, footer } = props;
5758
const { close } = useNavbarContext();
5859
const { navigate } = useRouter();
5960
const { navigateToFlowStart } = useNavigateToFlowStart();
@@ -132,13 +133,15 @@ export const NavBar = (props: NavBarProps) => {
132133
titleSx={titleSx}
133134
containerSx={containerSx}
134135
description={description}
136+
footer={footer}
135137
>
136138
{header}
137139
{items}
138140
</NavbarContainer>
139141
<MobileNavbarContainer>
140142
{header}
141143
{items}
144+
{footer}
142145
</MobileNavbarContainer>
143146
</>
144147
);
@@ -150,9 +153,10 @@ const NavbarContainer = (
150153
titleSx?: ThemableCssProp;
151154
containerSx?: ThemableCssProp;
152155
description?: LocalizationKey | string;
156+
footer?: React.ReactNode;
153157
}>,
154158
) => {
155-
const { title, titleSx, containerSx, description } = props;
159+
const { title, titleSx, containerSx, description, footer } = props;
156160
return (
157161
<Col
158162
elementDescriptor={descriptors.navbar}
@@ -174,6 +178,7 @@ const NavbarContainer = (
174178
<DevModeOverlay />
175179

176180
<Col sx={[t => ({ gap: t.space.$6, flex: `0 0 ${t.space.$60}` }), containerSx]}>
181+
{footer}
177182
<Col
178183
sx={t => ({
179184
gap: t.space.$0x5,

0 commit comments

Comments
 (0)