ant-design-vue/site/theme/template/IconDisplay/index.jsx

178 lines
3.7 KiB
Vue
Raw Normal View History

2019-01-12 03:33:27 +00:00
import manifest from '@ant-design/icons/lib/manifest';
import Category from './Category';
import { FilledIcon, OutlinedIcon, TwoToneIcon } from './themeIcons';
import { categories } from './fields';
2018-11-27 10:25:38 +00:00
const IconDisplay = {
cagetories: categories,
newIconNames: [
// direction
2019-01-12 03:33:27 +00:00
'border-bottom',
'border-horizontal',
'border-inner',
'border-outter',
'border-left',
'border-right',
'border-top',
'border-verticle',
'pic-center',
'pic-left',
'pic-right',
'radius-bottomleft',
'radius-bottomright',
'radius-upleft',
'radius-upleft',
'fullscreen',
'fullscreen-exit',
2018-11-27 10:25:38 +00:00
// suggestion
2019-01-12 03:33:27 +00:00
'issues-close',
'stop',
2018-11-27 10:25:38 +00:00
// edit
2019-01-12 03:33:27 +00:00
'scissor',
'snippets',
'diff',
'highlight',
'align-center',
'align-left',
'align-right',
'bg-colors',
'bold',
'italic',
'underline',
'redo',
'undo',
'zoom-in',
'zoom-out',
'font-colors',
'font-size',
'line-height',
'colum-height',
'colum-width',
'dash',
'small-dash',
'sort-ascending',
'sort-descending',
'drag',
'ordered-list',
'radius-setting',
2018-11-27 10:25:38 +00:00
// data
2019-01-12 03:33:27 +00:00
'radar-chart',
'heat-map',
'fall',
'rise',
'stock',
'box-plot',
'fund',
2018-11-27 10:25:38 +00:00
'sliders',
// other
2019-01-12 03:33:27 +00:00
'alert',
'audit',
'batch-folding',
'branches',
'build',
'border',
'crown',
'experiment',
'fire',
'money-collect',
'property-safety',
'read',
'reconciliation',
'rest',
'security-scan',
'insurance',
'interation',
'safety-certificate',
'project',
'thunderbolt',
'block',
'cluster',
'deployment-unit',
'dollar',
'euro',
'pound',
'file-done',
'file-exclamation',
'file-protect',
'file-search',
'file-sync',
'gateway',
'gold',
'robot',
'strikethrough',
'shopping',
2018-11-27 10:25:38 +00:00
// logo
2019-01-12 03:33:27 +00:00
'alibaba',
'yahoo',
2018-11-27 10:25:38 +00:00
],
themeTypeMapper: {
filled: 'fill',
outlined: 'outline',
twoTone: 'twotone',
},
2019-01-12 03:33:27 +00:00
data() {
2018-11-27 10:25:38 +00:00
return {
theme: 'outlined',
2019-01-12 03:33:27 +00:00
};
2018-11-27 10:25:38 +00:00
},
methods: {
2019-01-12 03:33:27 +00:00
getComputedDisplayList() {
2018-11-27 10:25:38 +00:00
return Object.keys(IconDisplay.cagetories)
2019-01-12 03:33:27 +00:00
.map(category => ({
category,
icons: IconDisplay.cagetories[category].filter(
name => manifest[IconDisplay.themeTypeMapper[this.theme]].indexOf(name) !== -1,
),
}))
.filter(({ icons }) => Boolean(icons.length));
2018-11-27 10:25:38 +00:00
},
2019-01-12 03:33:27 +00:00
handleChangeTheme(e) {
this.theme = e.target.value;
2018-11-27 10:25:38 +00:00
},
2019-01-12 03:33:27 +00:00
renderCategories(list) {
2018-11-27 10:25:38 +00:00
return list.map(({ category, icons }) => {
return (
<Category
key={category}
title={category}
icons={icons}
theme={this.theme}
newIcons={IconDisplay.newIconNames}
/>
2019-01-12 03:33:27 +00:00
);
});
2018-11-27 10:25:38 +00:00
},
},
2019-01-12 03:33:27 +00:00
render() {
const list = this.getComputedDisplayList();
const message = this.$t('message');
2018-11-27 10:25:38 +00:00
return (
<div>
<h3>{message['app.docs.components.icon.pick-theme']}</h3>
<a-radio-group value={this.theme} onChange={this.handleChangeTheme}>
2019-01-12 03:33:27 +00:00
<a-radio-button value="outlined">
2018-11-27 10:25:38 +00:00
<a-icon component={OutlinedIcon} /> {message['app.docs.components.icon.outlined']}
</a-radio-button>
2019-01-12 03:33:27 +00:00
<a-radio-button value="filled">
2018-11-27 10:25:38 +00:00
<a-icon component={FilledIcon} /> {message['app.docs.components.icon.filled']}
</a-radio-button>
2019-01-12 03:33:27 +00:00
<a-radio-button value="twoTone">
2018-11-27 10:25:38 +00:00
<a-icon component={TwoToneIcon} /> {message['app.docs.components.icon.two-tone']}
</a-radio-button>
</a-radio-group>
{this.renderCategories(list)}
</div>
2019-01-12 03:33:27 +00:00
);
2018-11-27 10:25:38 +00:00
},
2019-01-12 03:33:27 +00:00
};
2018-11-27 10:25:38 +00:00
2019-01-12 03:33:27 +00:00
export default IconDisplay;