11<template >
2- <div class =" progress__wrapper" >
2+ <div class =" progress__wrapper" :style = " styleData['progress__wrapper'] " >
33 <span
44 v-for =" (step, index) in steps"
55 :key =" 'step_' + step"
66 class =" progress__block"
7+ :style =" styleData['progress__block']"
78 ><div
89 @click =" callPageChange(index)"
910 class =" progress__bubble"
11+ :style =" {
12+ ...styleData['progress__bubble'],
13+ ...getColors('progress__bubble', index),
14+ }"
1015 v-bind:class =" {
11- 'progress__bubble-completed': index <= currentStep,
12- 'progress__bubble-active': isActive(index),
1316 clickable: isReactive && checkIfStepIsReactive(index),
1417 }"
1518 >
1619 {{ index + 1 }}
1720 </div >
1821 <span
1922 @click =" callPageChange(index)"
23+ :style =" {
24+ ...styleData['progress__label'],
25+ ...getColors('progress__label', index),
26+ }"
2027 v-bind:class =" {
21- 'progress__label-completed': index <= currentStep,
22- 'progress__label-active': isActive(index),
2328 clickable: isReactive && checkIfStepIsReactive(index),
2429 }"
2530 v-if =" showLabel"
3136 (showBridge || showBridgeOnSmallDevices) && index != steps.length - 1
3237 "
3338 v-bind:class =" {
34- 'progress__bridge-completed': index < currentStep,
3539 'hide-on-large': !showBridge,
3640 'display-on-small': showBridgeOnSmallDevices,
3741 }"
42+ :style =" {
43+ ...styleData['progress__bridge'],
44+ ...getColors('progress__bridge', index),
45+ }"
3846 class =" progress__bridge"
3947 ></div >
4048 </span >
@@ -88,11 +96,104 @@ export default {
8896 required: false ,
8997 default: true ,
9098 },
99+ colors: {
100+ type: Object ,
101+ required: false ,
102+ default : function () {
103+ return {};
104+ },
105+ },
106+ styles: {
107+ type: Object ,
108+ required: false ,
109+ default : function () {
110+ return {};
111+ },
112+ },
91113 },
92114
93115 data () {
94116 return {
95117 currentStep: this .activeStep < this .steps .length ? this .activeStep : 0 ,
118+ styleData: {
119+ progress__wrapper: {
120+ display: " -ms-flexbox" ,
121+ display: " flex" ,
122+ flexWrap: " wrap" ,
123+ display: " flex" ,
124+ justifyContent: " flex-start" ,
125+ margin: " 1rem 0" ,
126+ },
127+ progress__block: {
128+ display: " flex" ,
129+ alignItems: " center" ,
130+ },
131+ progress__bridge: {
132+ backgroundColor: " grey" ,
133+ height: " 2px" ,
134+ flexGrow: " 1" ,
135+ width: " 20px" ,
136+ },
137+ progress__bubble: {
138+ margin: " 0" ,
139+ padding: " 0" ,
140+ lineHeight: " 30px" ,
141+ display: " flex" ,
142+ justifyContent: " center" ,
143+ alignItems: " center" ,
144+ height: " 30px" ,
145+ width: " 30px" ,
146+ borderRadius: " 100%" ,
147+ backgroundColor: " transparent" ,
148+ border: " 2px grey solid" ,
149+ textAlign: " center" ,
150+ },
151+ progress__label: {
152+ margin: " 0 0.8rem" ,
153+ },
154+ },
155+ colorData: {
156+ progress__bubble: {
157+ active: {
158+ color: " #fff" ,
159+ backgroundColor: " red" ,
160+ borderColor: " red" ,
161+ },
162+ inactive: {
163+ color: " black" ,
164+ },
165+ completed: {
166+ color: " #fff" ,
167+ borderColor: " #1e7e34" ,
168+ backgroundColor: " #1e7e34" ,
169+ },
170+ },
171+ progress__label: {
172+ active: {
173+ color: " red" ,
174+ },
175+ inactive: {
176+ color: " black" ,
177+ },
178+ completed: {
179+ color: " #1e7e34" ,
180+ },
181+ },
182+ progress__bridge: {
183+ active: {
184+ backgroundColor: " black" ,
185+ borderColor: " black" ,
186+ },
187+ inactive: {
188+ backgroundColor: " black" ,
189+ borderColor: " black" ,
190+ },
191+ completed: {
192+ backgroundColor: " #1e7e34" ,
193+ borderColor: " #1e7e34" ,
194+ },
195+ },
196+ },
96197 };
97198 },
98199
@@ -121,77 +222,71 @@ export default {
121222 return false ;
122223 }
123224 },
225+ getColors : function (className , index ) {
226+ let styles = {};
227+ if (index < this .currentStep ) {
228+ styles[" color" ] = this .colorData [className][" completed" ][" color" ];
229+ styles[" backgroundColor" ] = this .inactiveColor
230+ ? this .inactiveColor
231+ : this .colorData [className][" completed" ][" backgroundColor" ];
232+ styles[" borderColor" ] = this .colorData [className][" completed" ][
233+ " borderColor"
234+ ];
235+ } else if (index == this .currentStep ) {
236+ styles[" color" ] = this .colorData [className][" active" ][" color" ];
237+ styles[" backgroundColor" ] = this .colorData [className][" active" ][
238+ " backgroundColor"
239+ ];
240+ styles[" borderColor" ] = this .colorData [className][" active" ][
241+ " borderColor"
242+ ];
243+ } else {
244+ styles[" color" ] = this .colorData [className][" inactive" ][" color" ];
245+ styles[" backgroundColor" ] = this .colorData [className][" inactive" ][
246+ " backgroundColor"
247+ ];
248+ styles[" borderColor" ] = this .colorData [className][" inactive" ][
249+ " borderColor"
250+ ];
251+ }
252+ return styles;
253+ },
254+ overwriteStyle : function (style1 , style2 ) {
255+ for (const property in style1) {
256+ if (Object .hasOwnProperty .call (style1, property)) {
257+ const element = style1[property];
258+ for (const value in element) {
259+ if (Object .hasOwnProperty .call (element, value)) {
260+ style2[property][value] = element[value];
261+ }
262+ }
263+ }
264+ }
265+ return style2;
266+ },
124267 },
125268 watch: {
126269 activeStep : function (newVal ) {
127270 if (this .activeStep < this .steps .length ) this .currentStep = newVal;
128271 },
129272 },
273+
274+ mounted () {
275+ this .styleData = this .overwriteStyle (this .styles , this .styleData );
276+ this .colorData = this .overwriteStyle (this .colors , this .colorData );
277+ },
130278};
131279 </script >
132280
133281
134282
135283<style scoped>
136- .progress__wrapper {
137- display : -ms-flexbox ;
138- display : flex ;
139- -ms-flex-wrap : wrap ;
140- flex-wrap : wrap ;
141- display : flex ;
142- justify-content : flex-start ;
143- margin : 1rem 0 ;
144- }
284+ @import url (" https://fonts.googleapis.com/css2?family=Poppins:wght@200&display=swap" );
285+
145286.clickable {
146287 cursor : pointer ;
147288}
148- .progress__block {
149- display : flex ;
150- align-items : center ;
151- }
152- .progress__bridge {
153- display : inline-block ;
154- background : grey ;
155- height : 2px ;
156- flex-grow : 1 ;
157- width : 20px ;
158- }
159- .progress__bubble {
160- margin : 0 ;
161- padding : 0 ;
162- line-height : 30px ;
163- display : flex ;
164- justify-content : center ;
165- align-items : center ;
166- height : 30px ;
167- width : 30px ;
168- border-radius : 100% ;
169- background : transparent ;
170- border : 2px grey solid ;
171- text-align : center ;
172- }
173- .progress__label {
174- margin : 0 0.8rem ;
175- }
176- .progress__bubble-completed {
177- border-color : #1e7e34 ;
178- background : #1e7e34 ;
179- color : white ;
180- }
181- .progress__bubble-active {
182- border-color : #1e7e34 ;
183- background : #1e7e34 ;
184- color : white ;
185- }
186- .progress__label-completed {
187- color : #1e7e34 ;
188- }
189- .progress__label-active {
190- color : #1e7e34 ;
191- }
192- .progress__bridge-completed {
193- background : #1e7e34 ;
194- }
289+
195290.hide-on-large {
196291 display : none ;
197292}
@@ -211,7 +306,7 @@ export default {
211306 margin-right : 0 ;
212307 }
213308 .display-on-small {
214- display : block ;
309+ display : inline- block ;
215310 }
216311 .progress__block {
217312 margin : 0 ;
0 commit comments