|
1 | | -import { useOrganization } from '@clerk/shared/react/index'; |
| 1 | +import { __internal_useOrganizationBase } from '@clerk/shared/react/index'; |
2 | 2 | import React from 'react'; |
3 | 3 |
|
4 | 4 | import { useEnvironment } from '@/contexts'; |
5 | | -import { Box, Col, Flex, Icon, localizationKeys, Text, useAppearance } from '@/customizables'; |
| 5 | +import { Box, Col, descriptors, Flex, Heading, Icon, localizationKeys, Text, useAppearance } from '@/customizables'; |
6 | 6 | import { ApplicationLogo } from '@/elements/ApplicationLogo'; |
7 | 7 | import { NavBar, NavbarContextProvider } from '@/elements/Navbar'; |
8 | 8 | import { BoxIcon } from '@/icons'; |
| 9 | +import { mqu } from '@/styledSystem'; |
9 | 10 |
|
10 | 11 | type ConfigureSSONavbarProps = React.PropsWithChildren<{ |
11 | 12 | contentRef: React.RefObject<HTMLDivElement>; |
@@ -73,18 +74,118 @@ export const ConfigureSSONavbar = ({ children, contentRef }: ConfigureSSONavbarP |
73 | 74 | > |
74 | 75 | {applicationName} |
75 | 76 | </Text> |
76 | | - {organizationSettings.enabled && <OrganizationSidebarSubtitle />} |
| 77 | + {organizationSettings.enabled && <OrganizationSubtitle />} |
77 | 78 | </Col> |
78 | 79 | </Flex> |
79 | 80 | } |
80 | 81 | /> |
81 | | - {children} |
| 82 | + <Col |
| 83 | + ref={contentRef} |
| 84 | + elementDescriptor={descriptors.scrollBox} |
| 85 | + sx={t => ({ |
| 86 | + backgroundColor: t.colors.$colorBackground, |
| 87 | + position: 'relative', |
| 88 | + borderRadius: t.radii.$lg, |
| 89 | + width: '100%', |
| 90 | + overflow: 'hidden', |
| 91 | + borderWidth: t.borderWidths.$normal, |
| 92 | + borderStyle: t.borderStyles.$solid, |
| 93 | + borderColor: t.colors.$borderAlpha150, |
| 94 | + flex: 1, |
| 95 | + })} |
| 96 | + > |
| 97 | + <ConfigureSSOMobileNavbar /> |
| 98 | + {children} |
| 99 | + </Col> |
82 | 100 | </NavbarContextProvider> |
83 | 101 | ); |
84 | 102 | }; |
85 | 103 |
|
86 | | -const OrganizationSidebarSubtitle = (): JSX.Element | null => { |
87 | | - const { organization } = useOrganization(); |
| 104 | +const ConfigureSSOMobileNavbar = () => { |
| 105 | + const { parsedOptions } = useAppearance(); |
| 106 | + const { |
| 107 | + organizationSettings, |
| 108 | + displayConfig: { applicationName, logoImageUrl }, |
| 109 | + } = useEnvironment(); |
| 110 | + |
| 111 | + const hasLogo = Boolean(parsedOptions.logoImageUrl || logoImageUrl); |
| 112 | + |
| 113 | + return ( |
| 114 | + <Col |
| 115 | + as='header' |
| 116 | + elementDescriptor={descriptors.configureSSOMobileNavbar} |
| 117 | + sx={t => ({ |
| 118 | + display: 'none', |
| 119 | + [mqu.md]: { |
| 120 | + display: 'flex', |
| 121 | + }, |
| 122 | + gap: t.space.$4, |
| 123 | + padding: t.space.$5, |
| 124 | + borderBottomWidth: t.borderWidths.$normal, |
| 125 | + borderBottomStyle: t.borderStyles.$solid, |
| 126 | + borderBottomColor: t.colors.$borderAlpha100, |
| 127 | + })} |
| 128 | + > |
| 129 | + <Flex |
| 130 | + align='center' |
| 131 | + sx={t => ({ |
| 132 | + gap: t.space.$2, |
| 133 | + maxWidth: '100%', |
| 134 | + })} |
| 135 | + > |
| 136 | + {hasLogo ? ( |
| 137 | + <ApplicationLogo |
| 138 | + sx={t => ({ |
| 139 | + width: t.space.$9, |
| 140 | + height: t.space.$9, |
| 141 | + borderRadius: t.radii.$md, |
| 142 | + overflow: 'hidden', |
| 143 | + })} |
| 144 | + /> |
| 145 | + ) : ( |
| 146 | + <Box |
| 147 | + sx={t => ({ |
| 148 | + width: t.space.$9, |
| 149 | + height: t.space.$9, |
| 150 | + flexShrink: 0, |
| 151 | + borderRadius: t.radii.$md, |
| 152 | + backgroundColor: t.colors.$primary500, |
| 153 | + color: t.colors.$colorPrimaryForeground, |
| 154 | + display: 'flex', |
| 155 | + alignItems: 'center', |
| 156 | + justifyContent: 'center', |
| 157 | + })} |
| 158 | + aria-hidden |
| 159 | + > |
| 160 | + <Icon |
| 161 | + icon={BoxIcon} |
| 162 | + sx={t => ({ width: t.sizes.$4, height: t.sizes.$4 })} |
| 163 | + /> |
| 164 | + </Box> |
| 165 | + )} |
| 166 | + |
| 167 | + <Col sx={{ minWidth: 0 }}> |
| 168 | + <Text |
| 169 | + as='p' |
| 170 | + truncate |
| 171 | + > |
| 172 | + {applicationName} |
| 173 | + </Text> |
| 174 | + {organizationSettings.enabled && <OrganizationSubtitle />} |
| 175 | + </Col> |
| 176 | + </Flex> |
| 177 | + |
| 178 | + <Heading |
| 179 | + as='h3' |
| 180 | + localizationKey={localizationKeys('configureSSO.navbar.title')} |
| 181 | + sx={t => ({ fontSize: t.fontSizes.$lg })} |
| 182 | + /> |
| 183 | + </Col> |
| 184 | + ); |
| 185 | +}; |
| 186 | + |
| 187 | +const OrganizationSubtitle = (): JSX.Element | null => { |
| 188 | + const organization = __internal_useOrganizationBase(); |
88 | 189 |
|
89 | 190 | if (!organization) { |
90 | 191 | return null; |
|
0 commit comments