@policystudio/policy-studio-ui-vue 1.0.19 → 1.0.23
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/.eslintrc.js +1 -2
- package/.storybook/main.js +10 -2
- package/.storybook/preview.js +1 -1
- package/README.md +8 -0
- package/babel.config.js +3 -0
- package/backup-package-lock.json +37194 -0
- package/dist/css/psui_styles.css +15709 -14658
- package/package.json +32 -21
- package/postcss.config.js +2 -0
- package/src/assets/scss/base.scss +9 -29
- package/src/assets/scss/components/PsAccordion.scss +63 -0
- package/src/assets/scss/components/PsButton.scss +145 -0
- package/src/assets/scss/components/PsInput.scss +104 -0
- package/src/components/accordion/PsAccordion.vue +30 -21
- package/src/components/accordion/PsAccordionItem.vue +29 -67
- package/src/components/badges-and-tags/PsCardInfos.vue +38 -0
- package/src/components/badges-and-tags/PsChartLegend.vue +43 -0
- package/src/components/badges-and-tags/PsClimateZoneBadge.vue +18 -0
- package/src/components/badges-and-tags/PsCostEffectBar.vue +114 -0
- package/src/components/badges-and-tags/PsHighlightRippleDot.vue +78 -0
- package/src/components/badges-and-tags/PsMiniTag.vue +46 -0
- package/src/components/badges-and-tags/PsProgressBar.vue +0 -0
- package/src/components/buttons/PsButton.vue +43 -75
- package/src/components/chips/PsChips.vue +46 -38
- package/src/components/controls/PsCheckbox.vue +29 -16
- package/src/components/controls/PsDraggable.vue +174 -3
- package/src/components/controls/PsRadioButton.vue +74 -43
- package/src/components/controls/PsSwitch.vue +75 -76
- package/src/components/controls/PsToggle.vue +1 -1
- package/src/components/datatable/PsDataTable.vue +25 -29
- package/src/components/datatable/PsDataTableItem.vue +2 -2
- package/src/components/forms/PsInput.vue +122 -102
- package/src/components/notifications/PsDialog.vue +37 -18
- package/src/components/tabs/PsTabHeader.vue +3 -2
- package/src/components/tooltip/PsDialogTooltip.vue +79 -0
- package/src/components/tooltip/PsRichTooltip.vue +44 -0
- package/src/components/tooltip/PsTooltip.vue +118 -0
- package/src/components/ui/PsIcon.vue +87 -24
- package/src/index.js +29 -9
- package/src/stories/Accordion.stories.js +88 -28
- package/src/stories/Button.stories.js +86 -38
- package/src/stories/CardInfos.stories.js +16 -0
- package/src/stories/ChartLegend.stories.js +16 -0
- package/src/stories/Checkbox.stories.js +6 -6
- package/src/stories/Chips.stories.js +14 -8
- package/src/stories/ClimateZoneBadge.stories.js +24 -0
- package/src/stories/Colors.stories.mdx +35 -35
- package/src/stories/CostEffectBar.stories.js +23 -0
- package/src/stories/Datatable.stories.js +15 -8
- package/src/stories/Dialog.stories.js +150 -17
- package/src/stories/Draggable.stories.js +22 -0
- package/src/stories/Dropdown.stories.js +8 -10
- package/src/stories/HighlightRippleDot.stories.js +16 -0
- package/src/stories/Input.stories.js +71 -19
- package/src/stories/MiniTag.stories.js +46 -0
- package/src/stories/ProgressBar.stories.js +23 -0
- package/src/stories/RadioButton.stories.js +15 -15
- package/src/stories/Slider.stories.js +9 -9
- package/src/stories/Swith.stories.js +10 -10
- package/src/stories/TabHeader.stories.js +9 -9
- package/src/stories/Toast.stories.js +13 -13
- package/src/stories/Toggle.stories.js +12 -13
- package/src/stories/Tooltip.stories.js +114 -0
- package/src/util/GeneralFunctions.js +11 -12
- package/src/util/imageLoader.js +50 -0
- package/tailwind.config.js +71 -47
- package/src/assets/scss/tailwind.css +0 -70643
- package/src/assets/scss/tailwind.scss +0 -61088
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<label
|
|
2
|
+
<label
|
|
3
|
+
class="container psui-pl-6"
|
|
4
|
+
:class="[
|
|
5
|
+
{ 'psui-text-gray-40': disabled },
|
|
6
|
+
{ 'psui-text-gray-50': !disabled },
|
|
7
|
+
labelClasses,
|
|
8
|
+
]"
|
|
9
|
+
>
|
|
3
10
|
{{ label }}
|
|
4
11
|
<input
|
|
5
12
|
type="checkbox"
|
|
@@ -7,7 +14,11 @@
|
|
|
7
14
|
:disabled="disabled"
|
|
8
15
|
:value="inputValue"
|
|
9
16
|
/>
|
|
10
|
-
<span
|
|
17
|
+
<span
|
|
18
|
+
class="checkmark psui-border-2"
|
|
19
|
+
:class="classes"
|
|
20
|
+
:style="getSize"
|
|
21
|
+
></span>
|
|
11
22
|
</label>
|
|
12
23
|
</template>
|
|
13
24
|
|
|
@@ -18,26 +29,26 @@ export default {
|
|
|
18
29
|
value: {
|
|
19
30
|
required: true,
|
|
20
31
|
},
|
|
21
|
-
inputValue: String,
|
|
32
|
+
inputValue: String,
|
|
22
33
|
label: {
|
|
23
34
|
type: String,
|
|
24
|
-
default: ''
|
|
35
|
+
default: '',
|
|
25
36
|
},
|
|
26
37
|
checkboxClasses: {
|
|
27
38
|
type: String,
|
|
28
|
-
default: ''
|
|
39
|
+
default: '',
|
|
29
40
|
},
|
|
30
41
|
labelClasses: {
|
|
31
42
|
type: String,
|
|
32
|
-
default: ''
|
|
43
|
+
default: '',
|
|
33
44
|
},
|
|
34
45
|
disabled: {
|
|
35
46
|
type: Boolean,
|
|
36
|
-
default: false
|
|
47
|
+
default: false,
|
|
37
48
|
},
|
|
38
49
|
size: {
|
|
39
|
-
default: 18
|
|
40
|
-
}
|
|
50
|
+
default: 18,
|
|
51
|
+
},
|
|
41
52
|
},
|
|
42
53
|
computed: {
|
|
43
54
|
model: {
|
|
@@ -50,15 +61,17 @@ export default {
|
|
|
50
61
|
},
|
|
51
62
|
},
|
|
52
63
|
classes() {
|
|
53
|
-
return `${
|
|
64
|
+
return `${
|
|
65
|
+
this.disabled ? 'psui-border-gray-40' : 'psui-border-gray-50'
|
|
66
|
+
} ${this.checkboxClasses}`
|
|
54
67
|
},
|
|
55
68
|
getSize() {
|
|
56
69
|
return {
|
|
57
70
|
width: `${this.size}px`,
|
|
58
|
-
height: `${this.size}px
|
|
71
|
+
height: `${this.size}px`,
|
|
59
72
|
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
73
|
+
},
|
|
74
|
+
},
|
|
62
75
|
}
|
|
63
76
|
</script>
|
|
64
77
|
|
|
@@ -92,12 +105,12 @@ export default {
|
|
|
92
105
|
}
|
|
93
106
|
|
|
94
107
|
.container input:checked ~ .checkmark {
|
|
95
|
-
background-color: #
|
|
108
|
+
background-color: #64b5ce;
|
|
96
109
|
border: none;
|
|
97
110
|
}
|
|
98
111
|
|
|
99
112
|
.checkmark:after {
|
|
100
|
-
content:
|
|
113
|
+
content: '';
|
|
101
114
|
position: absolute;
|
|
102
115
|
display: none;
|
|
103
116
|
}
|
|
@@ -118,4 +131,4 @@ export default {
|
|
|
118
131
|
-ms-transform: rotate(45deg);
|
|
119
132
|
transform: rotate(45deg);
|
|
120
133
|
}
|
|
121
|
-
</style>
|
|
134
|
+
</style>
|
|
@@ -1,13 +1,184 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
2
|
+
<div class="psui-w-full psui-my-4 psui-pr-4 psui-flex psui-flex-wrap psui-justify-start psui-mb-20">
|
|
3
|
+
<div class="psui-w-full psui-mb-4 psui-rounded-lg psui-bg-gray-30 psui-p-2"
|
|
4
|
+
v-for="(columnGroup, indexColumnGroup) in getColumns.columnGroups"
|
|
5
|
+
:key="indexColumnGroup"
|
|
6
|
+
:class="{ 'is-dragging-out' : indexColumnGroup == isDraggingOverGroup}"
|
|
7
|
+
>
|
|
8
|
+
<!-- COLUMN GROUP -->
|
|
9
|
+
<div
|
|
10
|
+
class="psui-w-full psui-flex psui-justify-between psui-mb-2 psui-rounded-sm psui-items-center psui-px-2 app-draggable-list-item"
|
|
11
|
+
draggable="true"
|
|
12
|
+
@dragstart="dragStartGroup({ indexColumnGroup })"
|
|
13
|
+
@dragover="dragOverGroup({ indexColumnGroup })"
|
|
14
|
+
@dragend="dragEndGroup"
|
|
15
|
+
>
|
|
16
|
+
<h2 class="psui-w-full psui-text-gray-80 psui-font-bold psui-pl-4 psui-py-2">{{columnGroup.title}}</h2>
|
|
17
|
+
<i class='material-icons-round psui-text-gray-40 psui-pr-1 psui-py-2'>drag_indicator</i>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<div class="psui-w-full psui-flex psui-flex-wrap">
|
|
21
|
+
<!-- COLUMNS -->
|
|
22
|
+
<div class="psui-w-full psui-mb-2 app-draggable-list-item"
|
|
23
|
+
v-for="(column, indexColumn) in columnGroup.columns"
|
|
24
|
+
:key="`edit-columns-column-${indexColumnGroup}-${indexColumn}`"
|
|
25
|
+
:id="`edit-columns-column-${indexColumnGroup}-${indexColumn}`"
|
|
26
|
+
>
|
|
27
|
+
<div class="psui-select-none psui-w-full psui-py-2 psui-px-3 psui-rounded-sm psui-flex psui-items-center psui-bg-white"
|
|
28
|
+
draggable="true"
|
|
29
|
+
@dragstart="dragStartColumn({ indexColumnGroup, indexColumn })"
|
|
30
|
+
@dragover="dragOverColumn({ indexColumnGroup, indexColumn })"
|
|
31
|
+
@dragend="dragEndColumn"
|
|
32
|
+
:class="{ 'is-dragging-out' : checkColumnIsDragOver({ indexColumnGroup, indexColumn }) }"
|
|
33
|
+
>
|
|
34
|
+
<PsCheckbox :inputValue='column' :label='column' @change="toggleColumnIsActive({ studyKey: getColumns.key, indexColumnGroup, indexColumn, columnGroupKey: columnGroup.key})">
|
|
35
|
+
</PsCheckbox>
|
|
36
|
+
|
|
37
|
+
<!-- <Checkbox
|
|
38
|
+
class="psui-whitespace-no-wrap"
|
|
39
|
+
:label="column.title"
|
|
40
|
+
:value="column.isActive"
|
|
41
|
+
@change="toggleColumnIsActive({ studyKey: getColumns.key, indexColumnGroup, indexColumn, columnGroupKey: columnGroup.key})"
|
|
42
|
+
></Checkbox> -->
|
|
43
|
+
<div class="psui-w-full psui-flex psui-justify-end">
|
|
44
|
+
<i class='material-icons-round psui-text-gray-30'>drag_indicator</i>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</div>
|
|
3
51
|
</template>
|
|
4
52
|
|
|
5
53
|
<script>
|
|
54
|
+
import PsCheckbox from './PsCheckbox.vue'
|
|
55
|
+
|
|
6
56
|
export default {
|
|
57
|
+
name: 'DragAndDropEditColumnsList',
|
|
58
|
+
components: { PsCheckbox},
|
|
59
|
+
props: ['getColumns', 'module'],
|
|
60
|
+
data() {
|
|
61
|
+
return {
|
|
62
|
+
// Column
|
|
63
|
+
isDraggingColumnGroup: -1,
|
|
64
|
+
isDraggingOverColumn: -1,
|
|
65
|
+
isDraggingColumn: -1,
|
|
66
|
+
|
|
67
|
+
// Group
|
|
68
|
+
isDraggingGroup: -1,
|
|
69
|
+
isDraggingOverGroup: -1,
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
computed: {
|
|
74
|
+
getColumnsStateKey() {
|
|
75
|
+
return `${this.module}Columns`
|
|
76
|
+
},
|
|
77
|
+
getMoveColumnStoreMutationName() {
|
|
78
|
+
return `${this.module}/moveColumnItem`
|
|
79
|
+
},
|
|
80
|
+
getMoveColumnGroupStoreMutationName() {
|
|
81
|
+
return `${this.module}/moveColumnGroup`
|
|
82
|
+
},
|
|
83
|
+
getToggleColumnIsActiveStoreMutationName() {
|
|
84
|
+
return `${this.module}/toggleColumnIsActive`
|
|
85
|
+
}
|
|
7
86
|
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
methods: {
|
|
90
|
+
toggleColumnIsActive({ studyKey, indexColumnGroup, indexColumn, columnGroupKey }) {
|
|
91
|
+
this.$store.commit(this.getToggleColumnIsActiveStoreMutationName, { columnsStateKey: this.getColumnsStateKey, studyKey, indexColumnGroup, indexColumn, columnGroupKey })
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Drag and drop COLUMN
|
|
96
|
+
*/
|
|
97
|
+
dragStartColumn({ indexColumnGroup, indexColumn }) {
|
|
98
|
+
this.isDraggingColumn = indexColumn
|
|
99
|
+
this.isDraggingColumnGroup = indexColumnGroup
|
|
100
|
+
},
|
|
101
|
+
dragEndColumn() {
|
|
102
|
+
this.moveItemColumn({
|
|
103
|
+
studyKey: this.getColumns.key,
|
|
104
|
+
indexColumnGroup: this.isDraggingColumnGroup,
|
|
105
|
+
from: this.isDraggingColumn,
|
|
106
|
+
to: this.isDraggingOverColumn
|
|
107
|
+
})
|
|
108
|
+
this.dragLeaveColumn()
|
|
109
|
+
this.dragLeaveGroup()
|
|
110
|
+
},
|
|
111
|
+
dragOverColumn({ indexColumnGroup, indexColumn }) {
|
|
112
|
+
if(this.isDraggingColumnGroup != indexColumnGroup) return
|
|
113
|
+
this.isDraggingOverColumn = indexColumn
|
|
114
|
+
},
|
|
115
|
+
checkColumnIsDragOver({indexColumnGroup, indexColumn }) {
|
|
116
|
+
return (this.isDraggingColumnGroup == indexColumnGroup && this.isDraggingOverColumn == indexColumn)
|
|
117
|
+
},
|
|
118
|
+
dragLeaveColumn() {
|
|
119
|
+
this.isDraggingColumn = -1
|
|
120
|
+
this.isDraggingColumnGroup = -1
|
|
121
|
+
this.isDraggingOverColumn = -1
|
|
122
|
+
},
|
|
123
|
+
moveItemColumn({ studyKey, indexColumnGroup, from, to}) {
|
|
124
|
+
this.$store.commit(this.getMoveColumnStoreMutationName, {
|
|
125
|
+
columnsStateKey: this.getColumnsStateKey,
|
|
126
|
+
studyKey,
|
|
127
|
+
indexColumnGroup,
|
|
128
|
+
from,
|
|
129
|
+
to
|
|
130
|
+
})
|
|
131
|
+
this.blinkColumns({ indexColumnGroup, to })
|
|
132
|
+
this.dragLeaveColumn()
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
blinkColumns({ indexColumnGroup, to }) {
|
|
136
|
+
const colToBlink = document.getElementById(`edit-columns-column-${indexColumnGroup}-${to}`)
|
|
137
|
+
if(colToBlink) {
|
|
138
|
+
colToBlink.classList.add('blink')
|
|
139
|
+
setTimeout(() => colToBlink.classList.remove('blink'), 800)
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Drag and drop GROUP
|
|
145
|
+
*/
|
|
146
|
+
dragStartGroup({ indexColumnGroup }) {
|
|
147
|
+
this.isDraggingGroup = indexColumnGroup
|
|
148
|
+
},
|
|
149
|
+
dragEndGroup() {
|
|
150
|
+
this.moveItemGroup({
|
|
151
|
+
studyKey: this.getColumns.key,
|
|
152
|
+
from: this.isDraggingGroup,
|
|
153
|
+
to: this.isDraggingOverGroup
|
|
154
|
+
})
|
|
155
|
+
this.dragLeaveGroup()
|
|
156
|
+
},
|
|
157
|
+
dragOverGroup({ indexColumnGroup }) {
|
|
158
|
+
if(this.isDraggingGroup < 0) return
|
|
159
|
+
this.isDraggingOverGroup = indexColumnGroup
|
|
160
|
+
},
|
|
161
|
+
dragLeaveGroup() {
|
|
162
|
+
this.isDraggingGroup = -1
|
|
163
|
+
this.isDraggingOverGroup = -1
|
|
164
|
+
},
|
|
165
|
+
moveItemGroup({ studyKey, from, to}) {
|
|
166
|
+
this.$store.commit(this.getMoveColumnGroupStoreMutationName, {
|
|
167
|
+
columnsStateKey: this.getColumnsStateKey,
|
|
168
|
+
studyKey,
|
|
169
|
+
from,to
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
}
|
|
8
174
|
}
|
|
9
175
|
</script>
|
|
176
|
+
<style scoped>
|
|
177
|
+
.app-draggable-list-item {
|
|
178
|
+
cursor: grab;
|
|
179
|
+
}
|
|
10
180
|
|
|
11
|
-
|
|
12
|
-
|
|
181
|
+
.app-draggable-list-item label {
|
|
182
|
+
margin-bottom: 0;
|
|
183
|
+
}
|
|
13
184
|
</style>
|
|
@@ -1,79 +1,110 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<label class="
|
|
3
|
-
|
|
4
|
-
<input
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
<label class="wrapper flex items-center">
|
|
3
|
+
{{ label }}
|
|
4
|
+
<input
|
|
5
|
+
class="checkbox"
|
|
6
|
+
type="radio"
|
|
7
|
+
:checked="isChecked"
|
|
8
|
+
:value="value"
|
|
9
|
+
@change="$emit('change', $event.target.value)"
|
|
10
|
+
/>
|
|
11
|
+
<span class="checkmark" :class="{ 'checkmark-small': small }"></span>
|
|
12
|
+
</label>
|
|
7
13
|
</template>
|
|
8
14
|
|
|
9
15
|
<script>
|
|
10
16
|
export default {
|
|
11
17
|
name: 'PsRadioButton',
|
|
12
|
-
props:
|
|
18
|
+
props: {
|
|
19
|
+
label: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: '',
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
modelValue: {
|
|
25
|
+
default: '',
|
|
26
|
+
},
|
|
27
|
+
value: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: undefined,
|
|
30
|
+
},
|
|
31
|
+
small: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
model: {
|
|
37
|
+
prop: 'modelValue',
|
|
38
|
+
event: 'change',
|
|
39
|
+
},
|
|
13
40
|
computed: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
set: function() {
|
|
19
|
-
this.$emit("change", this.value)
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
41
|
+
isChecked() {
|
|
42
|
+
return this.modelValue == this.value
|
|
43
|
+
},
|
|
44
|
+
},
|
|
23
45
|
}
|
|
24
46
|
</script>
|
|
25
47
|
|
|
26
48
|
<style scoped>
|
|
27
|
-
.
|
|
49
|
+
.wrapper {
|
|
28
50
|
display: block;
|
|
29
51
|
position: relative;
|
|
30
|
-
padding-left:
|
|
52
|
+
padding-left: 32px;
|
|
31
53
|
cursor: pointer;
|
|
32
54
|
-webkit-user-select: none;
|
|
33
55
|
-moz-user-select: none;
|
|
34
56
|
-ms-user-select: none;
|
|
35
57
|
user-select: none;
|
|
36
58
|
}
|
|
37
|
-
|
|
38
|
-
.form-control input {
|
|
59
|
+
.wrapper input {
|
|
39
60
|
position: absolute;
|
|
40
61
|
opacity: 0;
|
|
41
62
|
cursor: pointer;
|
|
63
|
+
height: 0;
|
|
64
|
+
width: 0;
|
|
42
65
|
}
|
|
43
|
-
|
|
44
|
-
.radio-button {
|
|
66
|
+
.checkmark {
|
|
45
67
|
position: absolute;
|
|
46
68
|
top: 0;
|
|
47
69
|
left: 0;
|
|
48
|
-
height:
|
|
49
|
-
width:
|
|
50
|
-
background-color: #FFF;
|
|
51
|
-
border: 2px solid #A2ACB7;
|
|
70
|
+
height: 24px;
|
|
71
|
+
width: 24px;
|
|
52
72
|
border-radius: 50%;
|
|
73
|
+
background-color: white;
|
|
74
|
+
border: 2px solid #a2acb7;
|
|
53
75
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
76
|
+
.checkmark-small {
|
|
77
|
+
top: 3px;
|
|
78
|
+
height: 18px !important;
|
|
79
|
+
width: 18px !important;
|
|
58
80
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
81
|
+
.wrapper input:checked ~ .checkmark {
|
|
82
|
+
background-color: white;
|
|
83
|
+
border-color: #64b5ce;
|
|
84
|
+
border-width: 2px;
|
|
85
|
+
}
|
|
86
|
+
.checkmark:after {
|
|
87
|
+
content: '';
|
|
62
88
|
position: absolute;
|
|
63
89
|
display: none;
|
|
64
90
|
}
|
|
65
|
-
|
|
66
|
-
.form-control input:checked ~ .radio-button:after {
|
|
91
|
+
.wrapper input:checked ~ .checkmark:after {
|
|
67
92
|
display: block;
|
|
68
93
|
}
|
|
69
|
-
|
|
70
|
-
|
|
94
|
+
.wrapper .checkmark:after {
|
|
95
|
+
top: 4px;
|
|
96
|
+
left: 4px;
|
|
97
|
+
width: 12px;
|
|
98
|
+
height: 12px;
|
|
99
|
+
border-radius: 50%;
|
|
100
|
+
background: #64b5ce;
|
|
101
|
+
}
|
|
102
|
+
.wrapper .checkmark-small:after {
|
|
71
103
|
top: 3px;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
background
|
|
104
|
+
left: 3px;
|
|
105
|
+
width: 8px;
|
|
106
|
+
height: 8px;
|
|
107
|
+
border-radius: 50%;
|
|
108
|
+
background: #64b5ce;
|
|
77
109
|
}
|
|
78
|
-
|
|
79
|
-
</style>
|
|
110
|
+
</style>
|
|
@@ -1,98 +1,97 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
<div class="switch-button-control">
|
|
3
|
+
<div
|
|
4
|
+
:class="{ enabled: active, 'switch-button': !small, 'switch-button-small': small }"
|
|
5
|
+
@click="toggle"
|
|
6
|
+
:style="{'--color': color}"
|
|
7
|
+
>
|
|
8
|
+
<div class="button"></div>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="switch-button-label">
|
|
11
|
+
<slot></slot>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
10
14
|
</template>
|
|
11
15
|
|
|
12
16
|
<script>
|
|
13
|
-
export const sizes = ['big', 'small']
|
|
14
17
|
export default {
|
|
15
18
|
name: 'PsSwitch',
|
|
16
19
|
props: {
|
|
17
|
-
|
|
18
|
-
active:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
default: false
|
|
25
|
-
},
|
|
26
|
-
size: {
|
|
27
|
-
type: String,
|
|
28
|
-
default: 'big',
|
|
29
|
-
validator: (value) => sizes.indexOf(value) !== -1
|
|
30
|
-
}
|
|
20
|
+
small: Boolean,
|
|
21
|
+
active: Boolean,
|
|
22
|
+
color: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: false,
|
|
25
|
+
default: '#5DB883'
|
|
26
|
+
}
|
|
31
27
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return this.active ? this.labelActived : this.label
|
|
36
|
-
} else if (this.label) {
|
|
37
|
-
return this.label
|
|
38
|
-
} else {
|
|
39
|
-
return false
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
classes() {
|
|
43
|
-
if (this.size === 'small') {
|
|
44
|
-
return 'toggle-bg psui-bg-gray-40 psui-border-gray-40 psui-border-2 psui-h-4 ps-switch-small psui-rounded-full'
|
|
45
|
-
}
|
|
46
|
-
return 'toggle-bg psui-bg-gray-40 psui-border-gray-40 psui-border-2 psui-h-6 ps-switch psui-rounded-full'
|
|
47
|
-
}
|
|
28
|
+
model: {
|
|
29
|
+
prop: "active",
|
|
30
|
+
event: "toggle"
|
|
48
31
|
},
|
|
49
32
|
methods: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.$emit('update:active', !this.active)
|
|
53
|
-
this.$emit('change', !this.active)
|
|
54
|
-
}
|
|
33
|
+
toggle: function() {
|
|
34
|
+
this.$emit('toggle', !this.active)
|
|
55
35
|
}
|
|
56
36
|
}
|
|
57
37
|
}
|
|
58
38
|
</script>
|
|
59
39
|
|
|
60
40
|
<style scoped>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
41
|
+
.switch-button-control {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: row;
|
|
44
|
+
align-items: center;
|
|
64
45
|
}
|
|
65
|
-
.
|
|
66
|
-
|
|
46
|
+
.switch-button-control .switch-button {
|
|
47
|
+
height: 24px;
|
|
48
|
+
width: calc(24px * 2);
|
|
49
|
+
background-color: #A2ACB7;
|
|
50
|
+
border: 2px solid #A2ACB7;
|
|
51
|
+
border-radius: 24px;
|
|
52
|
+
transition: all 0.3s ease-in-out;
|
|
53
|
+
cursor: pointer;
|
|
67
54
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
55
|
+
.switch-button-control .switch-button-small {
|
|
56
|
+
height: 16px;
|
|
57
|
+
width: calc(16px * 2);
|
|
58
|
+
background-color: #A2ACB7;
|
|
59
|
+
border: 2px solid #A2ACB7;
|
|
60
|
+
border-radius: 16px;
|
|
61
|
+
transition: all 0.3s ease-in-out;
|
|
62
|
+
cursor: pointer;
|
|
75
63
|
}
|
|
76
|
-
.
|
|
77
|
-
|
|
78
|
-
|
|
64
|
+
.switch-button-control .switch-button .button {
|
|
65
|
+
height: calc(24px - (2 * 2px));
|
|
66
|
+
width: calc(24px - (2 * 2px));
|
|
67
|
+
border-radius: calc(24px - (2 * 2px));
|
|
68
|
+
background:#F3F6F9;
|
|
69
|
+
transition: all 0.3s ease-in-out;
|
|
79
70
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
71
|
+
.switch-button-control .switch-button-small .button {
|
|
72
|
+
height: calc(16px - (2 * 2px));
|
|
73
|
+
width: calc(16px - (2 * 2px));
|
|
74
|
+
border-radius: calc(16px - (2 * 2px));
|
|
75
|
+
background:#F3F6F9;
|
|
76
|
+
transition: all 0.3s ease-in-out;
|
|
86
77
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
position: absolute;
|
|
91
|
-
left: 4px;
|
|
92
|
-
@apply border-white;
|
|
78
|
+
.switch-button-control .switch-button.enabled {
|
|
79
|
+
background-color: var(--color);
|
|
80
|
+
border: 2px solid var(--color);
|
|
93
81
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
82
|
+
.switch-button-control .switch-button-small.enabled {
|
|
83
|
+
background-color: var(--color);
|
|
84
|
+
border: 2px solid var(--color);
|
|
85
|
+
}
|
|
86
|
+
.switch-button-control .switch-button.enabled .button {
|
|
87
|
+
background: white;
|
|
88
|
+
transform: translateX(calc(calc(24px - (2 * 2px)) + (2 *2px)));
|
|
89
|
+
}
|
|
90
|
+
.switch-button-control .switch-button-small.enabled .button {
|
|
91
|
+
background: white;
|
|
92
|
+
transform: translateX(calc(calc(16px - (2 * 2px)) + (2 *2px)));
|
|
93
|
+
}
|
|
94
|
+
.switch-button-control .switch-button-label {
|
|
95
|
+
margin-left: 10px;
|
|
96
|
+
}
|
|
97
|
+
</style>
|