Skip to content
This repository was archived by the owner on Jun 24, 2020. It is now read-only.

Commit 7bbf83a

Browse files
committed
initial implement progress module
1 parent 804a8ca commit 7bbf83a

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

src/components/modules/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ import Dimmer from './dimmer'
22
import Modal from './modal'
33
import Checkbox from './checkbox'
44
import Accordion from './accordion'
5+
import Progress from './progress'
56

67
export default {
78
install(Vue) {
89
Vue.use(Dimmer)
910
Vue.use(Modal)
1011
Vue.use(Checkbox)
1112
Vue.use(Accordion)
13+
Vue.use(Progress)
1214
}
1315
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<template>
2+
<div class="ui progress" :class="[propClass, stylingClass]">
3+
<div class="bar" :style="{width: `${percent}%`}">
4+
<div class="progress" v-if="showProgress">{{percent}}%</div>
5+
</div>
6+
<div class="label" v-if="label">{{label}}</div>
7+
</div>
8+
</template>
9+
<script>
10+
import {COLORS, SIZES, ATTACH} from 'semantic/const'
11+
import {PropClass} from 'semantic/mixins'
12+
13+
export default {
14+
name: 'ui-progress',
15+
mixins: [
16+
PropClass('indicating', 'active', 'success', 'warning', 'error', 'disabled', 'inverted')
17+
],
18+
props: {
19+
max: {
20+
type: Number,
21+
default: 100
22+
},
23+
value: {
24+
type: Number,
25+
default: 0
26+
},
27+
size: {
28+
type: String,
29+
validate: value => SIZES.indexOf(value) > -1
30+
},
31+
color: {
32+
type: String,
33+
validate: value => COLORS.indexOf(value) > -1
34+
},
35+
attach: {
36+
type: String,
37+
validate: value => ATTACH.indexOf(value) > -1
38+
},
39+
label: String,
40+
showProgress: Boolean
41+
},
42+
model: {
43+
prop: 'value',
44+
event: 'change'
45+
},
46+
computed: {
47+
percent() {
48+
return Math.floor(this.value / this.max * 100)
49+
},
50+
stylingClass() {
51+
let cx = []
52+
this.color && cx.push(this.color)
53+
this.size && cx.push(this.size)
54+
this.attach && cx.push(`${this.attach} attached`)
55+
return cx
56+
}
57+
}
58+
}
59+
</script>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Progress from './Progress.vue'
2+
3+
export default {
4+
install(Vue) {
5+
Vue.component('ui-progress', Progress)
6+
}
7+
}

src/const.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const COLORS = ['red', 'orange', 'yellow', 'olive', 'green', 'teal', 'blue',
2+
'violet', 'purple', 'pink', 'brown', 'grey', 'black']
3+
export const SIZES = ['tiny', 'small', 'standard', 'large', 'big']
4+
export const ATTACH = ['top', 'left', 'right', 'bottom']

0 commit comments

Comments
 (0)