Skip to content

Commit 1e2c947

Browse files
authored
feat(icon): a few new icons (#94)
* feat(icon): a few new icons
1 parent 39ab827 commit 1e2c947

File tree

10 files changed

+164
-1
lines changed

10 files changed

+164
-1
lines changed

__tests__/icon.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ import { VntIcon } from '@/components';
33
import { isInstalled } from './utils';
44
import { resolveIcon } from '@/components/icon/Icon.vue';
55

6+
import VntIconAdd from '@/components/icon/icons/Add.vue';
7+
import VntIconClose from '@/components/icon/icons/Close.vue';
68
import VntIconContact from '@/components/icon/icons/Contact.vue';
9+
import VntIconDelete from '@/components/icon/icons/Delete.vue';
710
import VntIconEdit from '@/components/icon/icons/Edit.vue';
11+
import VntIconFlag from '@/components/icon/icons/Flag.vue';
812
import VntIconGlobalNav from '@/components/icon/icons/GlobalNavigation.vue';
13+
import VntIconHome from '@/components/icon/icons/Home.vue';
914
import VntIconSettings from '@/components/icon/icons/Settings.vue';
1015
import VntIconSave from '@/components/icon/icons/Save.vue';
16+
import VntIconTag from '@/components/icon/icons/Tag.vue';
1117

1218
describe('Icon', () => {
1319
let wrapper;
@@ -42,12 +48,18 @@ describe('Icon', () => {
4248
});
4349

4450
test('uses correct component', () => {
51+
expect(resolveIcon('add').name).toBe(VntIconAdd.name);
52+
expect(resolveIcon('close').name).toBe(VntIconClose.name);
4553
expect(resolveIcon('contact').name).toBe(VntIconContact.name);
54+
expect(resolveIcon('delete').name).toBe(VntIconDelete.name);
4655
expect(resolveIcon('edit').name).toBe(VntIconEdit.name);
56+
expect(resolveIcon('flag').name).toBe(VntIconFlag.name);
4757
expect(resolveIcon('global-navigation').name).toBe(VntIconGlobalNav.name);
4858
expect(resolveIcon('global-nav').name).toBe(VntIconGlobalNav.name);
59+
expect(resolveIcon('home').name).toBe(VntIconHome.name);
4960
expect(resolveIcon('save').name).toBe(VntIconSave.name);
5061
expect(resolveIcon('settings').name).toBe(VntIconSettings.name);
62+
expect(resolveIcon('tag').name).toBe(VntIconTag.name);
5163
expect(resolveIcon('some-non-existing-icon')).toBeNull();
5264
});
5365

docs/components/icon.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ Currently supported glyphs:
1616

1717
`name` | icon
1818
--- |:---:
19+
add | <icon-basic name="add" />
20+
close | <icon-basic name="close" />
1921
contact | <icon-basic name="contact" />
22+
delete | <icon-basic name="delete" />
2023
edit | <icon-basic name="edit" />
24+
flag | <icon-basic name="flag" />
2125
global-navigation | <icon-basic name="global-navigation" />
26+
home | <icon-basic name="home" />
2227
save | <icon-basic name="save" />
2328
settings | <icon-basic name="settings" />
29+
tag | <icon-basic name="tag" />

src/components/icon/Icon.vue

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
11
<script>
2+
import VntIconAdd from './icons/Add.vue';
3+
import VntIconClose from './icons/Close.vue';
24
import VntIconContact from './icons/Contact.vue';
5+
import VntIconDelete from './icons/Delete.vue';
36
import VntIconEdit from './icons/Edit.vue';
7+
import VntIconFlag from './icons/Flag.vue';
48
import VntIconGlobalNav from './icons/GlobalNavigation.vue';
9+
import VntIconHome from './icons/Home.vue';
510
import VntIconSave from './icons/Save.vue';
611
import VntIconSettings from './icons/Settings.vue';
12+
import VntIconTag from './icons/Tag.vue';
713
814
export function resolveIcon(name) {
915
switch (name) {
16+
case 'add':
17+
return VntIconAdd;
18+
case 'close':
19+
return VntIconClose;
1020
case 'contact':
1121
return VntIconContact;
22+
case 'delete':
23+
return VntIconDelete;
1224
case 'edit':
1325
return VntIconEdit;
26+
case 'flag':
27+
return VntIconFlag;
1428
case 'global-nav':
1529
case 'global-navigation':
1630
return VntIconGlobalNav;
31+
case 'home':
32+
return VntIconHome;
1733
case 'save':
1834
return VntIconSave;
1935
case 'settings':
2036
return VntIconSettings;
37+
case 'tag':
38+
return VntIconTag;
2139
default:
2240
return null;
2341
}
@@ -29,11 +47,17 @@ export default {
2947
functional: true,
3048
3149
components: {
50+
VntIconAdd,
51+
VntIconClose,
3252
VntIconContact,
53+
VntIconDelete,
3354
VntIconEdit,
55+
VntIconFlag,
3456
VntIconGlobalNav,
57+
VntIconHome,
3558
VntIconSave,
36-
VntIconSettings
59+
VntIconSettings,
60+
VntIconTag
3761
},
3862
3963
props: {

src/components/icon/icons/Add.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<template functional>
2+
<svg xmlns="http://www.w3.org/2000/svg"
3+
width="16"
4+
height="16"
5+
viewBox="0 0 16 16">
6+
<path d="M16-8.5v1H8.5V0h-1V-7.5H0v-1H7.5V-16h1v7.5Z"
7+
transform="translate(0 16)" />
8+
</svg>
9+
</template>
10+
11+
<script>
12+
export default {
13+
name: 'VntIconAdd'
14+
};
15+
</script>
16+

src/components/icon/icons/Close.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template functional>
2+
<svg xmlns="http://www.w3.org/2000/svg"
3+
width="13"
4+
height="13"
5+
viewBox="0 0 13 13">
6+
<path d="M9.156-7.6,14.9-1.851l-.749.749L8.4-6.844,2.647-1.1,1.9-1.851,7.641-7.6,1.9-13.353l.749-.749L8.4-8.359,14.149-14.1l.749.749Z"
7+
transform="translate(-1.898 14.102)" />
8+
</svg>
9+
</template>
10+
11+
<script>
12+
export default {
13+
name: 'VntIconClose'
14+
};
15+
</script>

src/components/icon/icons/Delete.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template functional>
2+
<svg xmlns="http://www.w3.org/2000/svg"
3+
width="13"
4+
height="16"
5+
viewBox="0 0 13 16">
6+
<path d="M14-13H13V-1.5a1.472,1.472,0,0,1-.117.586,1.5,1.5,0,0,1-.32.477,1.5,1.5,0,0,1-.477.32A1.472,1.472,0,0,1,11.5,0h-8a1.472,1.472,0,0,1-.586-.117,1.5,1.5,0,0,1-.477-.32,1.5,1.5,0,0,1-.32-.477A1.472,1.472,0,0,1,2-1.5V-13H1v-1H5v-1a.969.969,0,0,1,.078-.391,1.016,1.016,0,0,1,.215-.316,1.016,1.016,0,0,1,.316-.215A.969.969,0,0,1,6-16H9a.969.969,0,0,1,.391.078,1.016,1.016,0,0,1,.316.215,1.016,1.016,0,0,1,.215.316A.969.969,0,0,1,10-15v1h4ZM6-14H9v-1H6Zm6,1H3V-1.5a.481.481,0,0,0,.148.352A.481.481,0,0,0,3.5-1h8a.481.481,0,0,0,.352-.148A.481.481,0,0,0,12-1.5ZM6-3H5v-8H6ZM8-3H7v-8H8Zm2,0H9v-8h1Z"
7+
transform="translate(-1 16)" />
8+
</svg>
9+
</template>
10+
11+
<script>
12+
export default {
13+
name: 'VntIconDelete'
14+
};
15+
</script>

src/components/icon/icons/Flag.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template functional>
2+
<svg xmlns="http://www.w3.org/2000/svg"
3+
width="13"
4+
height="16"
5+
viewBox="0 0 13 16">
6+
<path d="M15-14v8H8V-8H3V0H2V-16H9v2ZM8-9v-6H3v6Zm6-4H9v6h5Z"
7+
transform="translate(-2 16)" />
8+
</svg>
9+
</template>
10+
11+
<script>
12+
export default {
13+
name: 'VntIconFlag'
14+
};
15+
</script>

src/components/icon/icons/Home.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template functional>
2+
<svg xmlns="http://www.w3.org/2000/svg"
3+
width="16"
4+
height="14.92"
5+
viewBox="0 0 16 14.92">
6+
<path d="M8.811-18.389l8,8.009-.765.765-.706-.7v6.844H9.9V-8.909H7.722v5.441H2.281v-6.844l-.706.7L.811-10.38ZM14.252-4.557V-11.4L8.811-16.841,3.37-11.4v6.844H6.634V-10h4.353v5.441Z"
7+
transform="translate(-0.811 18.389)" />
8+
</svg>
9+
</template>
10+
11+
<script>
12+
export default {
13+
name: 'VntIconHome'
14+
};
15+
</script>

src/components/icon/icons/Tag.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<template functional>
2+
<svg xmlns="http://www.w3.org/2000/svg"
3+
width="16"
4+
height="13"
5+
viewBox="0 0 16 13">
6+
<path d="M14.539-10.539a4.93,4.93,0,0,1,1.086,1.621A4.986,4.986,0,0,1,16-7a4.957,4.957,0,0,1-.375,1.914,4.941,4.941,0,0,1-1.086,1.617,4.982,4.982,0,0,1-1.621,1.09A4.941,4.941,0,0,1,11-2a4.994,4.994,0,0,1-1.59-.254A4.861,4.861,0,0,1,8-3L6-1,0-7l7-7h6v2.414a5.23,5.23,0,0,1,.809.449A5.272,5.272,0,0,1,14.539-10.539ZM6-2.414l6-6v-2.461a3.907,3.907,0,0,0-.492-.094A4.09,4.09,0,0,0,11-11h-.5a.481.481,0,0,1-.352-.148A.481.481,0,0,1,10-11.5a.481.481,0,0,1,.148-.352A.481.481,0,0,1,10.5-12H11a4.787,4.787,0,0,1,1,.1V-13H7.414l-6,6ZM11-3a3.851,3.851,0,0,0,1.555-.316,4.081,4.081,0,0,0,1.27-.859,4.081,4.081,0,0,0,.859-1.27A3.851,3.851,0,0,0,15-7a3.9,3.9,0,0,0-.145-1.066,4.055,4.055,0,0,0-.406-.957,3.966,3.966,0,0,0-.633-.812A4.022,4.022,0,0,0,13-10.461V-8L8.719-3.719A3.935,3.935,0,0,0,9.8-3.184,3.951,3.951,0,0,0,11-3Z"
7+
transform="translate(0 14)" />
8+
</svg>
9+
</template>
10+
11+
<script>
12+
export default {
13+
name: 'VntIconTag'
14+
};
15+
</script>

stories/components/icon.stories.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,46 @@ import { storiesOf } from '@storybook/vue';
33
/* eslint no-undef: 0,
44
no-unused-vars: 0 */
55
storiesOf('Icon', module)
6+
.add('add', () => ({
7+
render: (h) => (
8+
<vnt-icon name="add" />
9+
)
10+
}))
11+
.add('close', () => ({
12+
render: (h) => (
13+
<vnt-icon name="close" />
14+
)
15+
}))
616
.add('contact', () => ({
717
render: (h) => (
818
<vnt-icon name="contact" />
919
)
1020
}))
21+
.add('delete', () => ({
22+
render: (h) => (
23+
<vnt-icon name="delete" />
24+
)
25+
}))
1126
.add('edit', () => ({
1227
render: (h) => (
1328
<vnt-icon name="edit" />
1429
)
1530
}))
31+
.add('flag', () => ({
32+
render: (h) => (
33+
<vnt-icon name="flag" />
34+
)
35+
}))
1636
.add('global-navigation', () => ({
1737
render: (h) => (
1838
<vnt-icon name="global-navigation" />
1939
)
2040
}))
41+
.add('home', () => ({
42+
render: (h) => (
43+
<vnt-icon name="home" />
44+
)
45+
}))
2146
.add('save', () => ({
2247
render: (h) => (
2348
<vnt-icon name="save" />
@@ -27,4 +52,9 @@ storiesOf('Icon', module)
2752
render: (h) => (
2853
<vnt-icon name="settings" />
2954
)
55+
}))
56+
.add('tag', () => ({
57+
render: (h) => (
58+
<vnt-icon name="tag" />
59+
)
3060
}));

0 commit comments

Comments
 (0)