|
| 1 | +import { __internal_useOrganizationBase } from '@clerk/shared/react'; |
| 2 | + |
| 3 | +import { useEnvironment } from '@/contexts'; |
| 4 | +import { Box, Col, Flex, Heading, Icon, localizationKeys, Text, useAppearance } from '@/customizables'; |
| 5 | +import { ApplicationLogo } from '@/elements/ApplicationLogo'; |
| 6 | +import { BoxIcon } from '@/icons'; |
| 7 | +import { mqu } from '@/styledSystem'; |
| 8 | + |
| 9 | +export const ConfigureSSOMobileHeader = () => { |
| 10 | + const { parsedOptions } = useAppearance(); |
| 11 | + const { |
| 12 | + organizationSettings, |
| 13 | + displayConfig: { applicationName, logoImageUrl }, |
| 14 | + } = useEnvironment(); |
| 15 | + |
| 16 | + const hasLogo = Boolean(parsedOptions.logoImageUrl || logoImageUrl); |
| 17 | + |
| 18 | + return ( |
| 19 | + <Col |
| 20 | + as='header' |
| 21 | + sx={t => ({ |
| 22 | + display: 'none', |
| 23 | + [mqu.md]: { |
| 24 | + display: 'flex', |
| 25 | + }, |
| 26 | + gap: t.space.$4, |
| 27 | + padding: t.space.$5, |
| 28 | + borderBottomWidth: t.borderWidths.$normal, |
| 29 | + borderBottomStyle: t.borderStyles.$solid, |
| 30 | + borderBottomColor: t.colors.$borderAlpha100, |
| 31 | + })} |
| 32 | + > |
| 33 | + <Flex |
| 34 | + align='center' |
| 35 | + sx={t => ({ |
| 36 | + gap: t.space.$2, |
| 37 | + maxWidth: '100%', |
| 38 | + })} |
| 39 | + > |
| 40 | + {hasLogo ? ( |
| 41 | + <ApplicationLogo |
| 42 | + sx={t => ({ |
| 43 | + width: t.space.$9, |
| 44 | + height: t.space.$9, |
| 45 | + borderRadius: t.radii.$md, |
| 46 | + overflow: 'hidden', |
| 47 | + })} |
| 48 | + /> |
| 49 | + ) : ( |
| 50 | + <Box |
| 51 | + sx={t => ({ |
| 52 | + width: t.space.$9, |
| 53 | + height: t.space.$9, |
| 54 | + flexShrink: 0, |
| 55 | + borderRadius: t.radii.$md, |
| 56 | + backgroundColor: t.colors.$primary500, |
| 57 | + color: t.colors.$colorPrimaryForeground, |
| 58 | + display: 'flex', |
| 59 | + alignItems: 'center', |
| 60 | + justifyContent: 'center', |
| 61 | + })} |
| 62 | + aria-hidden |
| 63 | + > |
| 64 | + <Icon |
| 65 | + icon={BoxIcon} |
| 66 | + sx={t => ({ width: t.sizes.$4, height: t.sizes.$4 })} |
| 67 | + /> |
| 68 | + </Box> |
| 69 | + )} |
| 70 | + |
| 71 | + <Col sx={{ minWidth: 0 }}> |
| 72 | + <Text |
| 73 | + as='p' |
| 74 | + truncate |
| 75 | + > |
| 76 | + {applicationName} |
| 77 | + </Text> |
| 78 | + {organizationSettings.enabled && <OrganizationSubtitle />} |
| 79 | + </Col> |
| 80 | + </Flex> |
| 81 | + |
| 82 | + <Heading |
| 83 | + as='h3' |
| 84 | + localizationKey={localizationKeys('configureSSO.navbar.title')} |
| 85 | + sx={t => ({ fontSize: t.fontSizes.$lg })} |
| 86 | + /> |
| 87 | + </Col> |
| 88 | + ); |
| 89 | +}; |
| 90 | + |
| 91 | +const OrganizationSubtitle = (): JSX.Element | null => { |
| 92 | + const organization = __internal_useOrganizationBase(); |
| 93 | + |
| 94 | + if (!organization) { |
| 95 | + return null; |
| 96 | + } |
| 97 | + |
| 98 | + return ( |
| 99 | + <Text |
| 100 | + as='span' |
| 101 | + truncate |
| 102 | + sx={t => ({ color: t.colors.$colorMutedForeground })} |
| 103 | + > |
| 104 | + {organization.name} |
| 105 | + </Text> |
| 106 | + ); |
| 107 | +}; |
0 commit comments