Skip to content

Commit d35dc61

Browse files
authored
Merge pull request #242 from opentiny/lhs/materials-icon
feat(materials): move icons from renderer to materials
2 parents fd733d1 + 1518c20 commit d35dc61

13 files changed

Lines changed: 253 additions & 133 deletions

File tree

packages/materials/vue-element-plus/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
},
4141
"peerDependencies": {
4242
"element-plus": "^2.9.0",
43+
"@element-plus/icons-vue": "^2.3.1",
4344
"vue": "^3.5.13"
4445
},
4546
"devDependencies": {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script setup lang="ts">
2+
import { computed, type Component } from 'vue';
3+
import * as Icons from '@element-plus/icons-vue';
4+
5+
const props = withDefaults(
6+
defineProps<{
7+
name: string;
8+
}>(),
9+
{
10+
name: '',
11+
},
12+
);
13+
14+
const iconComponent = computed(() => {
15+
const cmp = (Icons as Record<string, Component | unknown>)[props.name];
16+
return cmp || null;
17+
});
18+
</script>
19+
20+
<template>
21+
<component :is="iconComponent" v-if="iconComponent" />
22+
</template>

packages/materials/vue-element-plus/src/materials/components/components.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ import {
2121
ElTabs,
2222
ElTabPane,
2323
} from 'element-plus';
24+
import ElIconSvg from './ElIconSvg.vue';
2425

2526
export interface IComponents {
2627
[key: string]: Component;
2728
}
2829

2930
export const components: IComponents = {
31+
ElIconSvg,
3032
ElInput,
3133
ElDatePicker,
3234
ElButton,

packages/materials/vue-element-plus/src/meta/materials/bundle.json

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,28 @@
10731073
"props": {}
10741074
},
10751075
"device": []
1076+
},
1077+
{
1078+
"property": "icon",
1079+
"label": {
1080+
"text": {
1081+
"zh_CN": "图标"
1082+
}
1083+
},
1084+
"description": {
1085+
"zh_CN": "按钮图标,必须使用 JSSlot 包裹 ElIconSvg。正确示例:{\"type\":\"JSSlot\",\"value\":[{\"componentName\":\"ElIconSvg\",\"props\":{\"name\":\"Search\"}}]}。禁止直接传组件对象或使用 JSExpression。"
1086+
},
1087+
"required": false,
1088+
"readOnly": false,
1089+
"disabled": false,
1090+
"cols": 12,
1091+
"labelPosition": "left",
1092+
"type": "object",
1093+
"widget": {
1094+
"component": "CodeConfigurator",
1095+
"props": {}
1096+
},
1097+
"device": []
10761098
}
10771099
],
10781100
"description": {
@@ -1101,6 +1123,95 @@
11011123
}
11021124
}
11031125
},
1126+
{
1127+
"name": {
1128+
"zh_CN": "ElIconSvg"
1129+
},
1130+
"component": "ElIconSvg",
1131+
"icon": "icon",
1132+
"description": "图标组件。可作独立节点:{\"componentName\":\"ElIconSvg\",\"props\":{\"name\":\"Search\"}}。作为 ElButton 的 icon 属性时必须使用 JSSlot:{\"icon\":{\"type\":\"JSSlot\",\"value\":[{\"componentName\":\"ElIconSvg\",\"props\":{\"name\":\"Search\"}}]}}",
1133+
"doc_url": "https://element-plus.org/zh-CN/component/icon",
1134+
"screenshot": "",
1135+
"tags": "icon,图标",
1136+
"keywords": "icon,图标",
1137+
"dev_mode": "proCode",
1138+
"group": "基础组件",
1139+
"category": "element-plus",
1140+
"configure": {
1141+
"loop": true,
1142+
"condition": true,
1143+
"styles": true,
1144+
"isContainer": false,
1145+
"isModal": false,
1146+
"isPopper": false,
1147+
"nestingRule": {
1148+
"childWhitelist": "",
1149+
"parentWhitelist": "",
1150+
"descendantBlacklist": "",
1151+
"ancestorWhitelist": ""
1152+
},
1153+
"isNullNode": false,
1154+
"isLayout": false,
1155+
"rootSelector": "",
1156+
"shortcuts": {
1157+
"properties": [
1158+
"name"
1159+
]
1160+
},
1161+
"contextMenu": {
1162+
"actions": [
1163+
"copy",
1164+
"remove",
1165+
"insert",
1166+
"updateAttr",
1167+
"bindEvent",
1168+
"createBlock"
1169+
],
1170+
"disable": []
1171+
},
1172+
"invalidity": [
1173+
""
1174+
],
1175+
"clickCapture": true,
1176+
"framework": "Vue"
1177+
},
1178+
"schema": {
1179+
"properties": [
1180+
{
1181+
"name": "0",
1182+
"label": {
1183+
"zh_CN": "基础属性"
1184+
},
1185+
"content": [
1186+
{
1187+
"property": "name",
1188+
"label": {
1189+
"text": {
1190+
"zh_CN": "图标名称"
1191+
}
1192+
},
1193+
"description": {
1194+
"zh_CN": "图标名称,仅允许优先使用以下精选(亦可使用 @element-plus/icons-vue 其它导出名):Search(搜索)、Edit(编辑)、EditPen(钢笔编辑)、Delete(删除)、DeleteFilled(实心删除)、Plus(加号)、Minus(减号)、CirclePlus(圆圈加号)、Close(关闭)、CircleClose(圆圈关闭)、CloseBold(粗关闭)、Check(勾选)、CircleCheck(圆圈勾选)、Finished(完成)、Warning(警告)、InfoFilled(信息)、QuestionFilled(问号)、WarnTriangleFilled(三角警告)、SuccessFilled(成功实心)、WarningFilled(警告实心)、CircleCheckFilled(完成实心)、User(用户)、UserFilled(实心用户)、Avatar(头像)、Setting(设置)、Tools(工具)、House(房屋)、HomeFilled(实心首页)、Loading(加载旋转)、Link(链接)、Star(空心星)、StarFilled(实心星)、View(可见)、Hide(隐藏)、Unlock(解锁)、Lock(锁定)、Refresh(刷新)、RefreshLeft(左旋刷新)、RefreshRight(右旋刷新)、Filter(筛选)、More(更多)、MoreFilled(实心更多)、Share(分享)、Message(消息)、Comment(评论)、Bell(铃铛)、Notification(通知)、Menu(菜单)、UploadFilled(上传实心)、Operation(操作)、Remove(移除)、ZoomIn(放大)、ZoomOut(缩小)、ArrowLeft(向左箭头)、ArrowRight(向右箭头)、ArrowUp(向上箭头)、ArrowDown(向下箭头)、Download(下载)、Upload(上传)、Sort(排序)、SortUp(升序)、SortDown(降序)、Expand(展开)、Fold(收起)、Back(返回)、Right(右)、Top(上)、Bottom(下)、Document(文档)、DocumentCopy(拷贝文档)、DocumentAdd(新增文档)、DocumentDelete(删除文档)、Folder(文件夹)、FolderOpened(打开文件夹)、FolderAdd(新建文件夹)、CopyDocument(复制文档)、Calendar(日历)、Clock(时钟)、Picture(图片)、Paperclip(回形针附件)、Printer(打印)、Location(定位)"
1195+
},
1196+
"required": true,
1197+
"readOnly": false,
1198+
"disabled": false,
1199+
"cols": 12,
1200+
"labelPosition": "left",
1201+
"type": "string",
1202+
"widget": {
1203+
"component": "SelectIconConfigurator",
1204+
"props": {}
1205+
}
1206+
}
1207+
],
1208+
"description": {
1209+
"zh_CN": ""
1210+
}
1211+
}
1212+
]
1213+
}
1214+
},
11041215
{
11051216
"id": 1,
11061217
"version": "2.4.2",

packages/materials/vue-element-plus/src/meta/white-list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const whiteList = [
2+
'ElIconSvg',
23
'ElInput',
34
'ElDatePicker',
45
'ElButton',
@@ -35,6 +36,5 @@ export const whiteList = [
3536
'Slot',
3637
'Template',
3738
'Text',
38-
'Icon',
3939
'Img',
4040
];

packages/materials/vue-opentiny-vue/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@opentiny/vue-form": "~3.28.0",
6060
"@opentiny/vue-form-item": "~3.28.0",
6161
"@opentiny/vue-grid": "~3.28.0",
62+
"@opentiny/vue-icon": "~3.28.0",
6263
"@opentiny/vue-input": "~3.28.0",
6364
"@opentiny/vue-layout": "~3.28.0",
6465
"@opentiny/vue-numeric": "~3.28.0",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script setup lang="ts">
2+
import { computed, type Component } from 'vue';
3+
import * as SvgIcons from '@opentiny/vue-icon';
4+
5+
const props = withDefaults(
6+
defineProps<{
7+
name: string;
8+
}>(),
9+
{
10+
name: '',
11+
},
12+
);
13+
14+
const iconComponent = computed(() => {
15+
const factory = (SvgIcons as Record<string, (() => Component) | unknown>)[props.name];
16+
return typeof factory === 'function' ? factory() : null;
17+
});
18+
</script>
19+
20+
<template>
21+
<component :is="iconComponent" v-if="iconComponent" />
22+
</template>

packages/materials/vue-opentiny-vue/src/materials/components/components.ts

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,49 +37,51 @@ import TinyTransfer from '@opentiny/vue-transfer';
3737
import TinyTree from '@opentiny/vue-tree';
3838
import TinySelect from '@opentiny/vue-select';
3939

40-
import TinyTabsWrap from './TinyTabsWrap.vue';
40+
import TinyTabs from './TinyTabsWrap.vue';
41+
import TinyIcon from './TinyIcon.vue';
4142

4243
export interface IComponents {
4344
[key: string]: Component;
4445
}
4546

4647
export const components: IComponents = {
47-
TinyCarouselItem: TinyCarouselItem,
48-
TinyCarousel: TinyCarousel,
49-
TinyRow: TinyRow,
50-
TinyLayout: TinyLayout,
51-
TinyForm: TinyForm,
52-
TinyFormItem: TinyFormItem,
53-
TinyCol: TinyCol,
54-
TinyButton: TinyButton,
55-
TinyInput: TinyInput,
56-
TinyRadio: TinyRadio,
57-
TinyRadioGroup: TinyRadioGroup,
58-
TinySwitch: TinySwitch,
59-
TinySearch: TinySearch,
60-
TinyCheckbox: TinyCheckbox,
61-
TinyCheckboxButton: TinyCheckboxButton,
62-
TinyCheckboxGroup: TinyCheckboxGroup,
63-
TinyTabItem: TinyTabItem,
64-
TinyGrid: TinyGrid,
65-
TinyCard: TinyCard,
66-
TinyTree: TinyTree,
67-
TinyDatePicker: TinyDatePicker,
68-
TinyNumeric: TinyNumeric,
69-
TinyPager: TinyPager,
70-
TinyTransfer: TinyTransfer,
71-
TinyHuichartsLine: TinyHuichartsLine,
72-
TinyHuichartsHistogram: TinyHuichartsHistogram,
73-
TinyHuichartsBar: TinyHuichartsBar,
74-
TinyHuichartsRadar: TinyHuichartsRadar,
75-
TinyHuichartsRing: TinyHuichartsRing,
76-
TinyHuichartsPie: TinyHuichartsPie,
77-
TinyHuichartsFunnel: TinyHuichartsFunnel,
78-
TinyHuichartsScatter: TinyHuichartsScatter,
79-
TinyHuichartsWaterfall: TinyHuichartsWaterfall,
80-
TinyHuichartsGauge: TinyHuichartsGauge,
81-
TinyHuichartsGraph: TinyHuichartsGraph,
82-
TinyHuichartsProcess: TinyHuichartsProcess,
83-
TinyTabs: TinyTabsWrap,
84-
TinySelect: TinySelect,
48+
TinyIcon,
49+
TinyCarouselItem,
50+
TinyCarousel,
51+
TinyRow,
52+
TinyLayout,
53+
TinyForm,
54+
TinyFormItem,
55+
TinyCol,
56+
TinyButton,
57+
TinyInput,
58+
TinyRadio,
59+
TinyRadioGroup,
60+
TinySwitch,
61+
TinySearch,
62+
TinyCheckbox,
63+
TinyCheckboxButton,
64+
TinyCheckboxGroup,
65+
TinyTabItem,
66+
TinyGrid,
67+
TinyCard,
68+
TinyTree,
69+
TinyDatePicker,
70+
TinyNumeric,
71+
TinyPager,
72+
TinyTransfer,
73+
TinyHuichartsLine,
74+
TinyHuichartsHistogram,
75+
TinyHuichartsBar,
76+
TinyHuichartsRadar,
77+
TinyHuichartsRing,
78+
TinyHuichartsPie,
79+
TinyHuichartsFunnel,
80+
TinyHuichartsScatter,
81+
TinyHuichartsWaterfall,
82+
TinyHuichartsGauge,
83+
TinyHuichartsGraph,
84+
TinyHuichartsProcess,
85+
TinyTabs,
86+
TinySelect,
8587
};

0 commit comments

Comments
 (0)