From f898ade9d33ced788bd59961e703feadde9df27e Mon Sep 17 00:00:00 2001 From: witt Date: Wed, 17 Feb 2021 19:22:42 +0800 Subject: [PATCH] fix(snippet): fix typo of copy type (#461) --- components/snippet/snippet.tsx | 7 ++++++- components/utils/prop-types.ts | 2 +- pages/en-us/components/snippet.mdx | 2 +- pages/zh-cn/components/snippet.mdx | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/components/snippet/snippet.tsx b/components/snippet/snippet.tsx index e8847577b..09655db0e 100644 --- a/components/snippet/snippet.tsx +++ b/components/snippet/snippet.tsx @@ -6,6 +6,7 @@ import { getStyles } from './styles' import SnippetIcon from './snippet-icon' import useClipboard from '../utils/use-clipboard' import useToasts from '../use-toasts' +import useWarning from 'components/utils/use-warning' interface Props { text?: string | string[] @@ -59,6 +60,10 @@ const Snippet: React.FC> = ({ const ref = useRef(null) const isMultiLine = text && Array.isArray(text) + if (copyType === 'slient') { + useWarning('"slient" is deprecated, use "silent" instead of it.', 'Snippet') + } + const style = useMemo(() => getStyles(type, theme.palette, filled), [ type, theme.palette, @@ -79,7 +84,7 @@ const Snippet: React.FC> = ({ const clickHandler = () => { if (!childText || !showCopyIcon) return copy(childText) - if (copyType === 'slient') return + if (copyType === 'silent' || copyType === 'slient') return setToast({ text: toastText, type: toastType }) } diff --git a/components/utils/prop-types.ts b/components/utils/prop-types.ts index 1201200a7..da1c7594b 100644 --- a/components/utils/prop-types.ts +++ b/components/utils/prop-types.ts @@ -41,7 +41,7 @@ const cardTypes = tuple( 'cyan', ) -const copyTypes = tuple('default', 'slient', 'prevent') +const copyTypes = tuple('default', 'silent', 'prevent', 'slient') const triggerTypes = tuple('hover', 'click') diff --git a/pages/en-us/components/snippet.mdx b/pages/en-us/components/snippet.mdx index 0dd29e3f0..85eebf929 100644 --- a/pages/en-us/components/snippet.mdx +++ b/pages/en-us/components/snippet.mdx @@ -106,7 +106,7 @@ Display a snippet of copyable code for the command line. | **type** | snippet types | [SnippetTypes](#snippettypes) | [SnippetTypes](#snippettypes) | `default` | | **filled** | filled style | `boolean` | - | `false` | | **width** | set CSS string | `string` | - | `initial` | -| **copy** | function of copy button | `CopyTypes` | `'default', 'slient', 'prevent'` | `default` | +| **copy** | function of copy button | `CopyTypes` | `'default', 'silent', 'prevent'` | `default` | | **symbol** | symbol snippet | `string` | - | `$` | | **toastText** | toast text | `string` | - | `Copied to clipboard!` | | **toastType** | toast type | `NormalTypes` | [NormalTypes](#normaltypes) | `success` | diff --git a/pages/zh-cn/components/snippet.mdx b/pages/zh-cn/components/snippet.mdx index 2fbecec8c..1d37f07f7 100644 --- a/pages/zh-cn/components/snippet.mdx +++ b/pages/zh-cn/components/snippet.mdx @@ -90,7 +90,7 @@ export const meta = { | **type** | 组件类型 | [SnippetTypes](#snippettypes) | [SnippetTypes](#snippettypes) | `default` | | **filled** | 填充风格的样式 | `boolean` | - | `false` | | **width** | 设置 CSS 宽度 | `string` | - | `initial` | -| **copy** | 拷贝按钮的工作方式 | `CopyTypes` | `'default', 'slient', 'prevent'` | `default` | +| **copy** | 拷贝按钮的工作方式 | `CopyTypes` | `'default', 'silent', 'prevent'` | `default` | | **symbol** | 组件左侧显示的字符 | `string` | - | `$` | | **toastText** | 拷贝提示的字符 | `string` | - | `Copied to clipboard!` | | **toastType** | 拷贝提示的类型 | `NormalTypes` | [NormalTypes](#normaltypes) | `success` |