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

Commit

Permalink
initial implement progress module
Browse files Browse the repository at this point in the history
  • Loading branch information
comfuture committed Jul 20, 2017
1 parent 804a8ca commit 7bbf83a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/components/modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import Dimmer from './dimmer'
import Modal from './modal'
import Checkbox from './checkbox'
import Accordion from './accordion'
import Progress from './progress'

export default {
install(Vue) {
Vue.use(Dimmer)
Vue.use(Modal)
Vue.use(Checkbox)
Vue.use(Accordion)
Vue.use(Progress)
}
}
59 changes: 59 additions & 0 deletions src/components/modules/progress/Progress.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>
<div class="ui progress" :class="[propClass, stylingClass]">
<div class="bar" :style="{width: `${percent}%`}">
<div class="progress" v-if="showProgress">{{percent}}%</div>
</div>
<div class="label" v-if="label">{{label}}</div>
</div>
</template>
<script>
import {COLORS, SIZES, ATTACH} from 'semantic/const'
import {PropClass} from 'semantic/mixins'
export default {
name: 'ui-progress',
mixins: [
PropClass('indicating', 'active', 'success', 'warning', 'error', 'disabled', 'inverted')
],
props: {
max: {
type: Number,
default: 100
},
value: {
type: Number,
default: 0
},
size: {
type: String,
validate: value => SIZES.indexOf(value) > -1
},
color: {
type: String,
validate: value => COLORS.indexOf(value) > -1
},
attach: {
type: String,
validate: value => ATTACH.indexOf(value) > -1
},
label: String,
showProgress: Boolean
},
model: {
prop: 'value',
event: 'change'
},
computed: {
percent() {
return Math.floor(this.value / this.max * 100)
},
stylingClass() {
let cx = []
this.color && cx.push(this.color)
this.size && cx.push(this.size)
this.attach && cx.push(`${this.attach} attached`)
return cx
}
}
}
</script>
7 changes: 7 additions & 0 deletions src/components/modules/progress/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Progress from './Progress.vue'

export default {
install(Vue) {
Vue.component('ui-progress', Progress)
}
}
4 changes: 4 additions & 0 deletions src/const.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const COLORS = ['red', 'orange', 'yellow', 'olive', 'green', 'teal', 'blue',
'violet', 'purple', 'pink', 'brown', 'grey', 'black']
export const SIZES = ['tiny', 'small', 'standard', 'large', 'big']
export const ATTACH = ['top', 'left', 'right', 'bottom']

0 comments on commit 7bbf83a

Please sign in to comment.