Skip to content

Commit

Permalink
fix(snippet): fix typo of copy type (#461)
Browse files Browse the repository at this point in the history
  • Loading branch information
unix authored Feb 17, 2021
1 parent cfd0a48 commit f898ade
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion components/snippet/snippet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down Expand Up @@ -59,6 +60,10 @@ const Snippet: React.FC<React.PropsWithChildren<SnippetProps>> = ({
const ref = useRef<HTMLPreElement>(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,
Expand All @@ -79,7 +84,7 @@ const Snippet: React.FC<React.PropsWithChildren<SnippetProps>> = ({
const clickHandler = () => {
if (!childText || !showCopyIcon) return
copy(childText)
if (copyType === 'slient') return
if (copyType === 'silent' || copyType === 'slient') return
setToast({ text: toastText, type: toastType })
}

Expand Down
2 changes: 1 addition & 1 deletion components/utils/prop-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion pages/en-us/components/snippet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down
2 changes: 1 addition & 1 deletion pages/zh-cn/components/snippet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down

0 comments on commit f898ade

Please sign in to comment.