From f8c7c0dfa325d2b8e84eda0cb13405cd9c6d7647 Mon Sep 17 00:00:00 2001 From: Xiao Yijun Date: Fri, 14 Oct 2022 10:18:06 +0800 Subject: [PATCH] refactor(console): support text button in the `Button` component (#2146) --- .../console/src/components/Alert/index.tsx | 2 +- .../src/components/Button/index.module.scss | 22 ++++++++++-------- .../console/src/components/Button/index.tsx | 2 +- .../src/components/MultiTextInput/index.tsx | 18 ++++++--------- .../console/src/components/Search/index.tsx | 2 +- .../components/TextButton/index.module.scss | 23 ------------------- .../components/GuideHeader/index.tsx | 2 +- .../src/pages/GetStarted/index.module.scss | 7 +----- .../console/src/pages/GetStarted/index.tsx | 17 ++++---------- .../SignInExperience/components/ColorForm.tsx | 2 +- .../components/GuideModal.tsx | 2 +- .../components/LanguagesForm.tsx | 4 +++- .../ManageLanguage/ManageLanguageButton.tsx | 10 ++++++-- .../components/index.module.scss | 5 ++++ .../UserDetails/components/UserConnectors.tsx | 3 ++- 15 files changed, 49 insertions(+), 72 deletions(-) delete mode 100644 packages/console/src/components/TextButton/index.module.scss diff --git a/packages/console/src/components/Alert/index.tsx b/packages/console/src/components/Alert/index.tsx index 42bb5a66e..ac32821bb 100644 --- a/packages/console/src/components/Alert/index.tsx +++ b/packages/console/src/components/Alert/index.tsx @@ -38,7 +38,7 @@ const Alert = ({ )} {action && onClick && (
-
)} diff --git a/packages/console/src/components/Button/index.module.scss b/packages/console/src/components/Button/index.module.scss index 57e8af522..07ea78ee9 100644 --- a/packages/console/src/components/Button/index.module.scss +++ b/packages/console/src/components/Button/index.module.scss @@ -53,9 +53,8 @@ height: 30px; padding: 0 _.unit(3); - &.plain { + &.text { height: 24px; - padding: 0; } } @@ -63,9 +62,9 @@ height: 36px; padding: 0 _.unit(4); - &.plain { + &.text { + font: var(--font-subhead-1); height: 28px; - padding: 0; } } @@ -73,9 +72,10 @@ height: 44px; padding: 0 _.unit(6); - &.plain { - height: 28px; // same as medium - padding: 0; + &.text { + // same as medium + font: var(--font-subhead-1); + height: 28px; } } @@ -196,11 +196,13 @@ } } - &.plain { + &.text { background: none; border-color: none; - font: var(--font-body-medium); + font: var(--font-label-large); color: var(--color-text-link); + padding: _.unit(0.5) _.unit(1); + border-radius: 4px; &:disabled { color: var(--color-disabled); @@ -211,7 +213,7 @@ } &:not(:disabled):hover { - text-decoration: underline; + background-color: var(--color-focused-variant); } } } diff --git a/packages/console/src/components/Button/index.tsx b/packages/console/src/components/Button/index.tsx index 9f0ee18fb..f5dd61d14 100644 --- a/packages/console/src/components/Button/index.tsx +++ b/packages/console/src/components/Button/index.tsx @@ -8,7 +8,7 @@ import { Ring as Spinner } from '@/components/Spinner'; import DangerousRaw from '../DangerousRaw'; import * as styles from './index.module.scss'; -export type ButtonType = 'primary' | 'danger' | 'outline' | 'plain' | 'default' | 'branding'; +export type ButtonType = 'primary' | 'danger' | 'outline' | 'text' | 'default' | 'branding'; type BaseProps = Omit, 'type' | 'size' | 'title'> & { htmlType?: 'button' | 'submit' | 'reset'; diff --git a/packages/console/src/components/MultiTextInput/index.tsx b/packages/console/src/components/MultiTextInput/index.tsx index 67d2722bd..e3b28690b 100644 --- a/packages/console/src/components/MultiTextInput/index.tsx +++ b/packages/console/src/components/MultiTextInput/index.tsx @@ -1,12 +1,10 @@ import { AdminConsoleKey } from '@logto/phrases'; -import classNames from 'classnames'; import { KeyboardEvent, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import Minus from '@/assets/images/minus.svg'; -import * as textButtonStyles from '@/components/TextButton/index.module.scss'; -import { onKeyDownHandler } from '@/utilities/a11y'; +import Button from '../Button'; import ConfirmModal from '../ConfirmModal'; import IconButton from '../IconButton'; import TextInput from '../TextInput'; @@ -86,15 +84,13 @@ const MultiTextInput = ({ title, value, onChange, onKeyPress, error, placeholder )} ))} -
- {t('general.add_another')} -
+ />