@eturnity/eturnity_reusable_components 1.0.24 → 1.0.28

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.28",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
package/src/App.vue CHANGED
@@ -8,6 +8,7 @@
8
8
  <th>Column 2</th>
9
9
  <th>Column 3</th>
10
10
  <th>Column 4</th>
11
+ <div />
11
12
  </tr>
12
13
  </thead>
13
14
  <tbody>
@@ -16,14 +17,12 @@
16
17
  <td class="text">Body 2</td>
17
18
  <td class="text">Body 3</td>
18
19
  <td class="text">Body 4</td>
20
+ <div class="icons-container">
21
+ <three-dots :options="listOptions" />
22
+ </div>
19
23
  </tr>
20
24
  </tbody>
21
25
  </main-table>
22
- <checkbox
23
- :isChecked="isChecked"
24
- @on-event-handler="isChecked = $event"
25
- size="small"
26
- />
27
26
  </page-container>
28
27
  </ThemeProvider>
29
28
  </template>
@@ -33,7 +32,7 @@ import { ThemeProvider } from "vue-styled-components"
33
32
  import theme from "./assets/theme"
34
33
  import styled from "vue-styled-components"
35
34
  import MainTable from "@/components/tables/mainTable"
36
- import Checkbox from "@/components/inputs/checkbox"
35
+ import ThreeDots from "@/components/threeDots"
37
36
 
38
37
  const PageContainer = styled.div`
39
38
  padding: 40px;
@@ -45,7 +44,7 @@ export default {
45
44
  ThemeProvider,
46
45
  PageContainer,
47
46
  MainTable,
48
- Checkbox,
47
+ ThreeDots,
49
48
  },
50
49
  data() {
51
50
  return {
@@ -58,6 +57,38 @@ export default {
58
57
  unit_short_name: "cm",
59
58
  },
60
59
  isChecked: false,
60
+ listOptions: [
61
+ {
62
+ name: "Option 1",
63
+ value: "option_1",
64
+ children: [
65
+ {
66
+ name: "Option 1 Child",
67
+ value: "option_1_child",
68
+ },
69
+ {
70
+ name: "Option 2 Child",
71
+ value: "option_2_child",
72
+ },
73
+ {
74
+ name: "Option 3 Child",
75
+ value: "option_3_child",
76
+ },
77
+ ],
78
+ },
79
+ {
80
+ name: "Option 2",
81
+ value: "option_2",
82
+ },
83
+ {
84
+ name: "Option 3",
85
+ value: "option_3",
86
+ },
87
+ {
88
+ name: "Option 4",
89
+ value: "option_4",
90
+ },
91
+ ],
61
92
  }
62
93
  },
63
94
  methods: {
@@ -6,6 +6,7 @@
6
6
  :isError="isError"
7
7
  :rows="rowHeight"
8
8
  :value="value"
9
+ :disabled="isDisabled"
9
10
  @input="onChangeHandler"
10
11
  />
11
12
  </input-wrapper>
@@ -96,6 +97,10 @@ export default {
96
97
  errorText: {
97
98
  required: false,
98
99
  },
100
+ isDisabled: {
101
+ required: false,
102
+ default: false,
103
+ },
99
104
  },
100
105
  methods: {
101
106
  onChangeHandler($event) {
@@ -1,17 +1,30 @@
1
1
  <template>
2
2
  <container>
3
- <flex-wrapper>
3
+ <flex-wrapper :size="size">
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
23
+ v-if="labelAlign === 'right'"
24
+ :size="size"
25
+ :fontColor="fontColor"
26
+ >{{ label }}</label-text
27
+ >
15
28
  </flex-wrapper>
16
29
  </container>
17
30
  </template>
@@ -24,6 +37,10 @@
24
37
  // :isChecked="toggleValue" // Boolean
25
38
  // label="My Label Text"
26
39
  // toggleColor="red"
40
+ // size="small" // small, medium
41
+ // backgroundColor="blue"
42
+ // labelAlign="right"
43
+ // fontColor="black"
27
44
  // />
28
45
 
29
46
  import styled from "vue-styled-components"
@@ -32,23 +49,47 @@ const Container = styled.div`
32
49
  display: inline-block;
33
50
  `
34
51
 
35
- const FlexWrapper = styled.div`
52
+ const flexAttrs = { size: String }
53
+ const FlexWrapper = styled("div", flexAttrs)`
36
54
  display: grid;
37
55
  grid-template-columns: auto 1fr;
38
- grid-gap: 20px;
56
+ grid-gap: ${(props) =>
57
+ props.size === "medium"
58
+ ? "20px"
59
+ : props.size === "small"
60
+ ? "10px"
61
+ : "20px"};
39
62
  align-items: center;
40
63
  `
41
64
 
42
- const LabelText = styled.div`
43
- color: ${(props) => props.theme.colors.darkGray};
65
+ const toggleAttrs = { size: String, fontColor: String }
66
+ const LabelText = styled("div", toggleAttrs)`
67
+ color: ${(props) =>
68
+ props.fontColor ? props.fontColor : props.theme.colors.darkGray};
69
+ font-size: ${(props) =>
70
+ props.size === "medium"
71
+ ? "16px"
72
+ : props.size === "small"
73
+ ? "12px"
74
+ : "16px"};
44
75
  `
45
76
 
46
- const ToggleWrapper = styled.span`
77
+ const ToggleWrapper = styled("span", toggleAttrs)`
47
78
  display: inline-block;
48
79
  position: relative;
49
80
  cursor: pointer;
50
- width: 50px;
51
- height: 24px;
81
+ width: ${(props) =>
82
+ props.size === "medium"
83
+ ? "50px"
84
+ : props.size === "small"
85
+ ? "29px"
86
+ : "50px"};
87
+ height: ${(props) =>
88
+ props.size === "medium"
89
+ ? "24px"
90
+ : props.size === "small"
91
+ ? "16px"
92
+ : "24px"};
52
93
  border-radius: 9px;
53
94
 
54
95
  &:focus {
@@ -61,22 +102,37 @@ const ToggleWrapper = styled.span`
61
102
  }
62
103
  `
63
104
 
64
- const ToggleBackground = styled.span`
105
+ const backroundAttrs = { backgroundColor: String }
106
+ const ToggleBackground = styled("span", backroundAttrs)`
65
107
  display: inline-block;
66
108
  border-radius: 100px;
67
109
  height: 100%;
68
110
  width: 100%;
69
- background-color: ${(props) => props.theme.colors.lightGray};
111
+ background-color: ${(props) =>
112
+ props.backgroundColor
113
+ ? props.backgroundColor
114
+ : props.theme.colors.lightGray};
70
115
  transition: 0.4s ease;
71
116
  `
72
117
 
73
- const toggleProps = { isChecked: Boolean, toggleColor: String }
118
+ const toggleProps = { isChecked: Boolean, toggleColor: String, size: String }
74
119
  const ToggleDot = styled("span", toggleProps)`
75
120
  position: absolute;
76
- height: 14px;
77
- width: 14px;
78
- left: 5px;
79
- bottom: 5px;
121
+ height: ${(props) =>
122
+ props.size === "medium"
123
+ ? "14px"
124
+ : props.size === "small"
125
+ ? "10px"
126
+ : "14px"};
127
+ width: ${(props) =>
128
+ props.size === "medium"
129
+ ? "14px"
130
+ : props.size === "small"
131
+ ? "10px"
132
+ : "14px"};
133
+ left: 5px
134
+ bottom: ${(props) =>
135
+ props.size === "medium" ? "5px" : props.size === "small" ? "3px" : "5px"};
80
136
  background-color: ${(props) =>
81
137
  props.isChecked
82
138
  ? props.toggleColor
@@ -86,7 +142,13 @@ const ToggleDot = styled("span", toggleProps)`
86
142
  border-radius: 100%;
87
143
  transition: transform 0.4s ease;
88
144
  transform: ${(props) =>
89
- props.isChecked ? "translateX(26px)" : "translateX(0)"};
145
+ props.isChecked
146
+ ? props.size === "medium"
147
+ ? "translateX(45px)"
148
+ : props.size === "small"
149
+ ? "translateX(10px)"
150
+ : "translateX(45px)"
151
+ : "translateX(0)"};
90
152
 
91
153
  @media (max-width: ${(props) => props.theme.screen.mobile}) {
92
154
  height: 24px;
@@ -119,6 +181,20 @@ export default {
119
181
  toggleColor: {
120
182
  required: false,
121
183
  },
184
+ backgroundColor: {
185
+ required: false,
186
+ },
187
+ size: {
188
+ required: false,
189
+ default: "medium",
190
+ },
191
+ labelAlign: {
192
+ required: false,
193
+ default: "right",
194
+ },
195
+ fontColor: {
196
+ required: false,
197
+ },
122
198
  },
123
199
  methods: {
124
200
  onToggleChange() {
@@ -154,8 +154,8 @@ const TableContainer = styled.table`
154
154
  }
155
155
 
156
156
  .icons-container {
157
- width: 100%;
158
- display: inline-flex;
157
+ width: auto;
158
+ display: table-cell;
159
159
  flex-wrap: nowrap;
160
160
  background-color: #fff;
161
161
  vertical-align: middle;
@@ -7,13 +7,22 @@
7
7
  </button-container>
8
8
  <options-container v-if="isOpen">
9
9
  <option-item
10
- v-for="item in options"
10
+ v-for="(item, index) in options"
11
11
  :key="item.value"
12
12
  tabindex="0"
13
13
  @click="onSelect(item.value)"
14
14
  @keyup.enter="onSelect(item.value)"
15
+ @mouseover="onItemHover(index)"
15
16
  >
16
17
  {{ item.name }}
18
+ <children-container
19
+ class="child"
20
+ v-if="item.children && item.children.length && hoverItem === index"
21
+ >
22
+ <option-child v-for="child in item.children" :key="child.value">
23
+ {{ child.name }}
24
+ </option-child>
25
+ </children-container>
17
26
  </option-item>
18
27
  </options-container>
19
28
  </page-container>
@@ -82,11 +91,9 @@ const DotItem = styled.div`
82
91
 
83
92
  const OptionsContainer = styled.div`
84
93
  z-index: 99;
85
- position: absolute;
86
- right: 0;
87
- border: 1px solid
88
- ${(props) =>
89
- props.buttonColor ? props.buttonColor : props.theme.colors.grey3};
94
+ position: fixed;
95
+ right: 60px;
96
+ border: 1px solid ${(props) => props.theme.colors.grey3};
90
97
  display: grid;
91
98
  grid-template-columns: 1fr;
92
99
  min-width: 200px;
@@ -102,6 +109,7 @@ const OptionItem = styled.div`
102
109
  padding: 12px;
103
110
  cursor: pointer;
104
111
  font-size: 13px;
112
+ position: relative;
105
113
 
106
114
  &:hover {
107
115
  background-color: #ebeef4;
@@ -112,6 +120,37 @@ const OptionItem = styled.div`
112
120
  background-color: #ebeef4;
113
121
  }
114
122
  `
123
+ const OptionChild = styled.div`
124
+ padding: 12px;
125
+ cursor: pointer;
126
+ font-size: 13px;
127
+ position: relative;
128
+
129
+ &:hover {
130
+ background-color: #ebeef4;
131
+ }
132
+
133
+ &:focus-visible {
134
+ outline: none;
135
+ background-color: #ebeef4;
136
+ }
137
+ `
138
+
139
+ const ChildrenContainer = styled.div`
140
+ position: fixed;
141
+ right: 262px;
142
+ border: 1px solid ${(props) => props.theme.colors.grey3};
143
+ border-right: none;
144
+ display: grid;
145
+ grid-template-columns: 1fr;
146
+ min-width: 200px;
147
+ width: max-content;
148
+ border-radius: 4px;
149
+ background-color: #fff;
150
+ margin-top: 8px;
151
+ max-height: 220px;
152
+ overflow: auto;
153
+ `
115
154
 
116
155
  export default {
117
156
  name: "three-dots",
@@ -121,6 +160,8 @@ export default {
121
160
  DotItem,
122
161
  OptionsContainer,
123
162
  OptionItem,
163
+ ChildrenContainer,
164
+ OptionChild,
124
165
  },
125
166
  props: {
126
167
  options: {
@@ -130,6 +171,7 @@ export default {
130
171
  data() {
131
172
  return {
132
173
  isOpen: false,
174
+ hoverItem: null,
133
175
  }
134
176
  },
135
177
  methods: {
@@ -142,6 +184,10 @@ export default {
142
184
  document.removeEventListener("click", this.clickOutside)
143
185
  }
144
186
  },
187
+ onItemHover(index) {
188
+ debugger // eslint-disable-line
189
+ this.hoverItem = index
190
+ },
145
191
  onSelect(value) {
146
192
  this.$emit("on-select", value)
147
193
  this.isOpen = false