@magicgol/polyjuice 0.36.0 → 0.37.0
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
package/src/assets/palette.scss
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
import MgBarChart from './BarChart.vue';
|
2
|
+
|
3
|
+
// More on default export: https://storybook.js.org/docs/vue/writing-stories/introduction#default-export
|
4
|
+
export default {
|
5
|
+
title: 'Chart/Bar',
|
6
|
+
component: MgBarChart,
|
7
|
+
// More on argTypes: https://storybook.js.org/docs/vue/api/argtypes
|
8
|
+
argTypes: {
|
9
|
+
theme: {
|
10
|
+
control: { type: 'select' },
|
11
|
+
options: [null, 'winner'],
|
12
|
+
defaultValue: null
|
13
|
+
},
|
14
|
+
},
|
15
|
+
};
|
16
|
+
|
17
|
+
// More on component templates: https://storybook.js.org/docs/vue/writing-stories/introduction#using-args
|
18
|
+
const Template = (args, { argTypes }) => ({
|
19
|
+
props: Object.keys(argTypes),
|
20
|
+
components: { MgBarChart },
|
21
|
+
template: `<mg-bar-chart v-bind="$props"><template v-if="${'default' in args}" v-slot>${args.default}</template></mg-bar-chart>`,
|
22
|
+
});
|
23
|
+
|
24
|
+
export const Default = Template.bind({});
|
25
|
+
// More on args: https://storybook.js.org/docs/vue/writing-stories/args
|
26
|
+
Default.args = {
|
27
|
+
value: 0.5
|
28
|
+
};
|
29
|
+
|
30
|
+
export const Winner = Template.bind({});
|
31
|
+
// More on args: https://storybook.js.org/docs/vue/writing-stories/args
|
32
|
+
Winner.args = {
|
33
|
+
value: 0.5,
|
34
|
+
theme: 'winner'
|
35
|
+
};
|
36
|
+
|
37
|
+
|
@@ -0,0 +1,69 @@
|
|
1
|
+
<template>
|
2
|
+
<div
|
3
|
+
class="w-100"
|
4
|
+
:class="classes"
|
5
|
+
><div :style="{width: width}"></div></div>
|
6
|
+
</template>
|
7
|
+
|
8
|
+
<script>
|
9
|
+
export default {
|
10
|
+
name: 'mg-bar-chart',
|
11
|
+
|
12
|
+
props: {
|
13
|
+
value: {
|
14
|
+
type: Number,
|
15
|
+
default: 0,
|
16
|
+
validator: function (value) {
|
17
|
+
return value >= 0 && value <= 1;
|
18
|
+
}
|
19
|
+
},
|
20
|
+
|
21
|
+
theme: {
|
22
|
+
type: String,
|
23
|
+
default: null,
|
24
|
+
validator: function (value) {
|
25
|
+
return ['winner'].indexOf(value) !== -1;
|
26
|
+
},
|
27
|
+
},
|
28
|
+
},
|
29
|
+
|
30
|
+
computed: {
|
31
|
+
classes() {
|
32
|
+
return {
|
33
|
+
'mg-bar-chart': true,
|
34
|
+
'mg-bar-chart--theme-winner': this.theme === 'winner',
|
35
|
+
};
|
36
|
+
},
|
37
|
+
|
38
|
+
width() {
|
39
|
+
return (this.value * 100) + '%';
|
40
|
+
},
|
41
|
+
},
|
42
|
+
};
|
43
|
+
</script>
|
44
|
+
|
45
|
+
<style lang="scss">
|
46
|
+
@import '../../../assets/palette';
|
47
|
+
|
48
|
+
.mg-bar-chart {
|
49
|
+
background-color: #eeeeee;
|
50
|
+
border-radius: 4px;
|
51
|
+
height: 0.5rem;
|
52
|
+
position: relative;
|
53
|
+
|
54
|
+
> div {
|
55
|
+
background-color: white;
|
56
|
+
border-radius: 4px;
|
57
|
+
height: 100%;
|
58
|
+
left: 0;
|
59
|
+
position: relative;
|
60
|
+
top: 0;
|
61
|
+
}
|
62
|
+
|
63
|
+
&--theme-winner {
|
64
|
+
> div {
|
65
|
+
background-color: map_get($palette, 'winner') !important;
|
66
|
+
}
|
67
|
+
}
|
68
|
+
}
|
69
|
+
</style>
|
@@ -3,6 +3,7 @@
|
|
3
3
|
<input
|
4
4
|
class="d-none"
|
5
5
|
type="radio"
|
6
|
+
:name="name"
|
6
7
|
:value="value"
|
7
8
|
@input="onInput"
|
8
9
|
/>
|
@@ -26,6 +27,11 @@ export default {
|
|
26
27
|
type: Boolean,
|
27
28
|
default: false
|
28
29
|
},
|
30
|
+
|
31
|
+
name: {
|
32
|
+
type: String,
|
33
|
+
default: 'radio'
|
34
|
+
},
|
29
35
|
},
|
30
36
|
|
31
37
|
computed: {
|