Skip to content

Commit 8503902

Browse files
isneezyNilpo
authored andcommitted
Implement icon component (tabler#34)
* add icon component * replace raw i tag usage with icon component
1 parent 43a058f commit 8503902

File tree

6 files changed

+39
-9
lines changed

6 files changed

+39
-9
lines changed

example/src/components/HomePage.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,28 @@
2424
<table-cel>Ronald Bardley</table-cel>
2525
<table-cel>Initial commit</table-cel>
2626
<table-cel class="text-norwap">May 6, 2018</table-cel>
27-
<table-cel class="w-1"><a href="#" class="icon"><i class="fe fe-trash"></i></a></table-cel>
27+
<table-cel class="w-1"><a href="#" class="icon"><icon icon="trash"/></a></table-cel>
2828
</table-row>
2929
<table-row>
3030
<table-cel class="w-1"><avatar image-url="/static/demo/faces/female/1.jpg"/></table-cel>
3131
<table-cel>Beverly Armstrong</table-cel>
3232
<table-cel>Left sidebar adjustments</table-cel>
3333
<table-cel class="text-norwap">Apirl 15, 2018</table-cel>
34-
<table-cel class="w-1"><a href="#" class="icon"><i class="fe fe-trash"></i></a></table-cel>
34+
<table-cel class="w-1"><a href="#" class="icon"><icon icon="trash"/></a></table-cel>
3535
</table-row>
3636
<table-row>
3737
<table-cel class="w-1"><avatar image-url="/static/demo/faces/male/4.jpg"/></table-cel>
3838
<table-cel>Boddy Knight</table-cel>
3939
<table-cel>Topbar dropdown style</table-cel>
4040
<table-cel class="text-norwap">Apirl 8, 2018</table-cel>
41-
<table-cel class="w-1"><a href="#" class="icon"><i class="fe fe-trash"></i></a></table-cel>
41+
<table-cel class="w-1"><a href="#" class="icon"><icon icon="trash"/></a></table-cel>
4242
</table-row>
4343
<table-row>
4444
<table-cel class="w-1"><avatar image-url="/static/demo/faces/female/11.jpg"/></table-cel>
4545
<table-cel>Sharon Wells</table-cel>
4646
<table-cel>Fixes #625</table-cel>
4747
<table-cel class="text-norwap">Apirl 9, 2018</table-cel>
48-
<table-cel class="w-1"><a href="#" class="icon"><i class="fe fe-trash"></i></a></table-cel>
48+
<table-cel class="w-1"><a href="#" class="icon"><icon icon="trash"/></a></table-cel>
4949
</table-row>
5050
</table-body>
5151
</t-table>

src/components/Dropdown/DropdownMenuItem.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
<a href="#" class="dropdown-item">
33
<slot>
44
<span v-if="!!badge" class="float-right"><span :class="`badge badge-${type}`">{{ badge }}</span></span>
5-
<i v-if="!!icon" :class="`${iconPrefix} ${iconPrefix}-${icon}`" class="dropdown-icon"></i>
5+
<icon v-if="!!icon" :icon="icon" :prefix="iconPrefix" class="dropdown-icon"/>
66
{{ label }}
77
</slot>
88
</a>
99
</template>
1010

1111
<script>
12+
import Icon from '../Icon'
13+
1214
export default {
13-
name: "dropdown-menu-item",
15+
components: {Icon},
16+
name: "dropdown-menu-item",
1417
props: {
1518
icon: {default: false},
1619
iconPrefix: {default: 'fe'},

src/components/Icon.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export default {
2+
name: 'icon',
3+
props: {
4+
icon: {required: true, type: String},
5+
prefix: {default: 'fe', type: String}
6+
},
7+
template: `<i :class="className"></i>`,
8+
computed: {
9+
className () {
10+
const className = {}
11+
className[`${this.prefix}`] = true
12+
className[`${this.prefix}-${this.icon}`] = true
13+
return className
14+
}
15+
}
16+
}

src/components/Nav/NavItem.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<template>
22
<tag-wrapper :tag="tag" class="nav-item">
3-
<a v-click-out-side="hideDropdown" @click="onClick" :class="className"><i v-if="icon" :class="iconClassName"></i> {{ label }}</a>
3+
<a v-click-out-side="hideDropdown" @click="onClick" :class="className">
4+
<icon v-if="icon" :icon="icon" :prefix="iconPrefix"/>
5+
{{ label }}
6+
</a>
47
<dropdown-menu :show="dropdownVisible">
58
<slot></slot>
69
</dropdown-menu>

src/components/StampCard.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<card class="p-3">
33
<div class="d-flex align-items-center">
44
<span class="stamp stamp-md mr-3" :class="stampClassName">
5-
<i :class="`fe fe-${icon}`"></i>
5+
<icon :icon="icon"/>
66
</span>
77
<div>
88
<h4 class="m-0"><slot>{{ header }}</slot></h4>
@@ -13,6 +13,7 @@
1313
</template>
1414

1515
<script>
16+
import Icon from './Icon'
1617
import Card from './Card/Card'
1718
export default {
1819
name: "stamp-card",
@@ -29,7 +30,12 @@
2930
className[`bg-${this.color}`] = true
3031
return className
3132
}
32-
}
33+
},
34+
35+
components: {
36+
Card,
37+
Icon
38+
}
3339
}
3440
</script>
3541

src/components/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as Card from './Card'
66
import Container from './Container'
77
import * as Dropdown from './Dropdown'
88
import * as Grid from './Grid/index'
9+
import Icon from './Icon'
910
import * as Nav from './Nav'
1011
import Notifications from './Notifications'
1112
import * as Page from './Page'
@@ -25,6 +26,7 @@ export const components = {
2526
Container,
2627
...Dropdown,
2728
...Grid,
29+
Icon,
2830
...Nav,
2931
Notifications,
3032
...Page,

0 commit comments

Comments
 (0)