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

style(experience): fix the terms of use link style #5771

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


.link {
color: var(--color-type-primary);
display: inline;
}

Expand Down
9 changes: 5 additions & 4 deletions packages/experience/src/components/TermsLinks/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { useTranslation } from 'react-i18next';

import TextLink from '@/components/TextLink';
import TextLink, { type Props as TextLinkProps } from '@/components/TextLink';

import * as styles from './index.module.scss';

type Props = {
readonly linkType?: TextLinkProps['type'];
// eslint-disable-next-line react/boolean-prop-naming
readonly inline?: boolean;
readonly termsOfUseUrl?: string;
readonly privacyPolicyUrl?: string;
};

const TermsLinks = ({ inline, termsOfUseUrl, privacyPolicyUrl }: Props) => {
const TermsLinks = ({ inline, termsOfUseUrl, privacyPolicyUrl, linkType = 'secondary' }: Props) => {
const { t } = useTranslation();

return (
Expand All @@ -21,7 +22,7 @@ const TermsLinks = ({ inline, termsOfUseUrl, privacyPolicyUrl }: Props) => {
className={styles.link}
text="description.terms_of_use"
href={termsOfUseUrl}
type="secondary"
type={linkType}
target="_blank"
onClick={(event) => {
event.stopPropagation();
Expand All @@ -35,7 +36,7 @@ const TermsLinks = ({ inline, termsOfUseUrl, privacyPolicyUrl }: Props) => {
className={styles.link}
text="description.privacy_policy"
href={privacyPolicyUrl}
type="secondary"
type={linkType}
target="_blank"
onClick={(event) => {
event.stopPropagation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Props = {
readonly className?: string;
};

const TermsAndPrivacy = ({ className }: Props) => {
const TermsAndPrivacyCheckbox = ({ className }: Props) => {
const { termsAgreement, setTermsAgreement, termsOfUseUrl, privacyPolicyUrl, isTermsDisabled } =
useTerms();
const { t } = useTranslation();
Expand Down Expand Up @@ -57,4 +57,4 @@ const TermsAndPrivacy = ({ className }: Props) => {
);
};

export default TermsAndPrivacy;
export default TermsAndPrivacyCheckbox;
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { conditional } from '@silverhand/essentials';
import { useContext } from 'react';
import { useTranslation, Trans } from 'react-i18next';
import { Trans, useTranslation } from 'react-i18next';

import PageContext from '@/Providers/PageContextProvider/PageContext';
import TermsLinks from '@/components/TermsLinks';

// Used by useTerms hook to display the terms and privacy policy confirmation modal
// This component should be used as the ModalContent prop in the useConfirmModal hook
const TermsAndPrivacyConfirmModalContent = () => {
const { experienceSettings } = useContext(PageContext);
const { termsOfUseUrl, privacyPolicyUrl } = experienceSettings ?? {};
Expand All @@ -17,6 +19,7 @@ const TermsAndPrivacyConfirmModalContent = () => {
link: (
<TermsLinks
inline
linkType="primary"
termsOfUseUrl={conditional(termsOfUseUrl)}
privacyPolicyUrl={conditional(privacyPolicyUrl)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type Props = {
readonly className?: string;
};

// For sign-in page displaying terms and privacy links use only. No user interaction is needed.
const TermsAndPrivacyLinks = ({ className }: Props) => {
const { termsOfUseUrl, privacyPolicyUrl, isTermsDisabled } = useTerms();

Expand Down
4 changes: 2 additions & 2 deletions packages/experience/src/hooks/use-terms.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { conditional } from '@silverhand/essentials';
import { useContext, useCallback, useMemo } from 'react';
import { useCallback, useContext, useMemo } from 'react';

import PageContext from '@/Providers/PageContextProvider/PageContext';
import TermsAndPrivacyConfirmModalContent from '@/containers/TermsAndPrivacy/TermsAndPrivacyConfirmModalContent';
import TermsAndPrivacyConfirmModalContent from '@/containers/TermsAndPrivacyConfirmModalContent';

import { useConfirmModal } from './use-confirm-modal';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import type { SignInIdentifier } from '@logto/schemas';
import classNames from 'classnames';
import { useCallback, useEffect } from 'react';
import { useForm, Controller } from 'react-hook-form';
import { Controller, useForm } from 'react-hook-form';
import { useTranslation } from 'react-i18next';

import LockIcon from '@/assets/icons/lock.svg';
import Button from '@/components/Button';
import ErrorMessage from '@/components/ErrorMessage';
import { SmartInputField } from '@/components/InputFields';
import type { IdentifierInputValue } from '@/components/InputFields/SmartInputField';
import TermsAndPrivacy from '@/containers/TermsAndPrivacy';
import TermsAndPrivacyCheckbox from '@/containers/TermsAndPrivacyCheckbox';
import useSingleSignOnWatch from '@/hooks/use-single-sign-on-watch';
import useTerms from '@/hooks/use-terms';
import { getGeneralIdentifierErrorMessage, validateIdentifierField } from '@/utils/form';
Expand Down Expand Up @@ -130,7 +130,7 @@ const IdentifierRegisterForm = ({ className, autoFocus, signUpMethods }: Props)
* Form rerender will trigger autofill.
* If the autofill value is SSO enabled, it will always show SSO form.
*/}
<TermsAndPrivacy
<TermsAndPrivacyCheckbox
className={classNames(styles.terms, showSingleSignOnForm && styles.hidden)}
/>

Expand Down
5 changes: 3 additions & 2 deletions packages/experience/src/pages/Register/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SingleSignOnFormModeContext from '@/Providers/SingleSignOnFormModeContext
import Divider from '@/components/Divider';
import TextLink from '@/components/TextLink';
import SocialSignInList from '@/containers/SocialSignInList';
import TermsAndPrivacy from '@/containers/TermsAndPrivacy';
import TermsAndPrivacyCheckbox from '@/containers/TermsAndPrivacyCheckbox';
import { useSieMethods } from '@/hooks/use-sie';

import ErrorPage from '../ErrorPage';
Expand Down Expand Up @@ -79,9 +79,10 @@ const Register = () => {
{signUpMethods.length > 0 && (
<IdentifierRegisterForm signUpMethods={signUpMethods} className={styles.main} />
)}
{/* Social sign-in methods only */}
{signUpMethods.length === 0 && socialConnectors.length > 0 && (
<>
<TermsAndPrivacy className={styles.terms} />
<TermsAndPrivacyCheckbox className={styles.terms} />
<SocialSignInList className={styles.main} socialConnectors={socialConnectors} />
</>
)}
Expand Down
Loading