fix(snippet): fix typo of copy type (#461)

This commit is contained in:
witt
2021-02-17 19:22:42 +08:00
committed by GitHub
parent cfd0a48688
commit f898ade9d3
4 changed files with 9 additions and 4 deletions

View File

@@ -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<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,
@@ -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 })
}

View File

@@ -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')