Skip to content

Commit c6a5e0f

Browse files
committedApr 6, 2024
feat(clerk-js,types,localizations): Add maintenance mode banner to SignIn and SignUp
1 parent 3e991ee commit c6a5e0f

File tree

10 files changed

+34
-4
lines changed

10 files changed

+34
-4
lines changed
 

‎.changeset/popular-rats-sneeze.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/localizations': patch
3+
'@clerk/clerk-js': patch
4+
'@clerk/types': patch
5+
---
6+
7+
Add maintenance mode banner to the SignIn and SignUp components. The text can be customized by updating the maintenanceMode localization key.

‎packages/clerk-js/src/core/resources/Environment.ts

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class Environment extends BaseResource implements EnvironmentResource {
1818
displayConfig!: DisplayConfigResource;
1919
userSettings!: UserSettingsResource;
2020
organizationSettings!: OrganizationSettingsResource;
21+
maintenanceMode!: boolean;
2122

2223
public static getInstance(): Environment {
2324
if (!Environment.instance) {
@@ -61,6 +62,7 @@ export class Environment extends BaseResource implements EnvironmentResource {
6162
this.displayConfig = new DisplayConfig(data.display_config);
6263
this.userSettings = new UserSettings(data.user_settings);
6364
this.organizationSettings = new OrganizationSettings(data.organization_settings);
65+
this.maintenanceMode = data.maintenance_mode;
6466
}
6567
return this;
6668
}

‎packages/clerk-js/src/ui/elements/Alert.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export const Alert = (props: AlertProps): JSX.Element | null => {
2222
elementDescriptor={descriptors.alert}
2323
elementId={descriptors.alert.setId(variant)}
2424
colorScheme={variant}
25+
align='start'
2526
{...rest}
27+
sx={[t => ({ backgroundColor: t.colors.$warningAlpha100 }), rest.sx]}
2628
>
2729
<AlertIcon
2830
elementId={descriptors.alert.setId(variant)}
@@ -39,9 +41,10 @@ export const Alert = (props: AlertProps): JSX.Element | null => {
3941
<Text
4042
elementDescriptor={descriptors.alertText}
4143
elementId={descriptors.alert.setId(variant)}
42-
colorScheme={variant === 'danger' ? 'danger' : 'secondary'}
44+
colorScheme={variant === 'danger' ? 'danger' : variant === 'warning' ? 'warning' : 'secondary'}
4345
variant='body'
4446
localizationKey={title}
47+
sx={{ textAlign: 'left' }}
4548
>
4649
{children}
4750
</Text>

‎packages/clerk-js/src/ui/elements/Card/CardContent.tsx

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
import React from 'react';
22

3-
import { descriptors, Flex, generateFlowPartClassname, Icon } from '../../customizables';
3+
import { useEnvironment } from '../../contexts';
4+
import {
5+
descriptors,
6+
Flex,
7+
generateFlowPartClassname,
8+
Icon,
9+
localizationKeys,
10+
useLocalizations,
11+
} from '../../customizables';
412
import { Close } from '../../icons';
513
import { type PropsOfComponent } from '../../styledSystem';
614
import { useFlowMetadata } from '../contexts';
715
import { IconButton } from '../IconButton';
816
import { useUnsafeModalContext } from '../Modal';
17+
import { CardAlert } from './CardAlert';
918

1019
type CardContentProps = PropsOfComponent<typeof Flex>;
1120
export const CardContent = React.forwardRef<HTMLDivElement, CardContentProps>((props, ref) => {
1221
const { children, sx, ...rest } = props;
1322
const flowMetadata = useFlowMetadata();
1423
const { toggle } = useUnsafeModalContext();
24+
const { maintenanceMode } = useEnvironment();
25+
const { t } = useLocalizations();
1526

1627
return (
1728
<Flex
@@ -63,6 +74,7 @@ export const CardContent = React.forwardRef<HTMLDivElement, CardContentProps>((p
6374
})}
6475
/>
6576
)}
77+
{(maintenanceMode || true) && <CardAlert variant={'warning'}>{t(localizationKeys('maintenanceMode'))}</CardAlert>}
6678
{children}
6779
</Flex>
6880
);

‎packages/clerk-js/src/ui/primitives/AlertIcon.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ExclamationCircle, ExclamationTriangle } from '../icons';
1+
import { ExclamationTriangle } from '../icons';
22
import type { StyleVariants } from '../styledSystem';
33
import { createVariants } from '../styledSystem';
44

@@ -24,7 +24,7 @@ export type AlertIconProps = OwnProps & StyleVariants<typeof applyVariants>;
2424

2525
export const AlertIcon = (props: AlertIconProps): JSX.Element => {
2626
const { variant, ...rest } = props;
27-
const Icon = variant === 'warning' ? ExclamationCircle : ExclamationTriangle;
27+
const Icon = ExclamationTriangle;
2828
return (
2929
<Icon
3030
{...filterProps(rest)}

‎packages/clerk-js/src/ui/primitives/Text.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const { applyVariants, filterProps } = createVariants(theme => {
1919
onPrimaryBg: { color: theme.colors.$colorTextOnPrimaryBackground },
2020
danger: { color: theme.colors.$danger500 },
2121
success: { color: theme.colors.$success500 },
22+
warning: { color: theme.colors.$warning500 },
2223
secondary: { color: theme.colors.$colorTextSecondary },
2324
inherit: { color: 'inherit' },
2425
},

‎packages/localizations/src/en-US.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import type { LocalizationResource } from '@clerk/types';
22

33
export const enUS: LocalizationResource = {
44
locale: 'en-US',
5+
maintenanceMode:
6+
"We are currently undergoing maintenance, but don't worry, it shouldn't take more than a few minutes.",
57
__experimental_formFieldLabel__passkeyName: 'Name of passkey',
68
backButton: 'Back',
79
badge__default: 'Default',

‎packages/types/src/environment.ts

+1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ export interface EnvironmentResource extends ClerkResource {
1313
isProduction: () => boolean;
1414
isDevelopmentOrStaging: () => boolean;
1515
onWindowLocationHost: () => boolean;
16+
maintenanceMode: boolean;
1617
}

‎packages/types/src/json.ts

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export interface EnvironmentJSON extends ClerkResourceJSON {
5858
display_config: DisplayConfigJSON;
5959
user_settings: UserSettingsJSON;
6060
organization_settings: OrganizationSettingsJSON;
61+
maintenance_mode: boolean;
6162
}
6263

6364
export interface ClientJSON extends ClerkResourceJSON {

‎packages/types/src/localization.ts

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export type LocalizationResource = DeepPartial<_LocalizationResource>;
1515

1616
type _LocalizationResource = {
1717
locale: string;
18+
maintenanceMode: LocalizationValue;
1819
/**
1920
* @experimental
2021
* Add role keys and their localized value

0 commit comments

Comments
 (0)
Please sign in to comment.