@policystudio/policy-studio-ui-vue 1.0.2 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,11 +1,29 @@
1
1
  # UI library of Vue components with StoryBook
2
2
 
3
- ### Run documentation
4
- ```$ npm run storybook```
3
+ ### Instalation
4
+ ```sh
5
+ npm i -S @policystudio/policy-studio-ui-vue
6
+ ```
5
7
 
6
- ### Instalation for use
7
- ```$ npm i -S @policystudio/policy-studio-ui-vue```
8
+ ### Import the library
9
+ ```javascript
10
+ // src/initComponents.js
8
11
 
12
+ import PolicyStudioUiVue from '@policystudio/policy-studio-ui-vue'
13
+ // ...
14
+ Vue.use(PolicyStudioUiVue)
15
+ ```
9
16
  ### Import CSS
10
17
  Add in your css file
11
- ```@import '~@policystudio/policy-studio-ui-vue/src/assets/scss/tailwind.css'```
18
+
19
+ ```css
20
+ /* src/assets/css/index.css */
21
+
22
+ @import '~@policystudio/policy-studio-ui-vue/src/assets/scss/tailwind.css'
23
+ ```
24
+
25
+ ### Run documentation
26
+ ```npm run storybook```
27
+
28
+ ### Website
29
+ [ui.policystudio.co](https://ui.policystudio.co/)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@policystudio/policy-studio-ui-vue",
3
- "version": "1.0.2",
3
+ "version": "1.0.6",
4
4
  "description": "Policy Studio UI",
5
5
  "main": "src/index.js",
6
6
  "author": "Policy Studio Team",
@@ -1,7 +1,11 @@
1
1
  <template>
2
2
  <label class="container">
3
3
  {{ label }}
4
- <input type="checkbox">
4
+ <input
5
+ type="checkbox"
6
+ v-model="childValue"
7
+ :disabled="disabled"
8
+ />
5
9
  <span class="checkmark"></span>
6
10
  </label>
7
11
  </template>
@@ -54,6 +58,7 @@ export default {
54
58
  return this.value
55
59
  },
56
60
  set (newValue) {
61
+ console.log(newValue)
57
62
  if(this.prevent) return
58
63
  this.$emit('input', newValue)
59
64
  this.$emit('change', newValue)
@@ -0,0 +1,13 @@
1
+ <template>
2
+
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+
8
+ }
9
+ </script>
10
+
11
+ <style>
12
+
13
+ </style>
@@ -0,0 +1,135 @@
1
+ <template>
2
+ <div>
3
+ <div v-if="label" class="psui-mb-2">
4
+ <div class="psui-float-right">{{ value }}</div>
5
+ <div>{{ label }}</div>
6
+ </div>
7
+ <div class="" :class="{'psui-flex psui-items-center': !label && !bubble }">
8
+ <div
9
+ v-if="bubble"
10
+ class="psui-relative psui-bg-gray-40 psui-text-gray-20 psui-rounded-md psui-text-white psui-font-bold psui-w-10 psui-text-center range-value"
11
+ :style="{ left: `${positionBubble}px` }"
12
+ >
13
+ {{ value }}
14
+ </div>
15
+ <input
16
+ type="range"
17
+ :min="min"
18
+ :max="max"
19
+ :value="value"
20
+ @input="$emit('update:value', Number($event.target.value))"
21
+ class="slider psui-float-left"
22
+ ref="slider"
23
+ />
24
+ <span v-if="!label && !bubble" class="psui-bg-gray-20 psui-font-bold psui-text-gray-50 psui-px-2 psui-py-px psui-rounded-sm psui-float-left psui-ml-2">{{ value }}</span>
25
+ </div>
26
+ </div>
27
+ </template>
28
+
29
+ <script>
30
+ export default {
31
+ name: 'PsSlider',
32
+ computed: {
33
+ positionBubble() {
34
+ if (this.bubble && this.isMounted) {
35
+ return (this.$refs.slider.offsetWidth / this.max) * this.value - 15
36
+ }
37
+ }
38
+ },
39
+ methods: {
40
+ getValueToScale(value) {
41
+ return 100 * value / this.rangeDistanceMax
42
+ }
43
+ },
44
+ props: {
45
+ min: {
46
+ type: Number,
47
+ default: 0,
48
+ },
49
+ max: {
50
+ type: Number,
51
+ required: true,
52
+ },
53
+ label: {
54
+ type: String,
55
+ },
56
+ value: {
57
+ type: [Number, String],
58
+ },
59
+ baseValue: {
60
+ type: [Number, Boolean]
61
+ },
62
+ labelPosition: {
63
+ type: String
64
+ },
65
+ step: {
66
+ type: Number,
67
+ default: 1
68
+ },
69
+ bubble: {
70
+ type: Boolean
71
+ }
72
+ },
73
+ data: () => {
74
+ return {
75
+ isMounted: false
76
+ }
77
+ },
78
+ mounted() {
79
+ this.isMounted = true
80
+ }
81
+ }
82
+ </script>
83
+
84
+ <style>
85
+ .slider {
86
+ width: 100%;
87
+ -webkit-appearance: none;
88
+ height: 6px;
89
+ border-radius: 5px;
90
+ background: #d3d3d3;
91
+ outline: none;
92
+ opacity: 0.7;
93
+ -webkit-transition: .2s;
94
+ transition: opacity .2s;
95
+ }
96
+
97
+ .slider:hover {
98
+ opacity: 1;
99
+ }
100
+
101
+ .slider::-webkit-slider-thumb {
102
+ border: none;
103
+ -webkit-appearance: none;
104
+ appearance: none;
105
+ width: 20px;
106
+ height: 20px;
107
+ border-radius: 50%;
108
+ background: #64B5CE;
109
+ cursor: pointer;
110
+ }
111
+
112
+ .slider::-moz-range-thumb {
113
+ border: none;
114
+ width: 20px;
115
+ height: 20px;
116
+ border-radius: 50%;
117
+ background: #64B5CE;
118
+ cursor: pointer;
119
+ }
120
+ .slider::-webkit-slider-progress, .slider::-moz-range-progress {
121
+ border-top-left-radius: 5px;
122
+ border-bottom-left-radius: 5px;
123
+ -webkit-appearance: none;
124
+ box-shadow: none;
125
+ border: none;
126
+ background: #64B5CE;
127
+ height: 6px;
128
+ }
129
+
130
+ .range-value{
131
+ margin-bottom: 10px;
132
+ padding: 2px 4px;
133
+
134
+ }
135
+ </style>
@@ -0,0 +1,92 @@
1
+ <template>
2
+ <label for="ps-switch" class="psui-flex psui-items-center psui-cursor-pointer psui-relative">
3
+ <input type="checkbox" id="ps-switch" class="psui-hidden" :checked="active">
4
+ <div
5
+ :class="classes"
6
+ @click="change()"
7
+ ></div>
8
+ <span class="psui-ml-3 psui-text-gray-50 psui-text-sm psui-font-medium">{{ label }}</span>
9
+ </label>
10
+ </template>
11
+
12
+ <script>
13
+ export const sizes = ['big', 'small']
14
+ export default {
15
+ computed: {
16
+ text() {
17
+ if (this.label && this.labelActived) {
18
+ return this.active ? this.labelActived : this.label
19
+ } else if (this.label) {
20
+ return this.label
21
+ } else {
22
+ return false
23
+ }
24
+ },
25
+ classes() {
26
+ if (this.size === 'small') {
27
+ return 'toggle-bg psui-bg-gray-40 psui-border-gray-40 psui-border-2 psui-h-4 ps-switch-small psui-rounded-full'
28
+ }
29
+ return 'toggle-bg psui-bg-gray-40 psui-border-gray-40 psui-border-2 psui-h-6 ps-switch psui-rounded-full'
30
+ }
31
+ },
32
+ props: {
33
+ label: String,
34
+ active: {
35
+ type: Boolean,
36
+ default: false
37
+ },
38
+ disabled: {
39
+ type: Boolean,
40
+ default: false
41
+ },
42
+ size: {
43
+ type: String,
44
+ default: 'big',
45
+ validator: (value) => sizes.indexOf(value) !== -1
46
+ }
47
+ },
48
+ methods: {
49
+ change() {
50
+ if (!this.disabled) {
51
+ this.$emit('update:active', !this.active)
52
+ this.$emit('change', !this.active)
53
+ }
54
+ }
55
+ }
56
+ }
57
+ </script>
58
+
59
+ <style scoped>
60
+ .ps-switch {
61
+ width: 46px;
62
+ }
63
+ .ps-switch-small {
64
+ width: 30px;
65
+ }
66
+ .toggle-bg:after {
67
+ content: '';
68
+ @apply psui-absolute psui-bg-white psui-border-gray-40 psui-rounded-full psui-h-5 psui-w-5 psui-transition;
69
+ }
70
+ .toggle-bg:after + .ps-switch-small {
71
+ content: '';
72
+ @apply psui-absolute psui-bg-white psui-border-gray-40 psui-rounded-full psui-h-2 psui-w-2 psui-transition;
73
+ }
74
+
75
+ input:checked + .toggle-bg:after + .ps-switch-small {
76
+ transform: translateX(100%);
77
+ position: absolute;
78
+ left: 2px;
79
+ @apply border-white;
80
+ }
81
+
82
+ input:checked + .toggle-bg:after {
83
+ transform: translateX(100%);
84
+ position: absolute;
85
+ left: 4px;
86
+ @apply border-white;
87
+ }
88
+
89
+ input:checked + .toggle-bg {
90
+ @apply psui-bg-green-20 psui-border-green-20;
91
+ }
92
+ </style>
File without changes
package/src/index.js CHANGED
@@ -1,18 +1,18 @@
1
- import PsButton from './components/notifications/PsButton.vue';
2
- import PsCheckbox from './components/notifications/PsCheckbox.vue';
1
+ import PsButton from './components/buttons/PsButton.vue';
2
+ import PsCheckbox from './components/controls/PsCheckbox.vue';
3
3
  import PsDialog from './components/notifications/PsDialog.vue';
4
4
  import PsToast from './components/notifications/PsToast.vue';
5
- import PsTabHeader from './components/notifications/PsTabHeader.vue';
6
- import PsTabRadioButton from './components/notifications/PsTabRadioButton.vue';
5
+ import PsTabHeader from './components/tabs/PsTabHeader.vue';
6
+ import PsRadioButton from './components/controls/PsRadioButton.vue';
7
7
 
8
8
  export default {
9
9
  install(Vue) {
10
- Vue.component(' PsButton', PsButton);
11
- Vue.component(' PsCheckbox', PsCheckbox);
12
- Vue.component(' PsDialog', PsDialog);
13
- Vue.component(' PsToast', PsToast);
14
- Vue.component(' PsTabHeader', PsTabHeader);
15
- Vue.component(' PsTabRadioButton', PsTabRadioButton);
10
+ Vue.component('PsButton', PsButton);
11
+ Vue.component('PsCheckbox', PsCheckbox);
12
+ Vue.component('PsDialog', PsDialog);
13
+ Vue.component('PsToast', PsToast);
14
+ Vue.component('PsTabHeader', PsTabHeader);
15
+ Vue.component('PsRadioButton', PsRadioButton);
16
16
  }
17
17
  };
18
18
 
@@ -22,5 +22,5 @@ export {
22
22
  PsDialog,
23
23
  PsToast,
24
24
  PsTabHeader,
25
- PsTabRadioButton
25
+ PsRadioButton
26
26
  }
@@ -11,8 +11,28 @@ export default {
11
11
  const Template = (args, { argTypes }) => ({
12
12
  props: Object.keys(argTypes),
13
13
  components: { PsCheckbox },
14
+ data: () => {
15
+ return {
16
+ items: [
17
+ { label: 'Label 1', id: 1 },
18
+ { label: 'Label 2', id: 2 },
19
+ { label: 'Label 3', id: 3 }
20
+ ],
21
+ selected: []
22
+ }
23
+ },
14
24
  template: `
15
- <PsCheckbox v-bind="$props" />
25
+ <div>
26
+ <PsCheckbox
27
+ v-bind="$props"
28
+ v-for="(item, index) in items"
29
+ :key="index"
30
+ :label="item.label"
31
+ :value.sync="item.id"
32
+ v-model="selected"
33
+ />
34
+ {{ selected }}
35
+ </div>
16
36
  `
17
37
  });
18
38
 
@@ -21,3 +41,4 @@ Default.args = {
21
41
  label: 'Label',
22
42
  size: 16
23
43
  };
44
+
@@ -0,0 +1,40 @@
1
+ import PsSlider from '../components/controls/PsSlider.vue';
2
+ export default {
3
+ title: 'Components/Slider',
4
+ component: PsSlider,
5
+ argTypes: {
6
+ },
7
+ };
8
+
9
+ const Template = (args, { argTypes }) => ({
10
+ props: Object.keys(argTypes),
11
+ components: { PsSlider },
12
+ template: `
13
+ <div style="width: 500px;">
14
+ <PsSlider v-bind="$props" :value.sync="value" />
15
+ </div>
16
+ `
17
+ });
18
+
19
+ export const Label = Template.bind({});
20
+ Label.args = {
21
+ min: 1,
22
+ max: 100,
23
+ value: 30,
24
+ label: 'Score Label'
25
+ };
26
+
27
+ export const NoLabel = Template.bind({});
28
+ NoLabel.args = {
29
+ min: 1,
30
+ max: 100,
31
+ value: 15
32
+ };
33
+
34
+ export const Bubble = Template.bind({});
35
+ Bubble.args = {
36
+ min: 1,
37
+ max: 100,
38
+ value: 23,
39
+ bubble: true
40
+ };
@@ -0,0 +1,38 @@
1
+ import PsSwitch, { sizes } from '../components/controls/PsSwitch.vue';
2
+ export default {
3
+ title: 'Components/Switch',
4
+ component: PsSwitch,
5
+ argTypes: {
6
+ size: { control: { type: 'select', options: sizes } }
7
+ },
8
+ };
9
+
10
+ const Template = (args, { argTypes }) => ({
11
+ props: Object.keys(argTypes),
12
+ components: { PsSwitch },
13
+ data: () => {
14
+ return {
15
+ model: true
16
+ }
17
+ },
18
+ template: `
19
+ <div>
20
+ <PsSwitch v-bind="$props" :active.sync="model" />
21
+ </div>
22
+ `
23
+ });
24
+
25
+ export const Big = Template.bind({});
26
+ Big.args = {
27
+ size: 'big',
28
+ active: false,
29
+ label: 'Switch Big',
30
+ };
31
+
32
+ export const Small = Template.bind({});
33
+ Small.args = {
34
+ size: 'small',
35
+ active: false,
36
+ label: 'Switch Small',
37
+ };
38
+