@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "1.0.24",
3
+ "version": "1.0.25",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
package/src/App.vue CHANGED
@@ -19,9 +19,10 @@
19
19
  </tr>
20
20
  </tbody>
21
21
  </main-table>
22
- <checkbox
22
+ <toggle
23
+ @on-toggle-change="isChecked = $event"
23
24
  :isChecked="isChecked"
24
- @on-event-handler="isChecked = $event"
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 Checkbox from "@/components/inputs/checkbox"
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
- Checkbox,
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 :isChecked="isChecked" :toggleColor="toggleColor" />
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>{{ label }}</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 LabelText = styled.div`
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.span`
66
+ const ToggleWrapper = styled("span", toggleAttrs)`
47
67
  display: inline-block;
48
68
  position: relative;
49
69
  cursor: pointer;
50
- width: 50px;
51
- height: 24px;
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 ToggleBackground = styled.span`
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) => props.theme.colors.lightGray};
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: 14px;
77
- width: 14px;
78
- left: 5px;
79
- bottom: 5px;
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 ? "translateX(26px)" : "translateX(0)"};
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() {