@eturnity/eturnity_reusable_components 1.0.24 → 1.0.25
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/package.json +1 -1
- package/src/App.vue +5 -4
- package/src/components/inputs/toggle/index.vue +77 -15
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -19,9 +19,10 @@
|
|
|
19
19
|
</tr>
|
|
20
20
|
</tbody>
|
|
21
21
|
</main-table>
|
|
22
|
-
<
|
|
22
|
+
<toggle
|
|
23
|
+
@on-toggle-change="isChecked = $event"
|
|
23
24
|
:isChecked="isChecked"
|
|
24
|
-
|
|
25
|
+
label="My Label Text"
|
|
25
26
|
size="small"
|
|
26
27
|
/>
|
|
27
28
|
</page-container>
|
|
@@ -33,7 +34,7 @@ import { ThemeProvider } from "vue-styled-components"
|
|
|
33
34
|
import theme from "./assets/theme"
|
|
34
35
|
import styled from "vue-styled-components"
|
|
35
36
|
import MainTable from "@/components/tables/mainTable"
|
|
36
|
-
import
|
|
37
|
+
import Toggle from "@/components/inputs/toggle"
|
|
37
38
|
|
|
38
39
|
const PageContainer = styled.div`
|
|
39
40
|
padding: 40px;
|
|
@@ -45,7 +46,7 @@ export default {
|
|
|
45
46
|
ThemeProvider,
|
|
46
47
|
PageContainer,
|
|
47
48
|
MainTable,
|
|
48
|
-
|
|
49
|
+
Toggle,
|
|
49
50
|
},
|
|
50
51
|
data() {
|
|
51
52
|
return {
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<container>
|
|
3
3
|
<flex-wrapper>
|
|
4
|
+
<label-text v-if="labelAlign === 'left'" :size="size">{{
|
|
5
|
+
label
|
|
6
|
+
}}</label-text>
|
|
4
7
|
<toggle-wrapper
|
|
5
8
|
role="checkbox"
|
|
6
9
|
:checked="isChecked"
|
|
10
|
+
:size="size"
|
|
7
11
|
tabindex="0"
|
|
8
12
|
@click="onToggleChange"
|
|
9
13
|
@keydown.space.prevent="onToggleChange"
|
|
10
14
|
>
|
|
11
|
-
<toggle-background />
|
|
12
|
-
<toggle-dot
|
|
15
|
+
<toggle-background :backgroundColor="backgroundColor" />
|
|
16
|
+
<toggle-dot
|
|
17
|
+
:isChecked="isChecked"
|
|
18
|
+
:toggleColor="toggleColor"
|
|
19
|
+
:size="size"
|
|
20
|
+
/>
|
|
13
21
|
</toggle-wrapper>
|
|
14
|
-
<label-text>{{
|
|
22
|
+
<label-text v-if="labelAlign === 'right'" :size="size">{{
|
|
23
|
+
label
|
|
24
|
+
}}</label-text>
|
|
15
25
|
</flex-wrapper>
|
|
16
26
|
</container>
|
|
17
27
|
</template>
|
|
@@ -24,6 +34,9 @@
|
|
|
24
34
|
// :isChecked="toggleValue" // Boolean
|
|
25
35
|
// label="My Label Text"
|
|
26
36
|
// toggleColor="red"
|
|
37
|
+
// size="small" // small, medium
|
|
38
|
+
// backgroundColor="blue"
|
|
39
|
+
// labelAlign="right"
|
|
27
40
|
// />
|
|
28
41
|
|
|
29
42
|
import styled from "vue-styled-components"
|
|
@@ -39,16 +52,33 @@ const FlexWrapper = styled.div`
|
|
|
39
52
|
align-items: center;
|
|
40
53
|
`
|
|
41
54
|
|
|
42
|
-
const
|
|
55
|
+
const toggleAttrs = { size: String }
|
|
56
|
+
const LabelText = styled("div", toggleAttrs)`
|
|
43
57
|
color: ${(props) => props.theme.colors.darkGray};
|
|
58
|
+
font-size: ${(props) =>
|
|
59
|
+
props.size === "medium"
|
|
60
|
+
? "16px"
|
|
61
|
+
: props.size === "small"
|
|
62
|
+
? "12px"
|
|
63
|
+
: "16px"};
|
|
44
64
|
`
|
|
45
65
|
|
|
46
|
-
const ToggleWrapper = styled
|
|
66
|
+
const ToggleWrapper = styled("span", toggleAttrs)`
|
|
47
67
|
display: inline-block;
|
|
48
68
|
position: relative;
|
|
49
69
|
cursor: pointer;
|
|
50
|
-
width:
|
|
51
|
-
|
|
70
|
+
width: ${(props) =>
|
|
71
|
+
props.size === "medium"
|
|
72
|
+
? "50px"
|
|
73
|
+
: props.size === "small"
|
|
74
|
+
? "29px"
|
|
75
|
+
: "50px"};
|
|
76
|
+
height: ${(props) =>
|
|
77
|
+
props.size === "medium"
|
|
78
|
+
? "24px"
|
|
79
|
+
: props.size === "small"
|
|
80
|
+
? "16px"
|
|
81
|
+
: "24px"};
|
|
52
82
|
border-radius: 9px;
|
|
53
83
|
|
|
54
84
|
&:focus {
|
|
@@ -61,22 +91,37 @@ const ToggleWrapper = styled.span`
|
|
|
61
91
|
}
|
|
62
92
|
`
|
|
63
93
|
|
|
64
|
-
const
|
|
94
|
+
const backroundAttrs = { backgroundColor: String }
|
|
95
|
+
const ToggleBackground = styled("span", backroundAttrs)`
|
|
65
96
|
display: inline-block;
|
|
66
97
|
border-radius: 100px;
|
|
67
98
|
height: 100%;
|
|
68
99
|
width: 100%;
|
|
69
|
-
background-color: ${(props) =>
|
|
100
|
+
background-color: ${(props) =>
|
|
101
|
+
props.backgroundColor
|
|
102
|
+
? props.backgroundColor
|
|
103
|
+
: props.theme.colors.lightGray};
|
|
70
104
|
transition: 0.4s ease;
|
|
71
105
|
`
|
|
72
106
|
|
|
73
|
-
const toggleProps = { isChecked: Boolean, toggleColor: String }
|
|
107
|
+
const toggleProps = { isChecked: Boolean, toggleColor: String, size: String }
|
|
74
108
|
const ToggleDot = styled("span", toggleProps)`
|
|
75
109
|
position: absolute;
|
|
76
|
-
height:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
110
|
+
height: ${(props) =>
|
|
111
|
+
props.size === "medium"
|
|
112
|
+
? "14px"
|
|
113
|
+
: props.size === "small"
|
|
114
|
+
? "10px"
|
|
115
|
+
: "14px"};
|
|
116
|
+
width: ${(props) =>
|
|
117
|
+
props.size === "medium"
|
|
118
|
+
? "14px"
|
|
119
|
+
: props.size === "small"
|
|
120
|
+
? "10px"
|
|
121
|
+
: "14px"};
|
|
122
|
+
left: 5px
|
|
123
|
+
bottom: ${(props) =>
|
|
124
|
+
props.size === "medium" ? "5px" : props.size === "small" ? "3px" : "5px"};
|
|
80
125
|
background-color: ${(props) =>
|
|
81
126
|
props.isChecked
|
|
82
127
|
? props.toggleColor
|
|
@@ -86,7 +131,13 @@ const ToggleDot = styled("span", toggleProps)`
|
|
|
86
131
|
border-radius: 100%;
|
|
87
132
|
transition: transform 0.4s ease;
|
|
88
133
|
transform: ${(props) =>
|
|
89
|
-
props.isChecked
|
|
134
|
+
props.isChecked
|
|
135
|
+
? props.size === "medium"
|
|
136
|
+
? "translateX(45px)"
|
|
137
|
+
: props.size === "small"
|
|
138
|
+
? "translateX(10px)"
|
|
139
|
+
: "translateX(45px)"
|
|
140
|
+
: "translateX(0)"};
|
|
90
141
|
|
|
91
142
|
@media (max-width: ${(props) => props.theme.screen.mobile}) {
|
|
92
143
|
height: 24px;
|
|
@@ -119,6 +170,17 @@ export default {
|
|
|
119
170
|
toggleColor: {
|
|
120
171
|
required: false,
|
|
121
172
|
},
|
|
173
|
+
backgroundColor: {
|
|
174
|
+
required: false,
|
|
175
|
+
},
|
|
176
|
+
size: {
|
|
177
|
+
required: false,
|
|
178
|
+
default: "medium",
|
|
179
|
+
},
|
|
180
|
+
labelAlign: {
|
|
181
|
+
required: false,
|
|
182
|
+
default: "right",
|
|
183
|
+
},
|
|
122
184
|
},
|
|
123
185
|
methods: {
|
|
124
186
|
onToggleChange() {
|