@eturnity/eturnity_reusable_components 1.0.13 → 1.0.17

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.
@@ -0,0 +1,195 @@
1
+ <template>
2
+ <page-wrapper>
3
+ <title-text>
4
+ {{ tableTitle }}
5
+ </title-text>
6
+ <table-scroll>
7
+ <table-wrapper :fullWidth="fullWidth">
8
+ <spinner-wrapper v-if="isLoading">
9
+ <spinner />
10
+ </spinner-wrapper>
11
+ <table-container v-else>
12
+ <thead>
13
+ <tr>
14
+ <table-header v-for="(item, index) in headerItems" :key="index">
15
+ {{ item.value }}
16
+ </table-header>
17
+ <div v-if="showIconsContainer && tableItems.length" />
18
+ </tr>
19
+ </thead>
20
+ <tbody>
21
+ <empty-td colspan="100" v-if="!tableItems.length && !isLoading">
22
+ <empty-container>
23
+ {{ emptyText }}
24
+ </empty-container>
25
+ </empty-td>
26
+ <table-row v-for="(row, index) in tableItems" :key="index" v-else>
27
+ <table-item v-for="(item, idx) in row" :key="idx">
28
+ {{ item.value }}
29
+ </table-item>
30
+ <icons-container v-if="showIconsContainer">
31
+ <delete-icon
32
+ @click.native="$emit('on-click-delete', index)"
33
+ color="gray"
34
+ />
35
+ </icons-container>
36
+ </table-row>
37
+ </tbody>
38
+ </table-container>
39
+ </table-wrapper>
40
+ </table-scroll>
41
+ </page-wrapper>
42
+ </template>
43
+
44
+ <script>
45
+ // This is a read only table. Pass it data, and it displays it
46
+ // ToDo: add this to storybook
47
+ // import ViewTable from "@eturnity/eturnity_reusable_components/src/components/tables/viewTable"
48
+ import styled from "vue-styled-components"
49
+ import DeleteIcon from "../../deleteIcon"
50
+ import Spinner from "../../spinner"
51
+
52
+ const TableScroll = styled.div`
53
+ position: relative;
54
+ max-width: 100%;
55
+ `
56
+
57
+ const wrapperAttrs = { fullWidth: Boolean }
58
+ const TableWrapper = styled("div", wrapperAttrs)`
59
+ width: ${(props) => (props.fullWidth ? "100%" : "fit-content")};
60
+ max-width: 100%;
61
+ overflow: auto;
62
+
63
+ ::-webkit-scrollbar {
64
+ width: 10px; //width of the whole scrollbar area
65
+ }
66
+
67
+ track ::-webkit-scrollbar-track {
68
+ background: #fff;
69
+ }
70
+
71
+ ::-webkit-scrollbar-thumb {
72
+ border-bottom: 2px solid ${(props) => props.theme.colors.grey3}; // width of the actual scrollbar
73
+ }
74
+ `
75
+
76
+ const TableContainer = styled.table`
77
+ width: 100%;
78
+ border-collapse: collapse;
79
+ border: none;
80
+ `
81
+
82
+ const TableItem = styled.td`
83
+ border: 1px solid ${(props) => props.theme.colors.grey3};
84
+ width: auto;
85
+ white-space: nowrap;
86
+ padding: 12px;
87
+ text-align: right;
88
+ `
89
+
90
+ const TableHeader = styled(TableItem)`
91
+ background-color: #e6e8ee;
92
+ font-family: "Lato-Bold", Arial;
93
+ text-align: left;
94
+ `
95
+
96
+ const TableRow = styled.tr`
97
+ &:hover {
98
+ background-color: #f5f7fa;
99
+ cursor: pointer;
100
+ }
101
+ `
102
+
103
+ const TitleText = styled.div`
104
+ font-family: "Lato-Bold", Arial;
105
+ margin-bottom: 6px;
106
+ `
107
+
108
+ const PageWrapper = styled.div`
109
+ margin: 16px 0;
110
+ font-size: 13px;
111
+ `
112
+
113
+ const IconsContainer = styled.div`
114
+ width: 100%;
115
+ display: inline-flex;
116
+ flex-wrap: nowrap;
117
+ background-color: #fff;
118
+
119
+ &:hover {
120
+ background-color: #fff;
121
+ }
122
+ `
123
+
124
+ const SpinnerWrapper = styled.div`
125
+ border: 1px solid ${(props) => props.theme.colors.grey3};
126
+ height: 150px;
127
+ display: grid;
128
+ align-items: center;
129
+ justify-items: center;
130
+ `
131
+
132
+ const EmptyContainer = styled.div`
133
+ display: grid;
134
+ align-items: center;
135
+ justify-items: center;
136
+ height: 100px;
137
+ `
138
+
139
+ const EmptyTd = styled.td`
140
+ border: 1px solid ${(props) => props.theme.colors.grey3};
141
+ `
142
+
143
+ export default {
144
+ name: "view-table",
145
+ components: {
146
+ TableScroll,
147
+ TableWrapper,
148
+ TableContainer,
149
+ TableHeader,
150
+ TableItem,
151
+ TableRow,
152
+ TitleText,
153
+ PageWrapper,
154
+ DeleteIcon,
155
+ IconsContainer,
156
+ Spinner,
157
+ SpinnerWrapper,
158
+ EmptyContainer,
159
+ EmptyTd,
160
+ },
161
+ props: {
162
+ headerItems: {
163
+ required: true,
164
+ },
165
+ tableItems: {
166
+ required: true,
167
+ },
168
+ fullWidth: {
169
+ required: false,
170
+ default: true,
171
+ },
172
+ tableTitle: {
173
+ required: false,
174
+ default: null,
175
+ },
176
+ showDeleteButton: {
177
+ required: false,
178
+ default: false,
179
+ },
180
+ isLoading: {
181
+ required: false,
182
+ default: false,
183
+ },
184
+ emptyText: {
185
+ required: false,
186
+ default: "There are no items",
187
+ },
188
+ },
189
+ computed: {
190
+ showIconsContainer() {
191
+ return this.showDeleteButton
192
+ },
193
+ },
194
+ }
195
+ </script>
@@ -0,0 +1,157 @@
1
+ <template>
2
+ <page-container>
3
+ <button-container @click="toggleButton()">
4
+ <dot-item />
5
+ <dot-item />
6
+ <dot-item />
7
+ </button-container>
8
+ <options-container v-if="isOpen">
9
+ <option-item
10
+ v-for="item in options"
11
+ :key="item.value"
12
+ tabindex="0"
13
+ @click="onSelect(item.value)"
14
+ @keyup.enter="onSelect(item.value)"
15
+ >
16
+ {{ item.name }}
17
+ </option-item>
18
+ </options-container>
19
+ </page-container>
20
+ </template>
21
+
22
+ <script>
23
+ // import ThreeDots from "@eturnity/eturnity_reusable_components/src/components/threeDots"
24
+ // To use:
25
+ // <three-dots
26
+ // :options="listOptions"
27
+ // @on-select="onSelect($event)"
28
+ // />
29
+ // options to pass:
30
+ // listOptions: [
31
+ // {
32
+ // name: "Option 1",
33
+ // value: "option_1",
34
+ // },
35
+ // {
36
+ // name: "Option 2",
37
+ // value: "option_2",
38
+ // },
39
+ // {
40
+ // name: "Option 3",
41
+ // value: "option_3",
42
+ // },
43
+ // {
44
+ // name: "Option 4",
45
+ // value: "option_4",
46
+ // }
47
+ // ],
48
+
49
+ import styled from "vue-styled-components"
50
+
51
+ const PageContainer = styled.div`
52
+ position: relative;
53
+ display: grid;
54
+ align-items: center;
55
+ `
56
+
57
+ const ButtonContainer = styled.div`
58
+ display: flex;
59
+ flex-direction: column;
60
+ padding: 5px;
61
+ cursor: pointer;
62
+
63
+ div {
64
+ // This is the dot color
65
+ background-color: #263238;
66
+ }
67
+
68
+ &:hover {
69
+ div {
70
+ // Dot color on hover
71
+ background-color: ${(props) => props.theme.colors.grey3};
72
+ }
73
+ }
74
+ `
75
+
76
+ const DotItem = styled.div`
77
+ width: 4px;
78
+ height: 4px;
79
+ margin: 1px;
80
+ border-radius: 50%;
81
+ `
82
+
83
+ const OptionsContainer = styled.div`
84
+ z-index: 99;
85
+ position: absolute;
86
+ right: 0;
87
+ border: 1px solid
88
+ ${(props) =>
89
+ props.buttonColor ? props.buttonColor : props.theme.colors.grey3};
90
+ display: grid;
91
+ grid-template-columns: 1fr;
92
+ min-width: 200px;
93
+ width: max-content;
94
+ border-radius: 4px;
95
+ background-color: #fff;
96
+ margin-top: 8px;
97
+ max-height: 220px;
98
+ overflow: auto;
99
+ `
100
+
101
+ const OptionItem = styled.div`
102
+ padding: 12px;
103
+ cursor: pointer;
104
+ font-size: 13px;
105
+
106
+ &:hover {
107
+ background-color: #ebeef4;
108
+ }
109
+
110
+ &:focus-visible {
111
+ outline: none;
112
+ background-color: #ebeef4;
113
+ }
114
+ `
115
+
116
+ export default {
117
+ name: "three-dots",
118
+ components: {
119
+ PageContainer,
120
+ ButtonContainer,
121
+ DotItem,
122
+ OptionsContainer,
123
+ OptionItem,
124
+ },
125
+ props: {
126
+ options: {
127
+ required: true,
128
+ },
129
+ },
130
+ data() {
131
+ return {
132
+ isOpen: false,
133
+ }
134
+ },
135
+ methods: {
136
+ toggleButton() {
137
+ this.isOpen = !this.isOpen
138
+
139
+ if (this.isOpen) {
140
+ document.addEventListener("click", this.clickOutside)
141
+ } else {
142
+ document.removeEventListener("click", this.clickOutside)
143
+ }
144
+ },
145
+ onSelect(value) {
146
+ this.$emit("on-select", value)
147
+ this.isOpen = false
148
+ },
149
+ clickOutside(event) {
150
+ if (this.$el.contains(event.target) || !this.isOpen) {
151
+ return
152
+ }
153
+ this.toggleButton()
154
+ },
155
+ },
156
+ }
157
+ </script>
Binary file