@eturnity/eturnity_reusable_components 7.22.4-EPDM-10528.0 → 7.22.4-EPDM-10461.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.
package/babel.config.js CHANGED
@@ -1,3 +1,5 @@
1
1
  module.exports = {
2
- presets: ['@vue/cli-plugin-babel/preset']
2
+ presets: [
3
+ '@vue/cli-plugin-babel/preset'
4
+ ]
3
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "7.22.4-EPDM-10528.0",
3
+ "version": "7.22.4-EPDM-10461.3",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
@@ -23,6 +23,7 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@babel/core": "7.12.16",
26
+ "@babel/eslint-parser": "7.12.16",
26
27
  "@vue/cli-plugin-babel": "5.0.8",
27
28
  "@vue/cli-plugin-eslint": "5.0.8",
28
29
  "@vue/cli-service": "5.0.8",
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <Modal :is-open="isOpen" @on-close="closeModal">
3
+ <modalContainer>
4
+ <modalTitle v-if="$slots.title">
5
+ <slot name="title"></slot>
6
+ </modalTitle>
7
+ <textContainer v-if="$slots.body">
8
+ <slot name="body"></slot>
9
+ </textContainer>
10
+ <buttonContainer v-if="$slots.buttons">
11
+ <slot name="buttons"></slot>
12
+ </buttonContainer>
13
+ </modalContainer>
14
+ </Modal>
15
+ </template>
16
+ <script>
17
+ import styled from 'vue3-styled-components'
18
+ import { mapActions, mapState } from 'vuex'
19
+ import Modal from '../modal'
20
+ const modalContainer = styled.div`
21
+ width: 450px;
22
+ min-height: 205px;
23
+ padding: 40px 40px 30px 40px;
24
+ `
25
+ const modalTitle = styled.div`
26
+ color: ${(props) => props.theme.colors.black};
27
+ font-family: ${(props) => props.theme.fonts.mainFont};
28
+ font-size: 18px;
29
+ font-style: normal;
30
+ font-weight: 700;
31
+ line-height: 120%;
32
+ text-transform: uppercase;
33
+ `
34
+ const buttonContainer = styled.div`
35
+ display: inline-flex;
36
+ align-items: flex-start;
37
+ gap: 20px;
38
+ `
39
+ const textContainer = styled.div`
40
+ color: ${(props) => props.theme.colors.black};
41
+ font-family: ${(props) => props.theme.fonts.mainFont};
42
+ font-size: 13px;
43
+ font-style: normal;
44
+ font-weight: 400;
45
+ line-height: normal;
46
+ padding: 30px 0px;
47
+ white-space: pre-wrap;
48
+ `
49
+ export default {
50
+ name: 'actionModal',
51
+ props: ['isOpen'],
52
+ components: {
53
+ Modal,
54
+ modalContainer,
55
+ modalTitle,
56
+ buttonContainer,
57
+ textContainer
58
+ },
59
+ methods: {
60
+ closeModal() {
61
+ this.$emit('on-close')
62
+ }
63
+ }
64
+ }
65
+ </script>
@@ -0,0 +1,31 @@
1
+ import Modal from "./index.vue";
2
+
3
+ export default {
4
+ title: "Modal",
5
+ component: Modal,
6
+ // argTypes: {},
7
+ };
8
+
9
+ const Template = (args, { argTypes }) => ({
10
+ // Components used in your story `template` are defined in the `components` object
11
+ components: { Modal },
12
+ // The story's `args` need to be mapped into the template through the `setup()` method
13
+ props: Object.keys(argTypes),
14
+ template: '<modal v-bind="$props" />',
15
+
16
+ // import Modal from "@eturnity/eturnity_reusable_components/src/components/modals/modal"
17
+ // This is a more flexible modal box, where the parent can decide how the body of the modal looks
18
+ // To use:
19
+ // <modal :isOpen="isOpen" @on-close="$emit('on-close-summary')" :preventOutsideClose="true" :isLoading="true" :hideClose="true">
20
+ // <div>Data....</div>
21
+ // </modal>
22
+ });
23
+
24
+ export const Default = Template.bind({
25
+ isOpen: true,
26
+ preventOutsideClose: true,
27
+ isLoading: false,
28
+ hideClose: false,
29
+ backdrop: 'dark',
30
+ })
31
+ Default.args = {};
@@ -0,0 +1,188 @@
1
+ <template>
2
+ <page-wrapper
3
+ :position="position"
4
+ :isOpen="isOpen"
5
+ :class="{ visible: isOpen, hidden: !isOpen }"
6
+ :backdrop="backdrop"
7
+ >
8
+ <modal-container @click="onClickModalContainer">
9
+ <spinner v-if="isLoading" size="50px" :limitedToModal="true" />
10
+ <content-container :visible="!isLoading">
11
+ <slot />
12
+ </content-container>
13
+ <close-button v-if="!hideClose" @click="onCloseModal()" class="close" />
14
+ </modal-container>
15
+ </page-wrapper>
16
+ </template>
17
+
18
+ <script>
19
+ // Rules: (as defined in https://e-turnity.atlassian.net/browse/EPDM-9694)
20
+ // 1. On clicking the “escape” key, close the modal onCloseModal()
21
+ // 2. Always prevent outside close
22
+ // import Modal from "@eturnity/eturnity_reusable_components/src/components/modals/modal"
23
+ // This is a more flexible modal box, where the parent can decide how the body of the modal looks
24
+ // To use:
25
+ // <modal :isOpen="isOpen" @on-close="$emit('on-close-summary')" :isLoading="true" :hideClose="true" :stopPropagation="false">
26
+ // <div>Data....</div>
27
+ // </modal>
28
+
29
+ import styled from 'vue3-styled-components'
30
+ import CloseButton from '../../buttons/closeButton'
31
+ import Spinner from '../../spinner'
32
+
33
+ const contentAttrs = { visible: Boolean }
34
+ const ContentContainer = styled('div', contentAttrs)`
35
+ visibility: ${(props) => (props.visible ? 'inherit' : 'hidden')};
36
+ `
37
+
38
+ const pageAttrs = { isOpen: Boolean, backdrop: String, position: String }
39
+ const PageWrapper = styled('div', pageAttrs)`
40
+ position: ${(props) => props.position}
41
+ display: grid;
42
+ top: 0;
43
+ left: 0;
44
+ width: 100%;
45
+ height: 100%;
46
+ background-color: ${(props) =>
47
+ props.backdrop == 'dark'
48
+ ? 'rgba(0, 0, 0, 0.4)'
49
+ : 'rgba(255, 255, 255, 0.9)'};
50
+ z-index: 99999;
51
+ overflow: auto;
52
+
53
+ &.visible {
54
+ visibility: visible;
55
+ opacity: 1;
56
+ transition: visibility 0s linear 0s, opacity 300ms;
57
+ }
58
+
59
+ &.hidden {
60
+ visibility: hidden;
61
+ opacity: 0;
62
+ transition: visibility 0s linear 300ms, opacity 300ms;
63
+ }
64
+
65
+ @media (max-width: 425px) {
66
+ background: white;
67
+ }
68
+ `
69
+
70
+ const ModalContainer = styled.div`
71
+ align-self: center;
72
+ justify-self: center;
73
+ position: relative;
74
+ box-shadow: 0px 4px 4px 3px rgba(0, 0, 0, 0.1);
75
+ border-radius: 4px;
76
+ background: white;
77
+ margin: 0 auto;
78
+ overflow: auto;
79
+ max-width: 95%;
80
+ max-height: 95%;
81
+ min-width: 100px;
82
+ min-height: 100px;
83
+
84
+ ::-webkit-scrollbar {
85
+ width: 0.3em;
86
+ height: 100%;
87
+ background-color: ${(props) => props.theme.colors.grey5};
88
+ }
89
+
90
+ /* Make scrollbar visible when needed */
91
+ ::-webkit-scrollbar-thumb {
92
+ background-color: ${(props) => props.theme.colors.grey3};
93
+ }
94
+
95
+ /* Make scrollbar track visible when needed */
96
+ ::-webkit-scrollbar-track {
97
+ background-color: ${(props) => props.theme.colors.grey5};
98
+ }
99
+
100
+ .close {
101
+ position: absolute;
102
+ right: 20px;
103
+ top: 20px;
104
+
105
+ @media (max-width: 425px) {
106
+ right: 14px;
107
+ top: 12px;
108
+ background: white;
109
+ position: fixed;
110
+ z-index: 99;
111
+ }
112
+ }
113
+
114
+ @media (max-width: 425px) {
115
+ width: 100%;
116
+ height: 100%;
117
+ box-shadow: none;
118
+ }
119
+ `
120
+
121
+ export default {
122
+ name: 'modal',
123
+ components: {
124
+ PageWrapper,
125
+ ModalContainer,
126
+ CloseButton,
127
+ Spinner,
128
+ ContentContainer
129
+ },
130
+ props: {
131
+ isOpen: {
132
+ required: true,
133
+ default: false
134
+ },
135
+ isLoading: {
136
+ required: false,
137
+ default: false
138
+ },
139
+ hideClose: {
140
+ required: false,
141
+ default: false
142
+ },
143
+ backdrop: {
144
+ required: false,
145
+ default: 'white'
146
+ },
147
+ position: {
148
+ required: false,
149
+ default: 'fixed'
150
+ },
151
+ stopPropagation: {
152
+ type: Boolean,
153
+ default: true
154
+ }
155
+ },
156
+ beforeDestroy() {
157
+ window.removeEventListener('keydown', this.handleKeyDown)
158
+ },
159
+ methods: {
160
+ onCloseModal() {
161
+ this.$emit('on-close')
162
+ },
163
+ handleKeyDown({ key }) {
164
+ if (key === 'Escape') {
165
+ this.onCloseModal()
166
+ }
167
+ },
168
+ onClickModalContainer(event) {
169
+ if (this.stopPropagation) {
170
+ event.stopPropagation()
171
+ }
172
+ }
173
+ },
174
+ watch: {
175
+ isOpen: {
176
+ immediate: true,
177
+ handler(isOpen) {
178
+ document.body.style.overflow = isOpen ? 'hidden' : ''
179
+ if (isOpen) {
180
+ window.addEventListener('keydown', this.handleKeyDown)
181
+ } else {
182
+ window.removeEventListener('keydown', this.handleKeyDown)
183
+ }
184
+ }
185
+ }
186
+ }
187
+ }
188
+ </script>
@@ -0,0 +1,69 @@
1
+ <template>
2
+ <ActionModal :is-open="isOpen" @on-close="closeModal">
3
+ <modalContainer>
4
+ <template name="title">
5
+ <slot name="title"></slot>
6
+ </template>
7
+ <template name="body">
8
+ <slot name="body"></slot>
9
+ </template>
10
+ <template name="buttons">
11
+ <buttonContainer>
12
+ <Button type="primary" :text="$gettext('Got it')" minWidth="150px" @click="closeModal" />
13
+ </buttonContainer>
14
+ </template>
15
+
16
+ </modalContainer>
17
+ </ActionModal>
18
+ </template>
19
+ <script>
20
+
21
+ import styled from 'vue3-styled-components'
22
+ import ActionModal from '../actionModal'
23
+
24
+ const modalContainer = styled.div`
25
+ width: 450px;
26
+ min-height: 205px;
27
+ padding: 40px 40px 30px 40px;
28
+ `
29
+ const modalTitle = styled.div`
30
+ color: ${(props) => props.theme.colors.black};
31
+ font-family: ${(props) => props.theme.fonts.mainFont};
32
+ font-size: 18px;
33
+ font-style: normal;
34
+ font-weight: 700;
35
+ line-height: 120%;
36
+ text-transform: uppercase;
37
+ `
38
+ const buttonContainer = styled.div`
39
+ display: inline-flex;
40
+ align-items: flex-start;
41
+ gap: 20px;
42
+ `
43
+ const textContainer = styled.div`
44
+ color: ${(props) => props.theme.colors.black};
45
+ font-family: ${(props) => props.theme.fonts.mainFont};
46
+ font-size: 13px;
47
+ font-style: normal;
48
+ font-weight: 400;
49
+ line-height: normal;
50
+ padding: 30px 0px;
51
+ white-space: pre-wrap;
52
+ `
53
+ export default {
54
+ name: 'InfoModal',
55
+ props: ['isOpen'],
56
+ components: {
57
+ Modal,
58
+ modalContainer,
59
+ modalTitle,
60
+ buttonContainer,
61
+ textContainer
62
+ },
63
+ methods: {
64
+ closeModal() {
65
+ this.$emit('on-close')
66
+ }
67
+ }
68
+ }
69
+ </script>
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <Modal :is-open="isOpen" @on-close="closeModal">
3
+ <modalContainer>
4
+ <modalTitle v-if="$slots.title">
5
+ <slot name="title"></slot>
6
+ </modalTitle>
7
+ <textContainer v-if="$slots.body">
8
+ <slot name="body"></slot>
9
+ </textContainer>
10
+ <buttonContainer v-if="$slots.buttons">
11
+ <slot name="buttons"></slot>
12
+ </buttonContainer>
13
+ </modalContainer>
14
+ </Modal>
15
+ </template>
16
+ <script>
17
+ import styled from 'vue3-styled-components'
18
+ import { mapActions, mapState } from 'vuex'
19
+ import Modal from '../modal'
20
+ const modalContainer = styled.div`
21
+ width: 450px;
22
+ min-height: 205px;
23
+ padding: 40px 40px 30px 40px;
24
+ `
25
+ const modalTitle = styled.div`
26
+ color: ${(props) => props.theme.colors.black};
27
+ font-family: ${(props) => props.theme.fonts.mainFont};
28
+ font-size: 18px;
29
+ font-style: normal;
30
+ font-weight: 700;
31
+ line-height: 120%;
32
+ text-transform: uppercase;
33
+ `
34
+ const buttonContainer = styled.div`
35
+ display: inline-flex;
36
+ align-items: flex-start;
37
+ gap: 20px;
38
+ `
39
+ const textContainer = styled.div`
40
+ color: ${(props) => props.theme.colors.black};
41
+ font-family: ${(props) => props.theme.fonts.mainFont};
42
+ font-size: 13px;
43
+ font-style: normal;
44
+ font-weight: 400;
45
+ line-height: normal;
46
+ padding: 30px 0px;
47
+ white-space: pre-wrap;
48
+ `
49
+ export default {
50
+ name: 'actionModal',
51
+ props: ['isOpen'],
52
+ components: {
53
+ Modal,
54
+ modalContainer,
55
+ modalTitle,
56
+ buttonContainer,
57
+ textContainer
58
+ },
59
+ methods: {
60
+ closeModal() {
61
+ this.$emit('on-close')
62
+ }
63
+ }
64
+ }
65
+ </script>
@@ -0,0 +1,69 @@
1
+ <template>
2
+ <ActionModal :is-open="isOpen" @on-close="closeModal">
3
+ <modalContainer>
4
+ <template #title>
5
+ <slot name="title" />
6
+ </template>
7
+ <template #body>
8
+ <slot name="body" />
9
+ </template>
10
+ <template #buttons>
11
+ <buttonContainer>
12
+ <Button type="primary" :text="$gettext('Got it')" minWidth="150px" @click="closeModal" />
13
+ </buttonContainer>
14
+ </template>
15
+
16
+ </modalContainer>
17
+ </ActionModal>
18
+ </template>
19
+ <script>
20
+
21
+ import styled from 'vue3-styled-components'
22
+ import ActionModal from '../actionModal'
23
+
24
+ const modalContainer = styled.div`
25
+ width: 450px;
26
+ min-height: 205px;
27
+ padding: 40px 40px 30px 40px;
28
+ `
29
+ const modalTitle = styled.div`
30
+ color: ${(props) => props.theme.colors.black};
31
+ font-family: ${(props) => props.theme.fonts.mainFont};
32
+ font-size: 18px;
33
+ font-style: normal;
34
+ font-weight: 700;
35
+ line-height: 120%;
36
+ text-transform: uppercase;
37
+ `
38
+ const buttonContainer = styled.div`
39
+ display: inline-flex;
40
+ align-items: flex-start;
41
+ gap: 20px;
42
+ `
43
+ const textContainer = styled.div`
44
+ color: ${(props) => props.theme.colors.black};
45
+ font-family: ${(props) => props.theme.fonts.mainFont};
46
+ font-size: 13px;
47
+ font-style: normal;
48
+ font-weight: 400;
49
+ line-height: normal;
50
+ padding: 30px 0px;
51
+ white-space: pre-wrap;
52
+ `
53
+ export default {
54
+ name: 'InfoModal',
55
+ props: ['isOpen'],
56
+ components: {
57
+ Modal,
58
+ modalContainer,
59
+ modalTitle,
60
+ buttonContainer,
61
+ textContainer
62
+ },
63
+ methods: {
64
+ closeModal() {
65
+ this.$emit('on-close')
66
+ }
67
+ }
68
+ }
69
+ </script>