@eturnity/eturnity_reusable_components 8.7.6 → 8.10.1
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 +3 -2
- package/src/Test.vue +12 -76
- package/src/assets/svgIcons/checkmark_white.svg +4 -0
- package/src/assets/svgIcons/clenergy.svg +4 -0
- package/src/assets/svgIcons/clickable_info.svg +2 -2
- package/src/assets/svgIcons/clickable_info_white.svg +5 -0
- package/src/assets/svgIcons/erase_white.svg +4 -0
- package/src/assets/svgIcons/module.svg +2 -2
- package/src/assets/svgIcons/optimizer.svg +2 -5
- package/src/assets/svgIcons/question_mark.svg +3 -0
- package/src/assets/svgIcons/question_mark_white.svg +4 -0
- package/src/assets/svgIcons/reorder_string.svg +3 -0
- package/src/assets/svgIcons/switch_polarity.svg +5 -0
- package/src/assets/svgIcons/transparent_warning.svg +4 -0
- package/src/assets/svgIcons/warning_triangle.svg +3 -0
- package/src/assets/svgIcons/warning_triangle_white.svg +5 -0
- package/src/components/buttons/buttonIcon/index.vue +31 -6
- package/src/components/infoLabel/index.vue +63 -0
- package/src/components/infoText/index.vue +168 -38
- package/src/components/inputs/checkbox/index.vue +11 -2
- package/src/components/inputs/select/index.vue +8 -58
- package/src/components/modals/modal/index.vue +1 -0
- package/src/components/panelRangeInfo/index.vue +196 -0
- package/src/components/tabsHeader/index.vue +71 -59
- package/src/components/stringDesign/DropdownMenu/index.vue +0 -1009
- /package/src/assets/svgIcons/{close_for_modals,_tool_tips.svg → close.svg} +0 -0
@@ -1,25 +1,48 @@
|
|
1
1
|
<template>
|
2
|
-
<PageContainer
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
>
|
10
|
-
<
|
11
|
-
|
12
|
-
:
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
2
|
+
<PageContainer
|
3
|
+
ref="container"
|
4
|
+
:type="type"
|
5
|
+
@click=";(isMobile || openTrigger === 'onClick') && toggleInfo()"
|
6
|
+
@mouseenter="!isMobile && openTrigger === 'onHover' && showInfo()"
|
7
|
+
@mouseleave="!isMobile && openTrigger === 'onHover' && hideInfo()"
|
8
|
+
>
|
9
|
+
<div ref="icon" data-test-id="infoText_trigger">
|
10
|
+
<IconWrapper
|
11
|
+
:background-color="backgroundColor"
|
12
|
+
:border-radius="borderRadius"
|
13
|
+
:hovered-icon="hoveredIcon"
|
14
|
+
:is-active="isActive"
|
15
|
+
:is-disabled="isDisabled"
|
16
|
+
:padding="padding"
|
17
|
+
>
|
18
|
+
<LabelWrapper
|
19
|
+
v-if="labelText && labelAlign === 'left'"
|
20
|
+
:color="iconColor || computedIconColor"
|
21
|
+
:size="labelSize"
|
22
|
+
>
|
23
|
+
{{ labelText }}
|
24
|
+
</LabelWrapper>
|
25
|
+
<Dot
|
26
|
+
v-if="type === 'dot'"
|
27
|
+
:color="dotColor"
|
28
|
+
data-test-id="infoText_dot"
|
29
|
+
/>
|
30
|
+
<IconComponent
|
31
|
+
v-else-if="!noIcon"
|
32
|
+
:color="iconColor || computedIconColor"
|
33
|
+
:cursor="isDisabled ? 'not-allowed' : 'pointer'"
|
34
|
+
:disabled="isDisabled"
|
35
|
+
:name="iconName"
|
36
|
+
:size="size"
|
37
|
+
/>
|
38
|
+
<LabelWrapper
|
39
|
+
v-if="labelText && labelAlign === 'right'"
|
40
|
+
:color="iconColor || computedIconColor"
|
41
|
+
:size="labelSize"
|
42
|
+
>
|
43
|
+
{{ labelText }}
|
44
|
+
</LabelWrapper>
|
45
|
+
</IconWrapper>
|
23
46
|
</div>
|
24
47
|
<Teleport v-if="isVisible" to="body">
|
25
48
|
<TextWrapper :style="wrapperStyle">
|
@@ -36,13 +59,13 @@
|
|
36
59
|
:src="image"
|
37
60
|
@load="onImageLoad"
|
38
61
|
/>
|
39
|
-
<span ref="textContent" :style="textStyle">
|
62
|
+
<span v-if="!hideInfoText" ref="textContent" :style="textStyle">
|
40
63
|
<slot>
|
41
64
|
<span v-html="text"></span>
|
42
65
|
</slot>
|
43
66
|
</span>
|
44
67
|
</TextOverlay>
|
45
|
-
<Arrow :image="image" :style="arrowStyle" />
|
68
|
+
<!-- <Arrow :image="image" :style="arrowStyle" /> -->
|
46
69
|
</TextWrapper>
|
47
70
|
</Teleport>
|
48
71
|
</PageContainer>
|
@@ -63,7 +86,12 @@
|
|
63
86
|
import styled from 'vue3-styled-components'
|
64
87
|
import theme from '../../assets/theme.js'
|
65
88
|
|
66
|
-
const
|
89
|
+
const TextOverlayAttrs = {
|
90
|
+
appTheme: String,
|
91
|
+
image: Boolean,
|
92
|
+
width: Number,
|
93
|
+
}
|
94
|
+
const TextOverlay = styled('div', TextOverlayAttrs)`
|
67
95
|
background-color: ${(props) =>
|
68
96
|
props.image ? props.theme.colors.white : props.theme.colors.black};
|
69
97
|
color: ${(props) =>
|
@@ -88,16 +116,16 @@
|
|
88
116
|
}
|
89
117
|
`
|
90
118
|
|
91
|
-
const Arrow = styled('div')`
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
`
|
119
|
+
// const Arrow = styled('div')`
|
120
|
+
// position: absolute;
|
121
|
+
// width: 0;
|
122
|
+
// height: 0;
|
123
|
+
// border: 8px solid transparent;
|
124
|
+
// border-top-color: ${(props) =>
|
125
|
+
// props.image ? props.theme.colors.white : props.theme.colors.black};
|
126
|
+
// filter: ${(props) =>
|
127
|
+
// props.image ? 'drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1))' : 'none'};
|
128
|
+
// `
|
101
129
|
|
102
130
|
const PageContainer = styled('div')`
|
103
131
|
display: ${(props) => (props.type === 'dot' ? 'unset' : 'inline-block')};
|
@@ -121,16 +149,57 @@
|
|
121
149
|
border-radius: 50%;
|
122
150
|
`
|
123
151
|
|
152
|
+
const IconWrapperAttrs = {
|
153
|
+
backgroundColor: String,
|
154
|
+
borderRadius: String,
|
155
|
+
padding: String,
|
156
|
+
hoveredIcon: Boolean,
|
157
|
+
isActive: Boolean,
|
158
|
+
isDisabled: Boolean,
|
159
|
+
}
|
160
|
+
const IconWrapper = styled('div', IconWrapperAttrs)`
|
161
|
+
display: flex;
|
162
|
+
align-items: center;
|
163
|
+
justify-content: center;
|
164
|
+
gap: 6px;
|
165
|
+
white-space: nowrap;
|
166
|
+
background-color: ${(props) => props.backgroundColor};
|
167
|
+
border-radius: ${(props) =>
|
168
|
+
props.hoveredIcon ? '6px' : props.borderRadius};
|
169
|
+
padding: ${(props) => props.padding};
|
170
|
+
width: ${(props) => (props.hoveredIcon ? '32px' : '')};
|
171
|
+
height: ${(props) => (props.hoveredIcon ? '32px' : '')};
|
172
|
+
cursor: pointer;
|
173
|
+
background-color: ${(props) =>
|
174
|
+
props.isActive ? props.theme.colors.transparentWhite2 : ''};
|
175
|
+
cursor: ${(props) => (props.isDisabled ? 'not-allowed' : 'pointer')};
|
176
|
+
&:hover {
|
177
|
+
background-color: ${(props) =>
|
178
|
+
props.hoveredIcon ? props.theme.colors.transparentWhite2 : ''};
|
179
|
+
}
|
180
|
+
`
|
181
|
+
|
182
|
+
const LabelWrapperAttrs = {
|
183
|
+
size: String,
|
184
|
+
color: String,
|
185
|
+
}
|
186
|
+
const LabelWrapper = styled('div', LabelWrapperAttrs)`
|
187
|
+
font-size: ${(props) => props.size};
|
188
|
+
color: ${(props) => props.color};
|
189
|
+
`
|
190
|
+
|
124
191
|
export default {
|
125
192
|
name: 'InfoText',
|
126
193
|
components: {
|
127
194
|
IconComponent,
|
128
195
|
TextOverlay,
|
129
|
-
Arrow,
|
196
|
+
// Arrow,
|
130
197
|
Dot,
|
131
198
|
PageContainer,
|
132
199
|
TextWrapper,
|
133
200
|
OverlayImage,
|
201
|
+
IconWrapper,
|
202
|
+
LabelWrapper,
|
134
203
|
},
|
135
204
|
props: {
|
136
205
|
text: {
|
@@ -138,6 +207,16 @@
|
|
138
207
|
default: '',
|
139
208
|
type: String,
|
140
209
|
},
|
210
|
+
isActive: {
|
211
|
+
required: false,
|
212
|
+
default: false,
|
213
|
+
type: Boolean,
|
214
|
+
},
|
215
|
+
labelText: {
|
216
|
+
required: false,
|
217
|
+
default: '',
|
218
|
+
type: String,
|
219
|
+
},
|
141
220
|
size: {
|
142
221
|
type: String,
|
143
222
|
default: '14px',
|
@@ -189,6 +268,51 @@
|
|
189
268
|
required: false,
|
190
269
|
default: 'info', // info, dot
|
191
270
|
},
|
271
|
+
appTheme: {
|
272
|
+
type: String,
|
273
|
+
default: 'light', // light or dark
|
274
|
+
required: false,
|
275
|
+
},
|
276
|
+
labelAlign: {
|
277
|
+
type: String,
|
278
|
+
default: 'right',
|
279
|
+
required: false,
|
280
|
+
},
|
281
|
+
backgroundColor: {
|
282
|
+
type: String,
|
283
|
+
default: '',
|
284
|
+
required: false,
|
285
|
+
},
|
286
|
+
borderRadius: {
|
287
|
+
type: String,
|
288
|
+
default: '',
|
289
|
+
required: false,
|
290
|
+
},
|
291
|
+
padding: {
|
292
|
+
type: String,
|
293
|
+
default: '',
|
294
|
+
required: false,
|
295
|
+
},
|
296
|
+
labelSize: {
|
297
|
+
type: String,
|
298
|
+
default: '12px',
|
299
|
+
required: false,
|
300
|
+
},
|
301
|
+
noIcon: {
|
302
|
+
type: Boolean,
|
303
|
+
default: false,
|
304
|
+
required: false,
|
305
|
+
},
|
306
|
+
hoveredIcon: {
|
307
|
+
type: Boolean,
|
308
|
+
default: false,
|
309
|
+
required: false,
|
310
|
+
},
|
311
|
+
hideInfoText: {
|
312
|
+
type: Boolean,
|
313
|
+
default: false,
|
314
|
+
required: false,
|
315
|
+
},
|
192
316
|
},
|
193
317
|
setup(props) {
|
194
318
|
const isVisible = ref(false)
|
@@ -206,7 +330,11 @@
|
|
206
330
|
|
207
331
|
const textStyle = computed(() => ({
|
208
332
|
fontSize: props.image ? '12px' : '13px',
|
209
|
-
color: props.image
|
333
|
+
color: props.image
|
334
|
+
? theme.colors.grey1
|
335
|
+
: props.appTheme === 'dark'
|
336
|
+
? theme.colors.black
|
337
|
+
: theme.colors.white,
|
210
338
|
textAlign: props.image ? 'right' : 'left',
|
211
339
|
}))
|
212
340
|
|
@@ -336,7 +464,9 @@
|
|
336
464
|
overflowY: 'auto',
|
337
465
|
backgroundColor: props.image
|
338
466
|
? theme.colors.white
|
339
|
-
:
|
467
|
+
: props.appTheme === 'light'
|
468
|
+
? theme.colors.black
|
469
|
+
: theme.colors.grey5,
|
340
470
|
}
|
341
471
|
}
|
342
472
|
|
@@ -408,7 +538,7 @@
|
|
408
538
|
|
409
539
|
// Calculate new width
|
410
540
|
const calculatedWidth = Math.min(
|
411
|
-
Math.max(contentWidth,
|
541
|
+
Math.max(contentWidth, 230),
|
412
542
|
parseInt(props.maxWidth, 10)
|
413
543
|
)
|
414
544
|
|
@@ -5,6 +5,7 @@
|
|
5
5
|
:check-color="checkColor"
|
6
6
|
:cursor-type="cursorType"
|
7
7
|
:data-test-id="dataId"
|
8
|
+
:font-color="fontColor"
|
8
9
|
:has-label="hasLabel"
|
9
10
|
:is-checked="isChecked"
|
10
11
|
:is-disabled="isDisabled"
|
@@ -63,6 +64,7 @@
|
|
63
64
|
isChecked: Boolean,
|
64
65
|
isDisabled: Boolean,
|
65
66
|
cursorType: String,
|
67
|
+
fontColor: String,
|
66
68
|
}
|
67
69
|
const Container = styled('label', containerAttrs)`
|
68
70
|
display: grid;
|
@@ -70,7 +72,10 @@
|
|
70
72
|
props.hasLabel ? '16px auto' : '16px'};
|
71
73
|
grid-gap: 16px;
|
72
74
|
align-content: center;
|
73
|
-
color: ${(props) =>
|
75
|
+
color: ${(props) =>
|
76
|
+
props.theme.colors[props.fontColor]
|
77
|
+
? props.theme.colors[props.fontColor]
|
78
|
+
: props.fontColor};
|
74
79
|
position: relative;
|
75
80
|
cursor: ${(props) => (props.isDisabled ? 'not-allowed' : props.cursorType)};
|
76
81
|
font-size: 16px;
|
@@ -176,7 +181,7 @@
|
|
176
181
|
align-items: center;
|
177
182
|
min-height: 18px;
|
178
183
|
color: ${(props) =>
|
179
|
-
props.isDisabled ? props.theme.colors.grey2 :
|
184
|
+
props.isDisabled ? props.theme.colors.grey2 : 'unset'};
|
180
185
|
`
|
181
186
|
|
182
187
|
export default {
|
@@ -193,6 +198,10 @@
|
|
193
198
|
required: false,
|
194
199
|
default: '',
|
195
200
|
},
|
201
|
+
fontColor: {
|
202
|
+
required: false,
|
203
|
+
default: 'black',
|
204
|
+
},
|
196
205
|
isChecked: {
|
197
206
|
required: true,
|
198
207
|
default: false,
|
@@ -141,13 +141,10 @@
|
|
141
141
|
<SelectDropdown
|
142
142
|
v-show="isSelectDropdownShown"
|
143
143
|
ref="dropdown"
|
144
|
-
:style="{
|
145
|
-
transform: `translate(${dropdownPosition?.left}px, ${
|
146
|
-
noRelative ? 'auto' : `${dropdownPosition?.top}px`
|
147
|
-
})`,
|
148
|
-
}"
|
149
144
|
:bg-color="
|
150
|
-
|
145
|
+
dropdownBgColor ||
|
146
|
+
colorMode == 'dark' ||
|
147
|
+
colorMode == 'transparent'
|
151
148
|
? 'black'
|
152
149
|
: 'white'
|
153
150
|
"
|
@@ -400,8 +397,9 @@
|
|
400
397
|
box-sizing: border-box;
|
401
398
|
z-index: ${(props) => (props.isActive ? '2' : '99999')};
|
402
399
|
position: absolute;
|
403
|
-
top:
|
404
|
-
|
400
|
+
top: ${(props) =>
|
401
|
+
props.noRelative ? 'auto' : props.dropdownPosition?.top + 'px'};
|
402
|
+
left: ${(props) => props.dropdownPosition?.left}px;
|
405
403
|
border: ${BORDER_WIDTH} solid ${(props) => props.theme.colors.grey4};
|
406
404
|
border-radius: 4px;
|
407
405
|
display: flex;
|
@@ -666,10 +664,6 @@
|
|
666
664
|
},
|
667
665
|
dropdownWidth: null,
|
668
666
|
hoveredValue: null,
|
669
|
-
isDisplayedAtBottom: true,
|
670
|
-
selectTopPosition: 0,
|
671
|
-
selectAndDropdownDistance: 0,
|
672
|
-
animationFrameId: null,
|
673
667
|
}
|
674
668
|
},
|
675
669
|
computed: {
|
@@ -740,13 +734,8 @@
|
|
740
734
|
}, 10)
|
741
735
|
await this.$nextTick()
|
742
736
|
this.handleSetDropdownOffet()
|
743
|
-
this.calculateSelectTopPosition()
|
744
737
|
} else {
|
745
738
|
this.dropdownPosition.left = null
|
746
|
-
if (this.animationFrameId) {
|
747
|
-
cancelAnimationFrame(this.animationFrameId)
|
748
|
-
this.animationFrameId = null
|
749
|
-
}
|
750
739
|
setTimeout(() => {
|
751
740
|
this.isClickOutsideActive = false
|
752
741
|
}, 10)
|
@@ -759,27 +748,11 @@
|
|
759
748
|
})
|
760
749
|
}
|
761
750
|
},
|
762
|
-
isSelectDropdownShown(isShown) {
|
763
|
-
if (!isShown) return
|
764
|
-
|
765
|
-
// Need to wait for 1ms to make sure the dropdown menu is shown in the DOM
|
766
|
-
// before getting the distance between the select and the dropdown menu
|
767
|
-
setTimeout(() => {
|
768
|
-
this.getDistanceBetweenSelectAndDropdownMenu()
|
769
|
-
}, 100)
|
770
|
-
},
|
771
|
-
selectTopPosition() {
|
772
|
-
this.dropdownPosition.top =
|
773
|
-
this.selectTopPosition +
|
774
|
-
this.$refs.select.$el.clientHeight +
|
775
|
-
this.selectAndDropdownDistance
|
776
|
-
},
|
777
751
|
},
|
778
752
|
mounted() {
|
779
753
|
this.observeDropdownHeight()
|
780
754
|
this.observeSelectWidth()
|
781
755
|
window.addEventListener('resize', this.handleSetDropdownOffet)
|
782
|
-
document.body.addEventListener('scroll', this.calculateSelectTopPosition)
|
783
756
|
},
|
784
757
|
beforeMount() {
|
785
758
|
this.selectedValue = this.value
|
@@ -788,10 +761,6 @@
|
|
788
761
|
window.removeEventListener('resize', this.handleSetDropdownOffet)
|
789
762
|
if (this.dropdownResizeObserver) this.dropdownResizeObserver.disconnect()
|
790
763
|
if (this.selectResizeObserver) this.selectResizeObserver.disconnect()
|
791
|
-
document.body.removeEventListener(
|
792
|
-
'scroll',
|
793
|
-
this.calculateSelectTopPosition
|
794
|
-
)
|
795
764
|
},
|
796
765
|
unmounted() {
|
797
766
|
document.removeEventListener('click', this.clickOutside)
|
@@ -897,11 +866,11 @@
|
|
897
866
|
return
|
898
867
|
}
|
899
868
|
await this.$nextTick()
|
900
|
-
|
869
|
+
const isDisplayedAtBottom = await this.generateDropdownPosition()
|
901
870
|
// If the dropdown menu is going to be displayed at the bottom,
|
902
871
|
// we need reverify its position after a dom update (nextTick)
|
903
872
|
await this.$nextTick()
|
904
|
-
if (
|
873
|
+
if (isDisplayedAtBottom) this.generateDropdownPosition()
|
905
874
|
},
|
906
875
|
async generateDropdownPosition() {
|
907
876
|
const isDropdownNotCompletelyVisible =
|
@@ -994,25 +963,6 @@
|
|
994
963
|
}
|
995
964
|
}
|
996
965
|
},
|
997
|
-
getDistanceBetweenSelectAndDropdownMenu() {
|
998
|
-
const wholeSelectTopPosition =
|
999
|
-
this.selectTopPosition + this.$refs.select.$el.clientHeight
|
1000
|
-
this.selectAndDropdownDistance =
|
1001
|
-
this.dropdownPosition.top - wholeSelectTopPosition
|
1002
|
-
},
|
1003
|
-
calculateSelectTopPosition() {
|
1004
|
-
const selectRef = this.$refs.select
|
1005
|
-
if (selectRef) {
|
1006
|
-
const currentTopPosition =
|
1007
|
-
selectRef.$el.getBoundingClientRect().top + window.scrollY
|
1008
|
-
if (this.selectTopPosition !== currentTopPosition) {
|
1009
|
-
this.selectTopPosition = currentTopPosition
|
1010
|
-
}
|
1011
|
-
}
|
1012
|
-
this.animationFrameId = requestAnimationFrame(
|
1013
|
-
this.calculateSelectTopPosition
|
1014
|
-
)
|
1015
|
-
},
|
1016
966
|
},
|
1017
967
|
}
|
1018
968
|
</script>
|
@@ -0,0 +1,196 @@
|
|
1
|
+
<template>
|
2
|
+
<Container :width="width">
|
3
|
+
<MainLine />
|
4
|
+
<MainLineHighlight :max-percent="maxPercent" :min-percent="minPercent" />
|
5
|
+
<TopValueContainer :position="valuePercent + '%'">
|
6
|
+
<TextWrapper :background-color="arrowColor">{{ value }}</TextWrapper>
|
7
|
+
<Arrow :background-color="arrowColor" />
|
8
|
+
<VerticalMarkerArrow :color="colorVerticalMarkerArrow" />
|
9
|
+
</TopValueContainer>
|
10
|
+
<BottomValueContainer :position="minPercent + '%'">
|
11
|
+
<TextWrapper>{{ minValue }}</TextWrapper>
|
12
|
+
<VerticalMarker side="bottom" />
|
13
|
+
</BottomValueContainer>
|
14
|
+
<BottomValueContainer :position="maxPercent + '%'">
|
15
|
+
<TextWrapper>{{ maxValue }}</TextWrapper>
|
16
|
+
<VerticalMarker side="bottom" />
|
17
|
+
</BottomValueContainer>
|
18
|
+
</Container>
|
19
|
+
</template>
|
20
|
+
|
21
|
+
<script>
|
22
|
+
// import ProgressBar from "@eturnity/eturnity_reusable_components/src/components/progressBar"
|
23
|
+
//To Use:
|
24
|
+
// <progress-bar
|
25
|
+
// fillColor="#000"
|
26
|
+
// backgroundColor="#888"
|
27
|
+
// minWidth="150px"
|
28
|
+
// maxWidth="100%"
|
29
|
+
// :fillProgress="50" //should be a number for percent
|
30
|
+
// stepNumber="4"
|
31
|
+
// :labelText="translate('step')"
|
32
|
+
// />
|
33
|
+
import styled from 'vue3-styled-components'
|
34
|
+
const Container = styled.div`
|
35
|
+
position: relative;
|
36
|
+
display: flex;
|
37
|
+
height: 47px;
|
38
|
+
width: ${(props) => props.width};
|
39
|
+
`
|
40
|
+
const TopValueContainer = styled('div', { position: String })`
|
41
|
+
font-size: 11px;
|
42
|
+
left: ${(props) => props.position};
|
43
|
+
position: absolute;
|
44
|
+
display: flex;
|
45
|
+
justify-content: center
|
46
|
+
width: 0px;
|
47
|
+
color:${(props) => props.theme.colors.black};
|
48
|
+
item-align: center;
|
49
|
+
|
50
|
+
`
|
51
|
+
const BottomValueContainer = styled('div', { position: String })`
|
52
|
+
font-size: 12px;
|
53
|
+
left: ${(props) => props.position};
|
54
|
+
width: 0px;
|
55
|
+
bottom: -2px;
|
56
|
+
position: absolute;
|
57
|
+
display: flex;
|
58
|
+
justify-content: center;
|
59
|
+
item-align: center;
|
60
|
+
border-radius: 4px;
|
61
|
+
color: white;
|
62
|
+
`
|
63
|
+
const TextWrapper = styled('div', { backgroundColor: String })`
|
64
|
+
padding: 2px 6px;
|
65
|
+
background-color: ${(props) =>
|
66
|
+
props.theme.colors[props.backgroundColor] || props.backgroundColor};
|
67
|
+
border-radius: 4px;
|
68
|
+
`
|
69
|
+
const Arrow = styled('div', { backgroundColor: String })`
|
70
|
+
position: absolute;
|
71
|
+
bottom: -10px;
|
72
|
+
left: calc(50% - 6px);
|
73
|
+
width: 0;
|
74
|
+
height: 0;
|
75
|
+
border: 6px solid transparent;
|
76
|
+
border-top-color: ${(props) =>
|
77
|
+
props.theme.colors[props.backgroundColor] || props.backgroundColor};
|
78
|
+
filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
|
79
|
+
`
|
80
|
+
const MainLine = styled.div`
|
81
|
+
display: block;
|
82
|
+
position: absolute;
|
83
|
+
bottom: 16px;
|
84
|
+
height: 4px;
|
85
|
+
width: 100%;
|
86
|
+
border-radius: 4px;
|
87
|
+
background-color: ${(props) => props.theme.colors.grey4};
|
88
|
+
`
|
89
|
+
const MainLineHighlight = styled('div', {
|
90
|
+
minPercent: Number,
|
91
|
+
maxPercent: Number,
|
92
|
+
})`
|
93
|
+
display: block;
|
94
|
+
position: absolute;
|
95
|
+
left: ${(props) => props.minPercent + '%'};
|
96
|
+
right: ${(props) => 100 - props.maxPercent + '%'};
|
97
|
+
bottom: 16px;
|
98
|
+
height: 4px;
|
99
|
+
background-color: white;
|
100
|
+
`
|
101
|
+
const VerticalMarker = styled('div')`
|
102
|
+
position: absolute;
|
103
|
+
width: 1px;
|
104
|
+
height: 8px;
|
105
|
+
background-color: white;
|
106
|
+
display: inline-block;
|
107
|
+
top: -6px;
|
108
|
+
left: 0px;
|
109
|
+
`
|
110
|
+
const VerticalMarkerArrow = styled('div', { color: String })`
|
111
|
+
position: absolute;
|
112
|
+
width: 1px;
|
113
|
+
height: 4px;
|
114
|
+
background-color: ${(props) => props.color};
|
115
|
+
display: inline-block;
|
116
|
+
bottom: -14px;
|
117
|
+
left: 0px;
|
118
|
+
`
|
119
|
+
export default {
|
120
|
+
name: 'ProgressBar',
|
121
|
+
components: {
|
122
|
+
Container,
|
123
|
+
MainLineHighlight,
|
124
|
+
Arrow,
|
125
|
+
TopValueContainer,
|
126
|
+
BottomValueContainer,
|
127
|
+
MainLine,
|
128
|
+
VerticalMarker,
|
129
|
+
VerticalMarkerArrow,
|
130
|
+
TextWrapper,
|
131
|
+
},
|
132
|
+
props: {
|
133
|
+
minValue: {
|
134
|
+
required: true,
|
135
|
+
type: Number,
|
136
|
+
},
|
137
|
+
maxValue: {
|
138
|
+
required: true,
|
139
|
+
type: Number,
|
140
|
+
},
|
141
|
+
value: {
|
142
|
+
required: true,
|
143
|
+
type: Number,
|
144
|
+
},
|
145
|
+
arrowColor: {
|
146
|
+
required: false,
|
147
|
+
type: String,
|
148
|
+
default: 'white',
|
149
|
+
},
|
150
|
+
width: {
|
151
|
+
required: false,
|
152
|
+
type: String,
|
153
|
+
default: null,
|
154
|
+
},
|
155
|
+
},
|
156
|
+
data() {
|
157
|
+
return {}
|
158
|
+
},
|
159
|
+
computed: {
|
160
|
+
minPercent() {
|
161
|
+
if (this.maxValue === this.minValue) {
|
162
|
+
return 50
|
163
|
+
} else {
|
164
|
+
return 30
|
165
|
+
}
|
166
|
+
},
|
167
|
+
maxPercent() {
|
168
|
+
if (this.maxValue === this.minValue) {
|
169
|
+
return 50
|
170
|
+
} else {
|
171
|
+
return 70
|
172
|
+
}
|
173
|
+
},
|
174
|
+
valuePercent() {
|
175
|
+
let percent
|
176
|
+
if (this.maxValue === this.minValue) {
|
177
|
+
percent = this.minPercent + 10 * (this.value - this.minValue)
|
178
|
+
} else {
|
179
|
+
percent =
|
180
|
+
this.minPercent +
|
181
|
+
((this.maxPercent - this.minPercent) /
|
182
|
+
(this.maxValue - this.minValue)) *
|
183
|
+
(this.value - this.minValue)
|
184
|
+
}
|
185
|
+
return Math.max(0, Math.min(100, percent))
|
186
|
+
},
|
187
|
+
colorVerticalMarkerArrow() {
|
188
|
+
if (this.value < this.maxValue && this.value > this.minValue) {
|
189
|
+
return 'black'
|
190
|
+
} else {
|
191
|
+
return 'white'
|
192
|
+
}
|
193
|
+
},
|
194
|
+
},
|
195
|
+
}
|
196
|
+
</script>
|