Skip to content

Commit f6f5dd0

Browse files
committed
Forward containerSx to Navbar
1 parent 4fc38a0 commit f6f5dd0

2 files changed

Lines changed: 42 additions & 34 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ export const ConfigureSSONavbar = ({ children, contentRef }: ConfigureSSONavbarP
7070
</Flex>
7171
}
7272
titleSx={t => ({ fontSize: t.fontSizes.$lg })}
73+
containerSx={{
74+
flexDirection: 'column-reverse',
75+
flex: 0,
76+
}}
7377
title={localizationKeys('configureSSO.navbar.title')}
7478
routes={[]}
7579
contentRef={contentRef}

packages/ui/src/elements/Navbar.tsx

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@ export type NavbarRoute = {
4545
type NavBarProps = {
4646
title: LocalizationKey;
4747
titleSx?: ThemableCssProp;
48+
containerSx?: ThemableCssProp;
4849
description?: LocalizationKey;
4950
contentRef: React.RefObject<HTMLDivElement>;
5051
routes: NavbarRoute[];
5152
header?: React.ReactNode;
5253
};
5354

5455
export const NavBar = (props: NavBarProps) => {
55-
const { contentRef, title, titleSx, description, routes, header } = props;
56+
const { contentRef, title, titleSx, containerSx, description, routes, header } = props;
5657
const { close } = useNavbarContext();
5758
const { navigate } = useRouter();
5859
const { navigateToFlowStart } = useNavigateToFlowStart();
@@ -91,43 +92,45 @@ export const NavBar = (props: NavBarProps) => {
9192
[router.currentPath],
9293
);
9394

94-
const items = (
95-
<Col
96-
elementDescriptor={descriptors.navbarButtons}
97-
sx={t => ({
98-
gap: t.space.$0x5,
99-
})}
100-
>
101-
{routes.map(r => (
102-
<NavButton
103-
key={r.id}
104-
elementDescriptor={descriptors.navbarButton}
105-
elementId={descriptors.navbarButton.setId(r.id as any)}
106-
iconElementDescriptor={descriptors.navbarButtonIcon}
107-
iconElementId={descriptors.navbarButtonIcon.setId(r.id) as any}
108-
onClick={handleNavigate(r)}
109-
icon={r.icon}
110-
isActive={checkIfActive(r)}
111-
sx={t => ({
112-
padding: `${t.space.$1x5} ${t.space.$3}`,
113-
minHeight: t.space.$8,
114-
})}
115-
>
116-
<Span
117-
elementDescriptor={descriptors.navbarButtonText}
118-
elementId={descriptors.navbarButtonText.setId(r.id as any)}
119-
localizationKey={r.name}
120-
/>
121-
</NavButton>
122-
))}
123-
</Col>
124-
);
95+
const items =
96+
routes.length > 0 ? (
97+
<Col
98+
elementDescriptor={descriptors.navbarButtons}
99+
sx={t => ({
100+
gap: t.space.$0x5,
101+
})}
102+
>
103+
{routes.map(r => (
104+
<NavButton
105+
key={r.id}
106+
elementDescriptor={descriptors.navbarButton}
107+
elementId={descriptors.navbarButton.setId(r.id as any)}
108+
iconElementDescriptor={descriptors.navbarButtonIcon}
109+
iconElementId={descriptors.navbarButtonIcon.setId(r.id) as any}
110+
onClick={handleNavigate(r)}
111+
icon={r.icon}
112+
isActive={checkIfActive(r)}
113+
sx={t => ({
114+
padding: `${t.space.$1x5} ${t.space.$3}`,
115+
minHeight: t.space.$8,
116+
})}
117+
>
118+
<Span
119+
elementDescriptor={descriptors.navbarButtonText}
120+
elementId={descriptors.navbarButtonText.setId(r.id as any)}
121+
localizationKey={r.name}
122+
/>
123+
</NavButton>
124+
))}
125+
</Col>
126+
) : null;
125127

126128
return (
127129
<>
128130
<NavbarContainer
129131
title={title}
130132
titleSx={titleSx}
133+
containerSx={containerSx}
131134
description={description}
132135
>
133136
{header}
@@ -145,10 +148,11 @@ const NavbarContainer = (
145148
props: React.PropsWithChildren<{
146149
title: LocalizationKey | string;
147150
titleSx?: ThemableCssProp;
151+
containerSx?: ThemableCssProp;
148152
description?: LocalizationKey | string;
149153
}>,
150154
) => {
151-
const { title, titleSx, description } = props;
155+
const { title, titleSx, containerSx, description } = props;
152156
return (
153157
<Col
154158
elementDescriptor={descriptors.navbar}
@@ -169,7 +173,7 @@ const NavbarContainer = (
169173
>
170174
<DevModeOverlay />
171175

172-
<Col sx={t => ({ gap: t.space.$6, flex: `0 0 ${t.space.$60}` })}>
176+
<Col sx={[t => ({ gap: t.space.$6, flex: `0 0 ${t.space.$60}` }), containerSx]}>
173177
<Col
174178
sx={t => ({
175179
gap: t.space.$0x5,

0 commit comments

Comments
 (0)