Skip to content

Commit f898ade

Browse files
authored
fix(snippet): fix typo of copy type (#461)
1 parent cfd0a48 commit f898ade

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

components/snippet/snippet.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { getStyles } from './styles'
66
import SnippetIcon from './snippet-icon'
77
import useClipboard from '../utils/use-clipboard'
88
import useToasts from '../use-toasts'
9+
import useWarning from 'components/utils/use-warning'
910

1011
interface Props {
1112
text?: string | string[]
@@ -59,6 +60,10 @@ const Snippet: React.FC<React.PropsWithChildren<SnippetProps>> = ({
5960
const ref = useRef<HTMLPreElement>(null)
6061
const isMultiLine = text && Array.isArray(text)
6162

63+
if (copyType === 'slient') {
64+
useWarning('"slient" is deprecated, use "silent" instead of it.', 'Snippet')
65+
}
66+
6267
const style = useMemo(() => getStyles(type, theme.palette, filled), [
6368
type,
6469
theme.palette,
@@ -79,7 +84,7 @@ const Snippet: React.FC<React.PropsWithChildren<SnippetProps>> = ({
7984
const clickHandler = () => {
8085
if (!childText || !showCopyIcon) return
8186
copy(childText)
82-
if (copyType === 'slient') return
87+
if (copyType === 'silent' || copyType === 'slient') return
8388
setToast({ text: toastText, type: toastType })
8489
}
8590

components/utils/prop-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const cardTypes = tuple(
4141
'cyan',
4242
)
4343

44-
const copyTypes = tuple('default', 'slient', 'prevent')
44+
const copyTypes = tuple('default', 'silent', 'prevent', 'slient')
4545

4646
const triggerTypes = tuple('hover', 'click')
4747

pages/en-us/components/snippet.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Display a snippet of copyable code for the command line.
106106
| **type** | snippet types | [SnippetTypes](#snippettypes) | [SnippetTypes](#snippettypes) | `default` |
107107
| **filled** | filled style | `boolean` | - | `false` |
108108
| **width** | set CSS string | `string` | - | `initial` |
109-
| **copy** | function of copy button | `CopyTypes` | `'default', 'slient', 'prevent'` | `default` |
109+
| **copy** | function of copy button | `CopyTypes` | `'default', 'silent', 'prevent'` | `default` |
110110
| **symbol** | symbol snippet | `string` | - | `$` |
111111
| **toastText** | toast text | `string` | - | `Copied to clipboard!` |
112112
| **toastType** | toast type | `NormalTypes` | [NormalTypes](#normaltypes) | `success` |

pages/zh-cn/components/snippet.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export const meta = {
9090
| **type** | 组件类型 | [SnippetTypes](#snippettypes) | [SnippetTypes](#snippettypes) | `default` |
9191
| **filled** | 填充风格的样式 | `boolean` | - | `false` |
9292
| **width** | 设置 CSS 宽度 | `string` | - | `initial` |
93-
| **copy** | 拷贝按钮的工作方式 | `CopyTypes` | `'default', 'slient', 'prevent'` | `default` |
93+
| **copy** | 拷贝按钮的工作方式 | `CopyTypes` | `'default', 'silent', 'prevent'` | `default` |
9494
| **symbol** | 组件左侧显示的字符 | `string` | - | `$` |
9595
| **toastText** | 拷贝提示的字符 | `string` | - | `Copied to clipboard!` |
9696
| **toastType** | 拷贝提示的类型 | `NormalTypes` | [NormalTypes](#normaltypes) | `success` |

0 commit comments

Comments
 (0)