update icons logic (#16623)

This commit is contained in:
zombieJ 2019-05-16 17:47:50 +08:00 committed by GitHub
parent e0fae5dacf
commit c39ca23b7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 384 deletions

View File

@ -1,370 +1,12 @@
import manifest from '@ant-design/icons/lib/manifest';
let allIcons: string[] = [];
Object.keys(manifest).forEach(theme => {
allIcons = [...allIcons, ...(manifest as any)[theme]];
});
export const categories = {
all: [
'underline',
'small-dash',
'caret-down',
'medium',
'search',
'vertical-align-middle',
'like',
'pause-circle',
'pic-left',
'check-square',
'file-search',
'arrow-down',
'switcher',
'rollback',
'money-collect',
'bulb',
'vertical-left',
'file-unknown',
'appstore',
'file-excel',
'sound',
'unordered-list',
'left-circle',
'play-circle',
'file-zip',
'border-outer',
'medium-workmark',
'dropbox',
'hourglass',
'sort-descending',
'swap-left',
'safety',
'menu-unfold',
'user',
'highlight',
'fullscreen',
'reconciliation',
'issues-close',
'android',
'dollar',
'colum-height',
'pull-request',
'home',
'shop',
'copyright',
'alert',
'gitlab',
'disconnect',
'column-width',
'sliders',
'ant-design',
'weibo',
'fullscreen-exit',
'logout',
'strikethrough',
'shopping',
'file-word',
'funnel-plot',
'github',
'vertical-right',
'usb',
'export',
'down',
'shrink',
'usergroup-add',
'tag',
'up-square',
'down-square',
'file-add',
'fall',
'inbox',
'audit',
'plus-square',
'stock',
'drag',
'database',
'file',
'account-book',
'control',
'red-envelope',
'radius-bottomright',
'radius-bottomleft',
'box-plot',
'file-text',
'folder-open',
'build',
'font-size',
'apartment',
'behance-square',
'bar-chart',
'up',
'question-circle',
'question',
'lock',
'cloud-upload',
'fire',
'weibo-circle',
'dislike',
'usergroup-delete',
'instagram',
'euro',
'link',
'idcard',
'key',
'meh',
'arrow-right',
'percentage',
'qrcode',
'number',
'ci',
'diff',
'minus-square',
'border-inner',
'paper-clip',
'caret-up',
'close-circle',
'pic-center',
'mail',
'desktop',
'download',
'import',
'radar-chart',
'area-chart',
'pound',
'file-done',
'user-delete',
'aliyun',
'login',
'book',
'scissor',
'wallet',
'file-image',
'bell',
'coffee',
'dashboard',
'code',
'poweroff',
'heat-map',
'alipay-circle',
'aliwangwang',
'carry-out',
'transaction',
'double-left',
'flag',
'snippets',
'stop',
'right-circle',
'step-forward',
'cluster',
'container',
'slack-square',
'frown',
'tool',
'safety-certificate',
'dribbble-square',
'rise',
'file-sync',
'border',
'caret-right',
'bold',
'trophy',
'share-alt',
'plus',
'check',
'dash',
'warning',
'trademark',
'global',
'pie-chart',
'radius-upright',
'security-scan',
'wifi',
'line-height',
'team',
'info',
'user-add',
'close',
'border-verticle',
'info-circle',
'dingding',
'eye-invisible',
'cloud-sync',
'left-square',
'copy',
'gold',
'ant-cloud',
'zoom-in',
'fund',
'reload',
'play-square',
'border-right',
'file-exclamation',
'codepen-circle',
'fast-backward',
'align-right',
'environment',
'check-circle',
'html5',
'save',
'smile',
'scan',
'fork',
'right',
'file-protect',
'setting',
'solution',
'loading',
'fast-forward',
'message',
'zoom-out',
'crown',
'backward',
'yuque',
'notification',
'picture',
'exception',
'table',
'barcode',
'taobao-circle',
'facebook',
'camera',
'printer',
'amazon',
'file-jpg',
'border-top',
'redo',
'pay-circle',
'wechat',
'swap-right',
'google',
'more',
'line',
'up-circle',
'exclamation-circle',
'branches',
'radius-setting',
'deployment-unit',
'down-circle',
'step-backward',
'rest',
'contacts',
'form',
'star',
'ordered-list',
'experiment',
'edit',
'api',
'windows',
'youtube',
'unlock',
'to-top',
'border-left',
'compass',
'alibaba',
'plus-circle',
'menu-fold',
'woman',
'bank',
'credit-card',
'file-markdown',
'vertical-align-bottom',
'gateway',
'select',
'yahoo',
'loading-3-quarters',
'sketch',
'audio',
'delete',
'reddit',
'alipay',
'pic-right',
'retweet',
'skin',
'phone',
'sync',
'eye',
'mobile',
'insurance',
'codepen',
'dribbble',
'gift',
'line-chart',
'car',
'weibo-square',
'thunderbolt',
'profile',
'tags',
'border-bottom',
'arrow-up',
'google-plus',
'folder-add',
'schedule',
'linkedin',
'qq',
'shake',
'undo',
'robot',
'twitter',
'filter',
'italic',
'calendar',
'video-camera',
'arrow-left',
'align-center',
'ellipsis',
'minus-circle',
'border-horizontal',
'laptop',
'dot-chart',
'caret-left',
'font-colors',
'close-square',
'slack',
'zhihu',
'cloud',
'ie',
'read',
'bars',
'vertical-align-top',
'upload',
'pause',
'double-right',
'property-safety',
'forward',
'code-sandbox',
'interation',
'right-square',
'skype',
'rocket',
'tablet',
'enter',
'cloud-download',
'menu',
'pushpin',
'hdd',
'chrome',
'shopping-cart',
'sort-ascending',
'calculator',
'apple',
'block',
'man',
'medicine-box',
'project',
'history',
'folder',
'arrows-alt',
'taobao',
'file-ppt',
'bg-colors',
'left',
'file-pdf',
'monitor',
'minus',
'exclamation',
'swap',
'behance',
'customer-service',
'radius-upleft',
'cloud-server',
'layout',
'clock-circle',
'align-left',
'heart',
],
all: [...new Set(allIcons)],
direction: [
'step-backward',
'step-forward',

View File

@ -63,28 +63,32 @@ class IconDisplay extends React.Component<IconDisplayProps, IconDisplayState> {
};
renderCategories(list: Array<{ category: CategoriesKeys; icons: string[] }>) {
const { searchKey } = this.state;
const { searchKey, theme } = this.state;
const otherIcons = categories.all.filter(icon => {
return list.filter(({ category }) => category !== 'all').every(item => !item.icons.includes(icon));
return list
.filter(({ category }) => category !== 'all')
.every(item => !item.icons.includes(icon));
});
return list
.filter(({ category }) => category !== 'all')
.concat({ category: 'other', icons: otherIcons })
.map(({ category, icons }) => ({
category,
icons: icons.filter(name => name.includes(searchKey)),
}))
.filter(({ icons }) => !!icons.length)
.map(({ category, icons }) => (
<Category
key={category}
title={category}
icons={icons}
theme={this.state.theme}
newIcons={IconDisplay.newIconNames}
/>
));
.filter(({ category }) => category !== 'all')
.concat({ category: 'other', icons: otherIcons })
.map(({ category, icons }) => ({
category,
icons: icons
.filter(name => name.includes(searchKey))
.filter(name => manifest[IconDisplay.themeTypeMapper[theme]].includes(name)),
}))
.filter(({ icons }) => !!icons.length)
.map(({ category, icons }) => (
<Category
key={category}
title={category}
icons={icons}
theme={this.state.theme}
newIcons={IconDisplay.newIconNames}
/>
));
}
render() {