Projet

Général

Profil

0001-core-refactorisation-of-wcs-steps-component-36765.patch

Thomas Jund (congés, retour le 29/04), 18 novembre 2019 15:08

Télécharger (14,6 ko)

Voir les différences:

Subject: [PATCH] core: refactorisation of wcs steps component (#36765)

 static/includes/_wcs.scss               |   3 +-
 static/includes/wcs/_bulk.scss          |  97 +-----
 static/includes/wcs/_steps.scss         | 431 ++++++++++++++++++++++++
 templates/theme.html                    |   2 +-
 templates/wcs/front/formdata_steps.html |  30 ++
 5 files changed, 465 insertions(+), 98 deletions(-)
 create mode 100644 static/includes/wcs/_steps.scss
 create mode 100644 templates/wcs/front/formdata_steps.html
static/includes/_wcs.scss
1 1
@import 'grid';
2 2
@import 'wcs/bulk';
3
@import 'wcs/nearby-form';
3
@import 'wcs/steps';
4
@import 'wcs/nearby-form';
static/includes/wcs/_bulk.scss
2 2
// possible values are: left, right, top
3 3
$form-sidebar-position: left !default;
4 4

  
5
$responsive-steps: horizontal !default;
6

  
7 5
// hide a bunch of elements
8 6
div#droite,
9 7
div#services > h3,
......
133 131
	margin: 1em;
134 132
}
135 133

  
136
// steps
137
div#steps ol {
138
	margin: 0;
139
	padding: 0;
140
	list-style: none;
141
	color: #868686;
142

  
143
	& li {
144
		border: 0;
145
		border-bottom: 1px solid #ccc;
146
		margin-bottom: 1.5em;
147
		border-radius: $border-radius;
148
		padding: 0.7em;
149
		letter-spacing: 1px;
150
	}
151
	& li.current {
152
		border: 0;
153
		background: $title-background;
154
		color: $title-color;
155
		& span.label {
156
			font-weight: bold;
157
		}
158
	}
159
	& li span.marker {
160
		font-size: 250%;
161
		display: block;
162
	}
163
}
164 134

  
165 135

  
166
@if ($form-sidebar-position == top) {
167
	div#steps ol {
168
		text-align: center;
169
		li {
170
			display: inline-block;
171
			min-width: 7rem;
172
			max-width: 11rem;
173
			vertical-align: top;
174
			border-bottom: none;
175
		}
176
	}
177
}
178

  
179
@if ($responsive-steps == horizontal) {
180 136
@media screen and (max-width: $mobile-limit) {
137
	// move #gauche on top and tracking code after steps
181 138
	div#gauche {
182 139
		float: none;
183 140
		width: 100%;
......
193 150
		h3 { display: inline-block; }
194 151
		.text-tracking-code-short-text { display: none; }
195 152
	}
196
	div#steps {
197
		position: static;
198
		margin: 0;
199
		color: #aaa;
200
		white-space: nowrap;
201
		overflow: hidden;
202
		width: 100%;
203
		& ol {
204
			list-style: none;
205
			padding: 0 0;
206
			margin: 0;
207
			text-align: left;
208
			& li {
209
				border: none;
210
				display: inline-block;
211
				margin: 0;
212
				padding: 0 1em 0.7em 0;
213
				list-style: none;
214
				min-width: auto;
215
				border-radius: 0;
216
				& span.marker {
217
					float: none;
218
					display: inline;
219
					font-size: 26px;
220
					position: static;
221
					padding: 2px 9px;
222
					font-weight: bold;
223
					color: white;
224
					text-align: center;
225
					background: #ddd;
226
					border-radius: $border-radius;
227
					border: 1px solid #ddd;
228
				}
229
			}
230
			& li.current {
231
				background: inherit;
232
				color: inherit;
233
				& span.label {
234
					font-weight: normal;
235
				}
236
				& span.marker {
237
					background: $title-background;
238
					color: $title-color;
239
					border-radius: $border-radius;
240
				}
241
			}
242
			& li.step-before .label {
243
				display: none;
244
			}
245
		}
246
	}
247 153
}
248
}  // @endif ($responsive-steps == horizontal)
249 154

  
250 155
@media screen and (max-width: $mobile-limit) {
251 156
	div#gauche + div#rub_service,
static/includes/wcs/_steps.scss
1
/*
2
 *	WCS Steps
3
 *
4
 *	Affiche les étapes/pages d'un formulaire
5
 *
6
 *	Template : wcs/front/formdata_steps.html
7
 *
8
 *	$form-sidebar-position define Steps orientation
9
 *
10
 */
11

  
12

  
13
//
14
//	 Config
15
//
16

  
17
// Steps Bloc
18
$wcs-steps-background: transparent !default;
19
$wcs-steps-spacing: 0.35rem !default; // half of default 0.7rem used in publik
20

  
21
// Step
22
$wcs-step-color: #868686 !default; // color for default marker & label
23
$wcs-step-current-color: $primary-color !default;
24
$wcs-step-background: transparent !default;
25
$wcs-step-current-background: $wcs-step-background !default;
26
$wcs-step-border-bottom: 1px solid $wcs-step-color !default;
27
$wcs-step-current-border-bottom: 3px solid $wcs-step-current-color !default;
28
@if ($wcs-step-border-bottom == none) {
29
	$wcs-step-current-border-bottom: none;
30
}
31
// Step option
32
$wsc-step-before-piled: false !default;
33

  
34
// marker
35
$wcs-step-marker-color: $wcs-step-color !default;
36
$wcs-step-current-marker-color: $wcs-step-current-color !default;
37
$wcs-step-marker-background: $wcs-step-background !default;
38
$wcs-step-current-marker-background: $wcs-step-current-background !default;
39
// marker options
40
$wcs-step-marker-size: 2.1em !default;
41
$wcs-step-current-marker-enlarge: 1 !default;
42
$wcs-step-marker-type: square !default; // square || tied || disc || disc tied
43
$wcs-step-marker-tie-color: $wcs-step-color !default;
44
$wcs-step-marker-tie-width: 5px !default;
45
$wcs-step-marker-background-type: solid !default;
46

  
47
// Label
48
$wcs-step-current-label-color: $wcs-step-current-color !default;
49

  
50
// Breakpoints between small & horizontal layout
51
$bq-max--wcs-steps-small-layout: $very-small-limit !default;
52

  
53
// UTILS for custom code
54
// media queries between small & horizontal layout
55
$mq-max--wcs-steps-small-layout: "max-width: #{$bq-max--wcs-steps-small-layout}";
56
$mq-min--wcs-steps-horizontal-layout: "min-width: #{$bq-max--wcs-steps-small-layout+1}";
57
//  Desktop Steps orientation sass mixins
58
//	Steps orientations depend on media-queries & $form-sidebar-position
59
@mixin desktop-horizontal-steps() {
60
	@if ($form-sidebar-position == top) {
61
		@media (min-width: $mobile-limit + 1) {
62
			@content;
63
		}
64
	}
65
}
66
@mixin desktop-vertical-steps() {
67
	@if ($form-sidebar-position == left or $form-sidebar-position == right) {
68
		@media (min-width: $mobile-limit + 1) {
69
			@content;
70
		}
71
	}
72
}
73

  
74

  
75

  
76
/*
77
 *	Default Steps (with SQUARES markers)
78
 */
79

  
80
/* Steps bloc */
81
.wcs-steps {
82
	background: $wcs-steps-background;
83
	margin-bottom: 0.7rem;
84
	border-radius: $border-radius;
85

  
86
	@if $wcs-steps-background != transparent {
87
		padding: $wcs-steps-spacing;
88
	}
89

  
90

  
91
	&--list {
92
		margin: 0;
93
		padding: 0;
94
		list-style: none;
95
		color: $wcs-step-color;
96
	}
97
}
98

  
99
/* Step item */
100
.wcs-step {
101
	border-radius: $border-radius;
102
	background-color: $wcs-step-background;
103
	display: flex;
104

  
105
	&--marker {
106
		// marker is abbr tag
107
		text-decoration: none;
108
		box-sizing: border-box;
109

  
110
		font-size: 1em;
111
		line-height: nomal;
112
		text-align: center;
113
		
114
		display: flex;
115

  
116
		color: $wcs-step-marker-color;
117
		background: $wcs-step-marker-background;
118
		border-radius: $border-radius;
119

  
120
		width: $wcs-step-marker-size;
121
		height: $wcs-step-marker-size;
122
		flex: 0 0 $wcs-step-marker-size;
123
		
124
		&-nb {
125
			margin: auto;
126
		}
127

  
128
		&-total {
129
			display: none;
130
		}
131
	}
132

  
133
	&--label {
134
		display: block;
135
		align-self: center;
136
		letter-spacing: 1px;
137
		line-height: 1.25;
138
	}
139

  
140

  
141
	// If step is current
142
	&.current {
143
		font-weight: bold;
144
		background: $wcs-step-current-background;
145
	}
146

  
147
	&.current & {
148
		&--marker {
149
			background: $wcs-step-current-marker-background;
150
			color: $wcs-step-current-marker-color;
151

  
152
			transform: scale($wcs-step-current-marker-enlarge);		
153
		}
154
		&--label {
155
			color: $wcs-step-current-label-color;
156
		}
157
	}
158

  
159
	// If step is NOT current
160
	&:not(.current) & {
161
		&--label {
162
			display: none;
163
		}
164
	}
165
}
166

  
167
/*	Sidebar on TOP, SMALL LAYOUT (very-small viewport)
168
 *	Display only current step with nb and total in marker
169
 */
170
@media ($mq-max--wcs-steps-small-layout) {
171
	.wcs-step {
172
		@if ($wcs-step-background != transparent or $wcs-step-current-background != transparent) {
173
			padding: $wcs-steps-spacing;
174
		}
175

  
176
		&--marker {
177

  
178
			$size: $wcs-step-marker-size + 0.8;
179

  
180
			width: $size;
181
			height: $size;
182
			flex: 0 0 auto;
183
			align-items: center;
184
			justify-content: center;
185

  
186
			&-nb {
187
				margin: 0;
188
				transform: translateY(-0.5em);
189
				order: 1;
190
			}
191

  
192
			&-total {
193
				display: block;
194
				transform: translateY(0.5em);
195
				font-size: 0.75em;
196
				font-weight: normal;
197
				order: 3;
198
			}
199

  
200
			// add slash
201
			&::before {
202
				content: "";
203
				display: block;
204
				flex: 0 0 0.1em;
205
				height: 2em;
206
				margin: 0 0.1em;
207
				background: $wcs-step-current-marker-color;
208
				transform: rotate(30deg);
209
				order: 2;
210
			}
211
		}
212

  
213
		&--label {
214
			margin-left: $wcs-steps-spacing*2;
215
		}
216

  
217
		// If step is NOT current
218
		&:not(.current) {
219
			display: none;
220
		}
221
	}
222
}
223

  
224
/*	Horizontal Layout
225
 *	Sidebar on TOP, SMALL and more viewport
226
 *	Diplay all marker, but only current Label
227
 */
228
@media ($mq-min--wcs-steps-horizontal-layout) {
229

  
230
	.wcs-steps {
231
		&--list {
232
			position: relative;		
233
			display: flex;
234
			flex-wrap: wrap;
235

  
236
			// keep space for label
237
			margin-bottom: 2em;
238
		}
239
	}
240

  
241
	.wcs-step {
242
		margin-bottom: $wcs-steps-spacing;
243
		margin-right: $wcs-steps-spacing;
244
		border-bottom: $wcs-step-border-bottom;
245

  
246
		&--label {
247
			position: absolute;
248
			top: 100%;
249
			left: 0;
250
			width: 100%;
251
			padding-bottom: $wcs-steps-spacing;
252
		}
253

  
254
		&.current {
255
			border-bottom: $wcs-step-current-border-bottom;
256
		}
257
	}
258
}
259

  
260

  
261
@include desktop-horizontal-steps() {
262
	.wcs-steps {	
263
		font-size: 1.25em;
264
	}
265
	.wcs-step {
266
		margin-bottom: $wcs-steps-spacing*2;
267
		margin-right: $wcs-steps-spacing*2;
268
	}
269
}
270

  
271
/*	Vertical Steps
272
 *	Sidebar on LEFT or RIGHT, DESKTOP only
273
 *	Display All steps with marker and label. One below the other.
274
 */
275
@include desktop-vertical-steps() {
276
	.wcs-steps {
277
		font-size: 1.25em;
278

  
279
		&--list {
280
			flex-wrap: nowrap;
281
			flex-direction: column;
282
			// remove keep space for label
283
			padding-bottom: 0;
284
		}
285
	}
286

  
287
	.wcs-step {
288
		@if $wcs-step-border-bottom != none {
289
			padding-bottom: $wcs-steps-spacing;
290
		}
291
		@if ($wcs-step-background != transparent or $wcs-step-current-background != transparent) {
292
			padding: $wcs-steps-spacing;
293
		}
294

  
295
		margin-right: 0;
296

  
297
		&--label {
298
			position: static;
299
			font-size: 0.7em;
300
			margin-left: $wcs-steps-spacing;
301
			padding-bottom: 0;
302
		}
303

  
304
		// If step is NOT current
305
		&:not(.current) & {
306
			&--label {
307
				display: block;
308
			}
309
		}
310
	}
311
}
312

  
313

  
314
/*
315
 *	OPTION marker-background-type: gradient.
316
 *	Generate automatically a gradient based on background-color
317
 */
318

  
319
@if $wcs-step-marker-background-type == gradient {
320
	.wcs-step {
321
		&--marker {
322
			background-attachment: fixed;
323
			@media (min-width: $very-small-limit + 1) {			
324
				background-image: linear-gradient(to right, lighten($wcs-step-marker-background, 10%), darken($wcs-step-marker-background, 10%));
325
			}
326

  
327
			@include desktop-vertical-steps() {
328
				background-image: linear-gradient(to bottom, lighten($wcs-step_marker-background, 10%), darken($wcs-step_marker-background, 10%));
329
			}
330
		}
331
	}
332
}
333

  
334
/*
335
 *	OPTION Pile Step Before
336
 *	Work only for
337
 *		* horizontal mode: desktop breakpoint and sidebar on left or right
338
 *		* with background-color on step
339
 */
340
@if ($wsc-step-before-piled ) {
341
	@include desktop-vertical-steps() {
342
		.wcs-step {	
343
			&:not(:first-child) {
344
				&.step-before, 
345
				&.current {
346
					box-shadow: 0 -4px 4px -4px darken($wcs-step-background, 40%);
347
				}
348
			}
349

  
350
			&.step-before, 
351
			&.current {
352
				z-index: 1;
353
				transition: margin 400ms, box-shadow 400ms;
354
			}
355
			
356
			&.step-before {
357
				margin-bottom: calc( (#{$wcs-step-marker-size} + #{$wcs-steps-spacing * 2}) / 2 * -1);
358

  
359
				&:hover {
360
					margin-bottom: $wcs-steps-spacing;
361

  
362
					& + .wcs-step {
363
						box-shadow: 0 0 0 0 darken($wcs-step-background, 40%);
364
					}
365
				}
366
			}
367
		}
368
	}
369
}
370

  
371

  
372
/*
373
 *	OPTION marker type DISC
374
 */
375
@if (str-index(quote($wcs-step-marker-type), 'disc')) {
376
	.wcs-step {
377
		&--marker {
378
			border-radius: 50% !important;
379

  
380
			@media ($mq-max--wcs-steps-small-layout) {
381
				$size: $wcs-step-marker-size + 1.4;
382
				width: $size;
383
				height: $size;
384
			}
385
		}
386
	}
387
}
388

  
389
/*
390
 *	OPTION marker type TIED
391
 */
392
@if (str-index(quote($wcs-step-marker-type), 'tied')) {
393
	
394
	.wcs-step {
395
		&:not(:last-child) {
396
			@media ($mq-min--wcs-steps-horizontal-layout) {
397
				&::after {
398
					content: "";
399
					display: block;
400
					height: $wcs-step-marker-tie-width;
401
					flex: 0 0 100%;
402
					background-color: $wcs-step-marker-tie-color;
403
					margin: auto;
404
				}
405
			}
406

  
407
			@include desktop-vertical-steps() {
408
				position: relative;
409

  
410
				&::after {
411
					height: calc(100% + #{$wcs-steps-spacing});
412
					width: $wcs-step-marker-tie-width;
413

  
414
					position: absolute;
415
					z-index: 1;
416
					top: $wcs-steps-spacing;
417
					left: calc( (#{$wcs-step-marker-size} - #{$wcs-step-marker-tie-width}) / 2 );
418

  
419
					@if $wcs-step-background != transparent {
420
						left: calc( (#{$wcs-step-marker-size} - #{$wcs-step-marker-tie-width}) / 2 + #{$wcs-steps-spacing});
421
					} 
422
				}
423
			}	
424
		}
425

  
426
		&--marker {
427
			position: relative;
428
			z-index: 2;
429
		}
430
	}
431
}
templates/theme.html
49 49
   </div>
50 50

  
51 51
   <div id="page" {% block page-args %}{% endblock %}>
52
    <header role="banner">
52
    <header role="banner" class="site-header">
53 53
    <div id="header-wrapper" >
54 54
    {% block header-pre %}{% endblock %}
55 55
    <div id="header">
templates/wcs/front/formdata_steps.html
1
<header id="steps" class="wcs-steps steps-{{page_labels|length}}">
2
<ol class="wcs-steps--list">
3
{% for page_label in page_labels %}
4
{% spaceless %}
5
<li {% if forloop.counter != current_page_no %}aria-hidden="true"{% endif %}
6
	class="wcs-step
7
           {% if forloop.first %}first{% endif %}
8
           {% if forloop.last %}last{% endif %}
9
           {% if forloop.counter == current_page_no %}current{% endif %}
10
           {% if forloop.counter < current_page_no %}step-before{% endif %}
11
           {% if forloop.counter > current_page_no %}step-after{% endif %}" >
12
	<abbr 
13
		{% if forloop.counter == current_page_no %}
14
			aria-label="Étape {{ forloop.counter }} sur {{ page_labels|length }}:"
15
			title="Étape {{ forloop.counter }} sur {{ page_labels|length }}"
16
		{% endif %}
17
			class="marker wcs-step--marker">
18
		<span class="wcs-step--marker-nb">
19
			{{ forloop.counter }}			
20
		</span>
21
		<span class="wcs-step--marker-total">
22
			{{ page_labels|length }}
23
		</span>
24
	</abbr>
25
	<span class="label wcs-step--label">{{ page_label }}</span>
26
</li>
27
{% endspaceless %}
28
{% endfor %}
29
</ol>
30
</header>
0
-