@eturnity/eturnity_reusable_components 7.4.4-EPDM-9606 → 7.4.4-EPDM-7260.3

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,104 @@
1
+ <template>
2
+ <label-wrapper
3
+ :labelAlign="labelAlign">
4
+ <input-label
5
+ :labelFontColor="labelFontColor"
6
+ :fontSize="fontSize"
7
+ >
8
+ <slot></slot>
9
+ <optionalLabel v-if="labelOptional"
10
+ >({{ $gettext('Optional') }})</optionalLabel
11
+ ></input-label
12
+ >
13
+ <info-text
14
+ v-if="infoTextMessage"
15
+ :text="infoTextMessage"
16
+ borderColor="#ccc"
17
+ :size="fontSize ? fontSize : '16px'"
18
+ :alignArrow="infoTextAlign"
19
+ />
20
+ </label-wrapper>
21
+ </template>
22
+
23
+ <script>
24
+ import styled from 'vue-styled-components'
25
+ import InfoText from '../infoText'
26
+
27
+
28
+ const labelAttrs = { fontSize: String, labelFontColor: String }
29
+ const InputLabel = styled('div', labelAttrs)`
30
+ color: ${(props) =>
31
+ props.theme.colors[props.labelFontColor]
32
+ ? props.theme.colors[props.labelFontColor]
33
+ : props.labelFontColor
34
+ ? props.labelFontColor
35
+ : props.theme.colors.eturnityGrey};
36
+
37
+ font-size: ${(props) => (props.fontSize ? props.fontSize : '13px')};
38
+ font-weight: 700;
39
+ `
40
+ const optionalLabel = styled.span`
41
+ font-weight: 300;
42
+ `
43
+
44
+ const LabelWrapper = styled('div',{labelAlign:String})`
45
+ ${props=>props.labelAlign=='horizontal'?
46
+ 'display: inline-grid;':
47
+ 'display: grid;'
48
+ }
49
+ ${props=>props.labelAlign=='horizontal'?
50
+ 'margin-right: 10px;':
51
+ 'margin-bottom: 8px;'
52
+ }
53
+ vertical-align: center;
54
+ grid-template-columns: auto auto;
55
+ grid-gap: 12px;
56
+ align-items: center;
57
+ justify-content: start;
58
+ `
59
+ export default {
60
+ // import labelText from "@eturnity/eturnity_reusable_components/src/components/label"
61
+ // To use:
62
+ // <label-text
63
+ // infoTextAlign="right" // left by default
64
+ // infoTextMessage="My info message"
65
+ // label="Question 5"
66
+ // />
67
+ name: 'input-text',
68
+ components: {
69
+ InfoText,
70
+ InputLabel,
71
+ LabelWrapper,
72
+ optionalLabel
73
+ },
74
+ data() {
75
+ return {
76
+ inputTypeData: 'text'
77
+ }
78
+ },
79
+ props: {
80
+ infoTextMessage: {
81
+ required: false
82
+ },
83
+ infoTextAlign: {
84
+ required: false
85
+ },
86
+ labelOptional: {
87
+ required: false,
88
+ default: false
89
+ },
90
+ fontSize: {
91
+ required: false,
92
+ default: null
93
+ },
94
+ labelFontColor: {
95
+ required: false,
96
+ default: 'black'
97
+ },
98
+ labelAlign: {
99
+ required: false,
100
+ default: 'vertical'
101
+ },
102
+ },
103
+ }
104
+ </script>
@@ -3,7 +3,6 @@
3
3
  :position="position"
4
4
  :isOpen="isOpen"
5
5
  :class="{ visible: isOpen, hidden: !isOpen }"
6
- @click.native="onOutsideClose()"
7
6
  :backdrop="backdrop"
8
7
  >
9
8
  <modal-container @click.stop>
@@ -27,7 +26,7 @@
27
26
  // import Modal from "@eturnity/eturnity_reusable_components/src/components/modals/modal"
28
27
  // This is a more flexible modal box, where the parent can decide how the body of the modal looks
29
28
  // To use:
30
- // <modal :isOpen="isOpen" @on-close="$emit('on-close-summary')" :preventOutsideClose="true" :isLoading="true" :hideClose="true">
29
+ // <modal :isOpen="isOpen" @on-close="$emit('on-close-summary')" :isLoading="true" :hideClose="true">
31
30
  // <div>Data....</div>
32
31
  // </modal>
33
32
 
@@ -86,6 +85,22 @@ const ModalContainer = styled.div`
86
85
  min-width: 100px;
87
86
  min-height: 100px;
88
87
 
88
+ ::-webkit-scrollbar {
89
+ width: 0.3em;
90
+ height: 100%;
91
+ background-color: ${(props) => props.theme.colors.grey5};
92
+ }
93
+
94
+ /* Make scrollbar visible when needed */
95
+ ::-webkit-scrollbar-thumb {
96
+ background-color: ${(props) => props.theme.colors.grey3};
97
+ }
98
+
99
+ /* Make scrollbar track visible when needed */
100
+ ::-webkit-scrollbar-track {
101
+ background-color: ${(props) => props.theme.colors.grey5};
102
+ }
103
+
89
104
  .close {
90
105
  position: absolute;
91
106
  right: 20px;
@@ -121,10 +136,6 @@ export default {
121
136
  required: true,
122
137
  default: false
123
138
  },
124
- preventOutsideClose: {
125
- required: false,
126
- default: false
127
- },
128
139
  isLoading: {
129
140
  required: false,
130
141
  default: false
@@ -142,20 +153,30 @@ export default {
142
153
  default: 'fixed'
143
154
  }
144
155
  },
156
+ beforeDestroy() {
157
+ window.removeEventListener('keydown', this.handleKeyDown)
158
+ },
145
159
  methods: {
146
160
  onCloseModal() {
147
161
  this.$emit('on-close')
148
162
  },
149
- onOutsideClose() {
150
- // If true, then only allow closing to come from clicking the X or wherever the onCloseModal is called
151
- if (!this.preventOutsideClose) {
152
- this.$emit('on-close')
163
+ handleKeyDown({ key }) {
164
+ if (key === 'Escape') {
165
+ this.onCloseModal()
153
166
  }
154
167
  }
155
168
  },
156
169
  watch: {
157
- isOpen: function (newVal) {
158
- document.body.style.overflow = newVal ? 'hidden' : ''
170
+ isOpen: {
171
+ immediate: true,
172
+ handler(isOpen) {
173
+ document.body.style.overflow = isOpen ? 'hidden' : ''
174
+ if (isOpen) {
175
+ window.addEventListener('keydown', this.handleKeyDown)
176
+ } else {
177
+ window.removeEventListener('keydown', this.handleKeyDown)
178
+ }
179
+ }
159
180
  }
160
181
  }
161
182
  }