mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-23 20:00:56 +08:00
fix(snippet): fix typo of copy type (#461)
This commit is contained in:
@@ -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 })
|
||||
}
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user