Skip to content

Commit

Permalink
refactor: update figure and phrase
Browse files Browse the repository at this point in the history
  • Loading branch information
gao-sun committed Jun 17, 2024
1 parent 8167dd6 commit d3fcf77
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { type GoogleConnectorConfig } from '@logto/connector-kit';
import { Theme } from '@logto/schemas';
import { Controller, useFormContext } from 'react-hook-form';
import { Trans, useTranslation } from 'react-i18next';

Expand All @@ -7,12 +8,19 @@ import Checkbox from '@/ds-components/Checkbox';
import FormField from '@/ds-components/FormField';
import Switch from '@/ds-components/Switch';
import TextLink from '@/ds-components/TextLink';
import useTheme from '@/hooks/use-theme';

import figure from './figure.webp';
import figureDark from './figure-dark.webp';
import figureLight from './figure-light.webp';
import * as styles from './index.module.scss';

type FormContext = { rawConfig: { oneTap: GoogleConnectorConfig['oneTap'] } };

const themeToFigure = Object.freeze({
[Theme.Light]: figureLight,
[Theme.Dark]: figureDark,
} satisfies Record<Theme, string>);

/**
* A card for configuring Google One Tap. It requires the `rawConfig.oneTap` field in the form
* context which can usually be obtained from the connector configuration context.
Expand All @@ -23,6 +31,7 @@ function GoogleOneTapCard() {
});
const { register, control, watch } = useFormContext<FormContext>();
const isEnabled = watch('rawConfig.oneTap.isEnabled');
const theme = useTheme();

return (
<FormCard
Expand All @@ -33,7 +42,11 @@ function GoogleOneTapCard() {
<Switch
description={
<>
<img className={styles.figure} src={figure} alt="Google One Tap figure" />
<img
className={styles.figure}
src={themeToFigure[theme]}
alt="Google One Tap figure"
/>
{t('enable_google_one_tap_description')}
</>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const connector_details = {
description: 'Google One Tap is a secure and easy way for users to sign in to your website.',
enable_google_one_tap: 'Enable Google One Tap',
enable_google_one_tap_description:
'Enable Google One Tap in your sign-in experience. Users can sign in with their Google account with a single tap.',
"Enable Google One Tap in your sign-in experience: Let users quickly sign up or sign in with their Google account if they're already signed in on their device.",
configure_google_one_tap: 'Configure Google One Tap',
auto_select: 'Auto-select credential if possible',
close_on_tap_outside: 'Cancel the prompt if user click/tap outside',
Expand Down

0 comments on commit d3fcf77

Please sign in to comment.