Skip to content

Commit

Permalink
feat(Icon): icon harmony adaptation (#2788)
Browse files Browse the repository at this point in the history
* feat(Icon): icon harmony adaptation

* fix: incorrect icon removed

* chore: update deps

---------

Co-authored-by: oasis <suanbanren@foxmail.com>
  • Loading branch information
xiaoyatong and oasis-cloud authored Nov 22, 2024
1 parent 0648882 commit f27d5bb
Show file tree
Hide file tree
Showing 11 changed files with 546 additions and 575 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"dependencies": {
"@babel/runtime": "^7.23.9",
"@nutui/icons-react": "^1.0.5",
"@nutui/icons-react-taro": "^2.0.0",
"@nutui/icons-react-taro": "^2.0.1",
"@nutui/jdesign-icons-react-taro": "1.0.6-beta.2",
"@nutui/touch-emulator": "^1.0.0",
"@react-spring/web": "~9.6.1",
Expand Down
1,013 changes: 503 additions & 510 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"author": "hanyuxinting"
},
{
"version": "2.0.0",
"version": "3.0.0",
"name": "Icon",
"type": "component",
"cName": "图标",
Expand Down
17 changes: 4 additions & 13 deletions src/packages/icon/demo.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Toast } from '@nutui/nutui-react-taro'
import { useTranslate } from '@/sites/assets/locale/taro'
import Header from '@/sites/components/header'
import Demo1 from './demos/taro/demo1'
import Demo2 from './demos/taro/demo2'
import Demo3 from './demos/taro/demo3'
import Demo4 from './demos/taro/demo4'
import Demo5 from './demos/taro/demo5'
Expand All @@ -16,28 +15,22 @@ import Demo7 from './demos/taro/demo7'
const IconDemo = () => {
const [translated] = useTranslate({
'zh-CN': {
'84aa6bce': '基础用法',
svg: 'SVG 按需使用',
'84aa6bce': '基础用法: SVG',
dab8a74f: '图片链接',
'52c15454': '图标颜色',
'7aeb5407': '图标大小',
f2e6c6d6: '基础图标',
},
'zh-TW': {
'84aa6bce': '基礎用法',
svg: 'SVG 按需使用',
'84aa6bce': '基礎用法: SVG',
dab8a74f: '圖片連結',
'52c15454': '圖示顏色',
'7aeb5407': '圖示大小',
f2e6c6d6: '基礎圖示',
},
'en-US': {
'84aa6bce': 'Basic Usage',
svg: 'SVG import On Demand',
'84aa6bce': 'Basic Usage: SVG',
dab8a74f: 'Image Link',
'52c15454': 'IconFont Color',
'7aeb5407': 'IconFont Size',
f2e6c6d6: 'Base IconFont',
},
})

Expand Down Expand Up @@ -72,10 +65,8 @@ const IconDemo = () => {
})
}}
/>
<View className="h2">{translated.svg}</View>
<Demo1 />
<View className="h2">{translated['84aa6bce']}</View>
<Demo2 />
<Demo1 />
<View className="h2">{translated.dab8a74f}</View>
<Demo3 />
<View className="h2">{translated['52c15454']}</View>
Expand Down
5 changes: 3 additions & 2 deletions src/packages/icon/demos/taro/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react'
import { Cell } from '@nutui/nutui-react-taro'
import { Add, Dongdong, UserAdd } from '@nutui/icons-react-taro'
import { Add, Dongdong, UserAdd, Minus } from '@nutui/icons-react-taro'

const Demo1 = () => {
return (
<Cell>
<Add color="red" style={{ marginRight: '10px' }} />
<UserAdd style={{ marginRight: '10px' }} />
<Dongdong />
<Dongdong style={{ marginRight: '10px' }} />
<Minus />
</Cell>
)
}
Expand Down
14 changes: 0 additions & 14 deletions src/packages/icon/demos/taro/demo2.tsx

This file was deleted.

3 changes: 2 additions & 1 deletion src/packages/icon/demos/taro/demo3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ const Demo3 = () => {
return (
<Cell>
<IconFont
size="40"
size={40}
style={{ width: 40, height: 40 }}
name="https://img11.360buyimg.com/imagetools/jfs/t1/137646/13/7132/1648/5f4c748bE43da8ddd/a3f06d51dcae7b60.png"
/>
</Cell>
Expand Down
16 changes: 4 additions & 12 deletions src/packages/icon/demos/taro/demo4.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
import React from 'react'
import { Cell } from '@nutui/nutui-react-taro'
import { IconFont } from '@nutui/icons-react-taro'
import { Dongdong } from '@nutui/icons-react-taro'

const Demo4 = () => {
return (
<Cell>
<IconFont
name="dongdong"
color="#FF0F23"
style={{ marginRight: '10px' }}
/>
<IconFont
name="dongdong"
color="#64b578"
style={{ marginRight: '10px' }}
/>
<IconFont name="dongdong" color="#ffd700" />
<Dongdong color="#FF0F23" style={{ marginRight: '10px' }} />
<Dongdong color="#64b578" style={{ marginRight: '10px' }} />
<Dongdong color="#ffd700" />
</Cell>
)
}
Expand Down
8 changes: 4 additions & 4 deletions src/packages/icon/demos/taro/demo5.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react'
import { Cell } from '@nutui/nutui-react-taro'
import { IconFont } from '@nutui/icons-react-taro'
import { Dongdong } from '@nutui/icons-react-taro'

const Demo5 = () => {
return (
<Cell style={{ alignItems: 'center' }}>
<IconFont name="dongdong" size="16" style={{ marginRight: '10px' }} />
<IconFont name="dongdong" size="20" style={{ marginRight: '10px' }} />
<IconFont name="dongdong" size="24" />
<Dongdong size="16" style={{ marginRight: '10px' }} />
<Dongdong size="20" style={{ marginRight: '10px' }} />
<Dongdong size="24" />
</Cell>
)
}
Expand Down
18 changes: 11 additions & 7 deletions src/packages/icon/demos/taro/demo6.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React, { useState } from 'react'
import { IconFontConfig, IconFont } from '@nutui/icons-react-taro'
import * as iconfonts from '@nutui/icons-react-taro'
import { Cell, Toast } from '@nutui/nutui-react-taro'
import { View } from '@tarojs/components'
import { camelCase } from '@/utils/camel-case'

const Demo6 = () => {
const generateCopyText = (name: string) => {
return `<${camelCase(name, { pascalCase: true })} />`
}

const copyTag = (text: string) => {
const input = document.createElement('input')
document.body.appendChild(input)
Expand All @@ -25,11 +27,11 @@ const Demo6 = () => {
return (
<>
<Toast visible={state.visible} content={state.content} type="text" />
{(IconFontConfig as any).data.map((item: any) => {
{(iconfonts.IconFontConfig as any).data.map((item: any) => {
return (
<Cell.Group key={item.name} title={item.name}>
<Cell>
<ul
<View
style={{
display: 'flex',
flexWrap: 'wrap',
Expand All @@ -39,7 +41,7 @@ const Demo6 = () => {
>
{item.icons.map((icon: any) => {
return (
<li
<View
key={Math.random()}
onClick={() => {
copyTag(generateCopyText(icon))
Expand All @@ -59,11 +61,13 @@ const Demo6 = () => {
justifyContent: 'center',
}}
>
<IconFont name={icon} />
</li>
{React.createElement(
iconfonts[camelCase(icon, { pascalCase: true })]
)}
</View>
)
})}
</ul>
</View>
</Cell>
</Cell.Group>
)
Expand Down
23 changes: 13 additions & 10 deletions src/packages/icon/demos/taro/demo7.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react'
import { IconFontConfig, IconFont } from '@nutui/icons-react-taro'
import * as iconfonts from '@nutui/icons-react-taro'
import { Cell, Toast } from '@nutui/nutui-react-taro'
import { View } from '@tarojs/components'
import { camelCase } from '@/utils/camel-case'

const Demo7 = () => {
Expand All @@ -27,11 +28,11 @@ const Demo7 = () => {
return (
<>
<Toast visible={state.visible} content={state.content} type="text" />
{(IconFontConfig as any).style.map((item: any) => {
{(iconfonts.IconFontConfig as any).style.map((item: any) => {
return (
<Cell.Group key={item.name} title={item.name}>
<Cell>
<ul
<View
style={{
display: 'flex',
flexWrap: 'wrap',
Expand All @@ -41,7 +42,7 @@ const Demo7 = () => {
>
{item.icons.map((icon: any) => {
return (
<li
<View
key={icon.name}
onClick={() => {
copyTag(generateAMCopyText(icon))
Expand All @@ -61,14 +62,16 @@ const Demo7 = () => {
justifyContent: 'center',
}}
>
<IconFont
name={icon.name}
className={`nut-icon-${icon['animation-name']} nut-icon-${icon['animation-time']}`}
/>
</li>
{React.createElement(
iconfonts[camelCase(icon.name, { pascalCase: true })],
{
className: `nut-icon-${icon['animation-name']} nut-icon-${icon['animation-time']}`,
}
)}
</View>
)
})}
</ul>
</View>
</Cell>
</Cell.Group>
)
Expand Down

0 comments on commit f27d5bb

Please sign in to comment.