Skip to content

Commit

Permalink
Merge pull request #806 from GuYith/master
Browse files Browse the repository at this point in the history
feat: add icon
  • Loading branch information
dntzhang committed Aug 23, 2023
2 parents 764f8de + a773261 commit 135f1cc
Show file tree
Hide file tree
Showing 1,212 changed files with 64,543 additions and 37 deletions.
32 changes: 16 additions & 16 deletions tdesign/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,6 @@
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.22.6",
"@popperjs/core": "^2.11.8",
"@types/lodash": "4.14.182",
"@types/sortablejs": "^1.15.1",
"@types/tinycolor2": "^1.4.3",
"@types/validator": "^13.7.17",
"dayjs": "^1.11.9",
"lodash": "^4.17.21",
"marked": "^7.0.2",
"mitt": "^3.0.1",
"omi": "^6.25.18",
"omi-router": "^3.0.5",
"sortablejs": "^1.15.0",
"tinycolor2": "^1.6.0",
"validator": "^13.9.0",

"@omiu/action-sheet": "^0.0.5",
"@omiu/avatar": "^0.0.1",
"@omiu/badge": "^0.0.2",
Expand Down Expand Up @@ -145,12 +130,26 @@
"@omiu/tooltip": "0.0.1",
"@omiu/transition": "^0.0.16",
"@omiu/tree": "^0.0.21",
"@popperjs/core": "^2.11.8",
"@types/lodash": "4.14.182",
"@types/sortablejs": "^1.15.1",
"@types/tinycolor2": "^1.4.3",
"@types/validator": "^13.7.17",
"copy-to-clipboard": "^3.3.1",
"dayjs": "^1.11.9",
"lodash": "^4.17.21",
"markdown-it": "^12.1.0",
"markdown-it-anchor": "^8.1.0",
"marked": "^7.0.2",
"mitt": "^3.0.1",
"omi": "^6.25.18",
"omi-router": "^3.0.5",
"omi-twind": "^0.0.4",
"prismjs": "^1.24.0",
"twind": "^0.16.16"
"sortablejs": "^1.15.0",
"tinycolor2": "^1.6.0",
"twind": "^0.16.16",
"validator": "^13.9.0"
},
"devDependencies": {
"@babel/cli": "^7.22.9",
Expand Down Expand Up @@ -216,6 +215,7 @@
"rollup-plugin-styles": "^4.0.0",
"rollup-plugin-terser": "^7.0.2",
"semver": "^7.5.4",
"svgson": "^5.3.1",
"tdesign-icons-view": "^0.1.9",
"tdesign-publish-cli": "^0.0.12",
"tdesign-site-components": "^0.13.4",
Expand Down
32 changes: 16 additions & 16 deletions tdesign/desktop/site/site.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ export const docs = [
// component: () => import('tdesign-omi/button/button.md'),
// componentEn: () => import('tdesign-omi/button/button.en-US.md'),
},
// {
// title: 'Icon 图标',
// titleEn: 'Icon',
// name: 'icon',
// path: '/omi/components/icon',
// component: () => import('tdesign-omi/icon/icon.md'),
// componentEn: () => import('tdesign-omi/icon/icon.en-US.md'),
// },
{
title: 'Icon 图标',
titleEn: 'Icon',
name: 'icon',
path: '/icon',
// component: () => import('tdesign-omi/icon/icon.md'),
// componentEn: () => import('tdesign-omi/icon/icon.en-US.md'),
},
{
title: 'Link 链接',
titleEn: 'Link',
Expand Down Expand Up @@ -449,14 +449,14 @@ export const docs = [
// component: () => import('tdesign-omi/collapse/collapse.md'),
// componentEn: () => import('tdesign-omi/collapse/collapse.en-US.md'),
// },
// {
// title: 'Comment 评论',
// titleEn: 'Comment',
// name: 'comment',
// path: '/omi/components/comment',
// component: () => import('tdesign-omi/comment/comment.md'),
// componentEn: () => import('tdesign-omi/comment/comment.en-US.md'),
// },
{
title: 'Comment 评论',
titleEn: 'Comment',
name: 'comment',
path: '/comment',
// component: () => import('tdesign-omi/comment/comment.md'),
// componentEn: () => import('tdesign-omi/comment/comment.en-US.md'),
},
// {
// title: 'Image 图片',
// titleEn: 'Image',
Expand Down
193 changes: 193 additions & 0 deletions tdesign/desktop/site/src/components/web/icon/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
import { WeElement, define, h, createRef } from 'omi'
import '../common/index'
import {
StarFilledIcon,
ActivityIcon,
AddAndSubtractIcon,
AddCircleIcon,
AddRectangleIcon,
AddIcon,
AddressBookIcon,
} from '../../../../../src/icon/index'

import '../../../../../src/space/index'
import * as marked from 'marked'
import '../../../../code-box/index.tsx'
import '../../../../../src/icon/bookmark'

import { tw } from 'omi-twind'
const docsHTML = marked.parse(`
## API
### IconSVG Props
名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
style | Object | - | 样 | N
size | String | undefined | 图标尺寸,支持 'small', 'medium', 'large','35px', '3em' 等 | N
onClick | Function | | TS 类型:\`(context: { e: MouseEvent }) => void\`<br/>点击时触发 | N
`)
interface Props {
tab: string
}

define(
'page-icon',
class extends WeElement<Props> {
static defaultProps = {
tab: 'demo',
}

static css = `t-link { margin: 5px }`

tab = ['demo', 'api', 'design']
tdDocHeader = createRef()
tdDocTabs = createRef()

static propTypes = {
tab: String,
}

updateTab = (t: string) => {
this.updateProps({
tab: t,
})
}

isShow(tabStr: string) {
return this.props.tab === tabStr ? { display: 'block' } : { display: 'none' }
}

installed() {
this.tdDocTabs.current.onchange = ({ detail: currentTab }) => {
this.updateTab(currentTab)
}
}

render() {
return (
<>
<td-doc-tabs ref={this.tdDocTabs} tab={this.props.tab} style="display:block"></td-doc-tabs>
<div style={this.isShow('demo')} name="DEMO">
<h3 id="Icon图标">
Icon图标 <a class="header-anchor" href="#Icon图标"></a>
</h3>
<h4 id="按需引入图标">
按需引入图标 <a class="header-anchor" href="#按需引入图标"></a>
</h4>
<code-box
title="按需引入图标"
describe={`可以通过
import { StarFilledIcon} from '../../../../../src/icon/index'或者
import '../../../../../src/icon/bookmark'
的方式按需引入图标`}
code={`
\`\`\`html
import {
StarFilledIcon,
ActivityIcon,
AddAndSubtractIcon,
AddCircleIcon,
AddRectangleIcon,
AddIcon,
AddressBookIcon,
} from '../../../../../src/icon/index'
import '../../../../../src/icon/bookmark'
<div>
<t-space>
<ActivityIcon />
<AddAndSubtractIcon />
<AddCircleIcon />
<AddRectangleIcon />
<AddIcon />
<AddressBookIcon />
<t-icon-bookmark/>
</t-space>
</div>
\`\`\`
`}
>
<div slot="demo" class={tw`px-5 py-5`}>
<t-space>
<ActivityIcon />
<AddAndSubtractIcon />
<AddCircleIcon />
<AddRectangleIcon />
<AddIcon />
<AddressBookIcon />
<t-icon-bookmark />
</t-space>
</div>
</code-box>
<h4 id="样式自定义">
样式自定义 <a class="header-anchor" href="#样式自定义"></a>
</h4>
<code-box
title="样式自定义"
describe={`图标尺寸单位支持多种, 'small', 'medium', 'large', '35px', '3em' 等。 图标颜色使用 CSS 控制,如:
style={{color: "red"}} 或者 style={{fill: "red"}}`}
code={`
\`\`\`html
import { StarFilledIcon } from '../../../../../src/icon/index'
<div>
<t-space direction="vertical">
<h4>Size: small | medium | large | 1.5em | 2em | 40px</h4>
<t-space align="center">
<StarFilledIcon size="small"></StarFilledIcon>
<StarFilledIcon size="medium"></StarFilledIcon>
<StarFilledIcon size="large"></StarFilledIcon>
<StarFilledIcon size="1.5em"></StarFilledIcon>
<StarFilledIcon size="2em"></StarFilledIcon>
<StarFilledIcon size="40px"></StarFilledIcon>
</t-space>
<h4>Color</h4>
<t-space align="center">
<StarFilledIcon></StarFilledIcon>
<StarFilledIcon style={{ color: '#0d5bdb' }}></StarFilledIcon>
<StarFilledIcon style={{ color: '#d54941' }}></StarFilledIcon>
<StarFilledIcon style={{ color: '#e47922' }}></StarFilledIcon>
<StarFilledIcon style={{ color: '#2ba471' }}></StarFilledIcon>
</t-space>
</t-space>
</div>
\`\`\`
`}
>
<div slot="demo" class={tw`px-5 py-5`}>
<t-space direction="vertical">
<h4>Size: small | medium | large | 1.5em | 2em | 40px</h4>
<t-space align="center">
<StarFilledIcon size="small"></StarFilledIcon>
<StarFilledIcon size="medium"></StarFilledIcon>
<StarFilledIcon size="large"></StarFilledIcon>
<StarFilledIcon size="1.5em"></StarFilledIcon>
<StarFilledIcon size="2em"></StarFilledIcon>
<StarFilledIcon size="40px"></StarFilledIcon>
</t-space>
<h4>Color</h4>
<t-space align="center">
<StarFilledIcon></StarFilledIcon>
<StarFilledIcon style={{ color: '#0d5bdb' }}></StarFilledIcon>
<StarFilledIcon style={{ color: '#d54941' }}></StarFilledIcon>
<StarFilledIcon style={{ color: '#e47922' }}></StarFilledIcon>
<StarFilledIcon style={{ color: '#2ba471' }}></StarFilledIcon>
</t-space>
</t-space>
</div>
</code-box>
</div>
<div style={this.isShow('api')} name="API">
<div
style="margin-bottom:76px"
unsafeHTML={{
html: docsHTML,
}}
></div>
</div>
<div style={this.isShow('design')} name="DESIGN"></div>
</>
)
}
},
)
9 changes: 8 additions & 1 deletion tdesign/desktop/site/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function registerRouting(rootEl: any) {
rootEl.data.tagName = 'page-rate'
rootEl.update()
})
})
})

route('/comment', () => {
import('./components/web/comment/index').then(() => {
Expand All @@ -131,6 +131,13 @@ export function registerRouting(rootEl: any) {
})
})

route('/icon', () => {
import('./components/web/icon/index').then(() => {
rootEl.data.tagName = 'page-icon'
rootEl.update()
})
})

route('*', function () {
console.log('not found')
})
Expand Down
1 change: 0 additions & 1 deletion tdesign/desktop/src/icon/_example/base.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { h, tag, WeElement } from 'omi'

// import '../t-icon-star-filled'
import '../index'
import '../../space/index'
@tag('icon-base')
Expand Down
Loading

0 comments on commit 135f1cc

Please sign in to comment.