Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Commit 5832c31

Browse files
committed
Add progress component
1 parent caec116 commit 5832c31

File tree

7 files changed

+126
-4
lines changed

7 files changed

+126
-4
lines changed

docs/.vuepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module.exports = {
2626
'components/button',
2727
'components/checkbox',
2828
'components/checkbox-group',
29+
'components/progress',
2930
'components/radio',
3031
'components/radio-group',
3132
'components/spinner',

docs/components/progress.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Progress
2+
Simple progress component showing progress.
3+
4+
5+
## Example
6+
7+
<div class="p-3 border rounded-2 my-3 flex flex-column">
8+
<!-- Indeterminated -->
9+
<v-progress class="mb-5"></v-progress>
10+
11+
<!-- Determinated -->
12+
<v-progress class="mb-3" :progress="progress" type="determinate"></v-progress>
13+
14+
<div>
15+
<v-button size="2" :disabled="progress === 0" @click.native="decrease">-</v-button>
16+
<v-button size="2" :disabled="progress === 100" @click.native="increase">+</v-button>
17+
</div>
18+
</div>
19+
20+
```html
21+
<!-- Indeterminate -->
22+
<v-progress />
23+
24+
<!-- Determinate -->
25+
<v-progress :progress="progress" type="determinate"></v-progress>
26+
```
27+
28+
## Props
29+
Name | Type | Description | Default
30+
---------- | -------- | ----------- | ---------
31+
type | String | Type of progress bar [ 'determinate', 'indeterminate'] | 'determinate'
32+
appearance | String | Appearance of progress bar | 'primary'
33+
34+
<script>
35+
export default {
36+
data() {
37+
return { progress: 10 };
38+
},
39+
methods: {
40+
increase() {
41+
if (this.progress < 100) {
42+
this.progress = this.progress + 5;
43+
}
44+
},
45+
decrease() {
46+
if (this.progress > 0) {
47+
this.progress = this.progress - 5;
48+
}
49+
},
50+
},
51+
};
52+
</script>

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"test:unit": "vue-cli-service test:unit"
1919
},
2020
"devDependencies": {
21-
"@modulist/css": "0.0.7",
21+
"@modulist/css": "0.0.9",
2222
"@vue/cli-plugin-babel": "^3.5.0",
2323
"@vue/cli-plugin-eslint": "^3.5.0",
2424
"@vue/cli-plugin-unit-jest": "^3.5.0",

src/components/Progress/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Progress from './main.vue';
2+
3+
// eslint-disable-next-line func-names
4+
Progress.install = function (Vue) {
5+
Vue.component('VProgress', Progress);
6+
};
7+
8+
export default Progress;

src/components/Progress/main.vue

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<template>
2+
<div class="progress" :class="classes">
3+
<div
4+
class="progress__bar"
5+
role="progressbar"
6+
7+
:aria-valuemax="100"
8+
:aria-valuemin="0"
9+
:aria-valuenow="moderatedProgress"
10+
:style="{ 'width': `${moderatedProgress}%` }"
11+
12+
v-if="type === 'determinate'"
13+
></div>
14+
15+
<div
16+
class="progress__bar"
17+
role="progressbar"
18+
19+
:aria-valuemax="100"
20+
:aria-valuemin="0"
21+
22+
v-else
23+
></div>
24+
</div>
25+
</template>
26+
27+
<script>
28+
export default {
29+
name: 'VProgress',
30+
props: {
31+
type: {
32+
type: String,
33+
default: 'indeterminate',
34+
validator(type) {
35+
return ['indeterminate', 'determinate'].indexOf(type) > -1;
36+
},
37+
},
38+
progress: {
39+
type: Number,
40+
default: 0,
41+
},
42+
},
43+
computed: {
44+
classes() {
45+
return [
46+
`progress--${this.type}`,
47+
];
48+
},
49+
moderatedProgress() {
50+
if (this.progress < 0) {
51+
return 0;
52+
}
53+
if (this.progress > 100) {
54+
return 100;
55+
}
56+
return this.progress;
57+
},
58+
},
59+
};
60+
</script>

src/components/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export { default as VBadge } from './Badge';
44
export { default as VButton } from './Button';
55
export { default as VCheckbox } from './Checkbox';
66
export { default as VCheckboxGroup } from './CheckboxGroup';
7+
export { default as VProgress } from './Progress';
78
export { default as VRadio } from './Radio';
89
export { default as VRadioGroup } from './RadioGroup';
910
export { default as VSpinner } from './Spinner';

0 commit comments

Comments
 (0)