Skip to content

Commit

Permalink
chore(icon): update demo (#2214)
Browse files Browse the repository at this point in the history
  • Loading branch information
eiinu authored Apr 30, 2024
1 parent 6b603f1 commit 9beaa1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/packages/icon/demos/h5/demo7.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { camelCase } from '@/utils/camel-case'
const generateAMCopyText = (icon: any) => {
return `<${camelCase(icon.name, {
pascalCase: true,
})} className="${`nut-icon-${icon['animation-name']} nut-icon-${icon['animation-time']}`}" />`
})} className="${`nut-icon-${icon['animation-name']} nut-icon-${icon['animation-time']}`}" />`
}

const copyTag = (text: string) => {
Expand Down Expand Up @@ -37,7 +37,7 @@ const Demo7 = () => {
>
<IconFont
name={icon.name}
className={`nut-icon-${icon['animation-name']} nut-icon-${icon['animation-time']}`}
className={`nut-icon-${icon['animation-name']} nut-icon-${icon['animation-time']}`}
/>
</li>
)
Expand Down
22 changes: 6 additions & 16 deletions src/packages/icon/demos/taro/demo7.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import React, { useState } from 'react'
import { IconFontConfig, IconFont } from '@nutui/icons-react-taro'
import { Cell } from '@/packages/nutui.react.taro'
import { Cell, Toast } from '@/packages/nutui.react.taro'
import { camelCase } from '@/utils/camel-case'

const Demo7 = () => {
const generateCopyText = (name: string) => {
return `<${camelCase(name, { pascalCase: true })} />`
}
const generateAMCopyText = (icon: any) => {
return `<${camelCase(icon.name, {
pascalCase: true,
})} className='${`nut-icon-${icon['animation-name']} nut-icon-${icon['animation-time']}`}' />`
})} className='${`nut-icon-${icon['animation-name']} nut-icon-${icon['animation-time']}`}' />`
}
const copyTag = (text: string) => {
const input = document.createElement('input')
Expand All @@ -23,20 +20,13 @@ const Demo7 = () => {
document.body.removeChild(input)
}
const [state, setState] = useState({
msg: '',
type: 'text',
cover: false,
content: '',
visible: false,
duration: 2,
closeOnOverlayClick: false,
title: '',
bottom: '',
icon: '',
center: true,
})

return (
<>
<Toast visible={state.visible} content={state.content} type="text" />
{(IconFontConfig as any).style.map((item: any) => {
return (
<Cell.Group key={item.name} title={item.name}>
Expand All @@ -58,7 +48,7 @@ const Demo7 = () => {
setState({
...state,
visible: true,
msg: generateCopyText(icon),
content: generateAMCopyText(icon),
})
}}
style={{
Expand All @@ -73,7 +63,7 @@ const Demo7 = () => {
>
<IconFont
name={icon.name}
className={`nut-icon-${icon['animation-name']} nut-icon-${icon['animation-time']}`}
className={`nut-icon-${icon['animation-name']} nut-icon-${icon['animation-time']}`}
/>
</li>
)
Expand Down

0 comments on commit 9beaa1e

Please sign in to comment.