Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(console): google one tap #6034

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: update figure and phrase
  • Loading branch information
gao-sun committed Jun 17, 2024
commit d3fcf77e3cdd5fd02ca703e642f51c59cfcbd0b1
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
Loading