@ecl/button 5.0.0-alpha.14 → 5.0.0-alpha.16

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/README.md CHANGED
@@ -9,7 +9,9 @@ npm install --save @ecl/button
9
9
  ### Parameters
10
10
 
11
11
  - **"label"** (string) (default: '')
12
- - **"variant"** (string) (default: 'primary'): variant of button (can be 'primary', 'secondary', 'cta', 'ghost', 'ghost-inverted', 'tertiary')
12
+ - **"size"** (string) (default: 'l'): button size
13
+ - **"variant"** (string) (default: 'primary'): can be 'primary', 'secondary', 'tertiary'
14
+ - **"style"** (string) (default: ''): can be 'highlight', 'neutral', 'inverted'. Not all styles are available for all variants
13
15
  - **"type"** (string) (default: 'submit'): can be the same type as HTML button - 'submit', 'reset', 'button'
14
16
  - **"disabled"** (bool) (default: false): define if button should be disabled (HTML disabled attribute)
15
17
  - **"hide_label"** (bool) (default: false): hide button label, for screen reader only. Note: requires to have an icon defined
package/button-print.scss CHANGED
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  @use 'sass:map';
7
+ @use '@ecl/mixins-typography/mixins';
7
8
 
8
9
  // Exposed variables
9
10
  $theme: null !default;
@@ -17,7 +18,6 @@ $button: null !default;
17
18
  border-width: 0;
18
19
  cursor: pointer;
19
20
  display: inline-block;
20
- font: map.get($theme, 'font-ui-print', 'm');
21
21
  margin: 0;
22
22
  text-decoration: none;
23
23
 
@@ -33,66 +33,161 @@ $button: null !default;
33
33
  display: flex;
34
34
  }
35
35
 
36
- .ecl-button__label {
37
- text-align: left;
38
- }
39
-
40
36
  .ecl-button__icon {
41
37
  flex-shrink: 0;
38
+ height: map.get($button, 'large', 'icon-size');
39
+ width: map.get($button, 'large', 'icon-size');
40
+
41
+ .ecl-button--s & {
42
+ height: map.get($button, 'small', 'icon-size');
43
+ width: map.get($button, 'small', 'icon-size');
44
+ }
45
+
46
+ .ecl-button--m & {
47
+ height: map.get($button, 'medium', 'icon-size');
48
+ width: map.get($button, 'medium', 'icon-size');
49
+ }
42
50
  }
43
51
 
44
- .ecl-button__icon ~ .ecl-button__label,
45
- .ecl-button__icon-container ~ .ecl-button__label,
46
- .ecl-button__label ~ .ecl-button__icon,
47
- .ecl-button__label ~ .ecl-button__icon-container {
48
- margin-inline-end: map.get($theme, 'spacing-print', 'xs');
52
+ .ecl-button__icon-container {
53
+ display: flex;
54
+ position: relative;
49
55
  }
50
56
 
51
57
  .ecl-button__indicator {
52
58
  display: none;
53
59
  }
54
60
 
55
- /**
56
- * Button styles
57
- */
61
+ // Icon only
62
+ .ecl-button--icon-only {
63
+ align-items: center;
64
+ display: flex;
65
+ justify-content: center;
66
+ padding: 0 !important;
67
+
68
+ .ecl-button__label {
69
+ display: none;
70
+ }
71
+
72
+ .ecl-button__icon {
73
+ height: map.get($button, 'large', 'icon-only-size');
74
+ width: map.get($button, 'large', 'icon-only-size');
75
+ }
76
+
77
+ &.ecl-button--s .ecl-button__icon {
78
+ height: map.get($button, 'small', 'icon-only-size');
79
+ width: map.get($button, 'small', 'icon-only-size');
80
+ }
81
+
82
+ &.ecl-button--m .ecl-button__icon {
83
+ height: map.get($button, 'medium', 'icon-only-size');
84
+ width: map.get($button, 'medium', 'icon-only-size');
85
+ }
86
+ }
87
+
88
+ .ecl-button:not(.ecl-button--icon-only) {
89
+ .ecl-button__icon ~ .ecl-button__label,
90
+ .ecl-button__icon-container ~ .ecl-button__label,
91
+ .ecl-button__label ~ .ecl-button__icon,
92
+ .ecl-button__label ~ .ecl-button__icon-container {
93
+ margin-inline-start: map.get($button, 'large', 'icon-spacing');
94
+
95
+ .ecl-button--s & {
96
+ margin-inline-start: map.get($button, 'small', 'icon-spacing');
97
+ }
98
+
99
+ .ecl-button--m & {
100
+ margin-inline-start: map.get($button, 'medium', 'icon-spacing');
101
+ }
102
+ }
103
+ }
104
+
105
+ // Button styles
106
+ // stylelint-disable nesting-selector-no-missing-scoping-root
58
107
  @mixin button($variant: null) {
59
108
  background-color: map.get($button, #{$variant}, 'background');
60
109
  border: map.get($button, #{$variant}, 'border-width') solid
61
110
  map.get($button, #{$variant}, 'border-color');
62
111
  color: map.get($button, #{$variant}, 'color');
112
+ min-height: map.get($button, 'large', 'size');
113
+ min-width: map.get($button, 'large', 'size');
63
114
  padding: calc(
64
- #{map.get($button, 'padding-vertical')} -
115
+ #{map.get($button, 'large', 'padding-vertical')} -
65
116
  #{map.get($button, #{$variant}, 'border-width')}
66
117
  )
67
118
  calc(
68
- #{map.get($button, 'padding-horizontal')} -
119
+ #{map.get($button, 'large', 'padding-horizontal')} -
69
120
  #{map.get($button, #{$variant}, 'border-width')}
70
121
  );
122
+
123
+ @include mixins.responsive-font(map.get($button, 'large', 'font'));
124
+
125
+ &.ecl-button--s {
126
+ min-height: map.get($button, 'small', 'size');
127
+ min-width: map.get($button, 'small', 'size');
128
+ padding: calc(
129
+ #{map.get($button, 'small', 'padding-vertical')} -
130
+ #{map.get($button, #{$variant}, 'border-width')}
131
+ )
132
+ calc(
133
+ #{map.get($button, 'small', 'padding-horizontal')} -
134
+ #{map.get($button, #{$variant}, 'border-width')}
135
+ );
136
+
137
+ @include mixins.responsive-font(map.get($button, 'small', 'font'));
138
+ }
139
+
140
+ &.ecl-button--m {
141
+ min-height: map.get($button, 'medium', 'size');
142
+ min-width: map.get($button, 'medium', 'size');
143
+ padding: calc(
144
+ #{map.get($button, 'medium', 'padding-vertical')} -
145
+ #{map.get($button, #{$variant}, 'border-width')}
146
+ )
147
+ calc(
148
+ #{map.get($button, 'medium', 'padding-horizontal')} -
149
+ #{map.get($button, #{$variant}, 'border-width')}
150
+ );
151
+
152
+ @include mixins.responsive-font(map.get($button, 'medium', 'font'));
153
+ }
71
154
  }
155
+ // stylelint-enable nesting-selector-no-missing-scoping-root
72
156
 
157
+ // Primary
73
158
  .ecl-button--primary {
74
159
  @include button(primary);
160
+
161
+ &.ecl-button--highlight {
162
+ @include button(primary-highlight);
163
+ }
164
+
165
+ &.ecl-button--inverted {
166
+ @include button(primary-inverted);
167
+ }
75
168
  }
76
169
 
77
- // stylelint-disable plugin/selector-bem-pattern
78
170
  .ecl-button--secondary,
79
171
  %ecl-button {
80
172
  @include button(secondary);
173
+
174
+ &.ecl-button--neutral {
175
+ @include button(secondary-neutral);
176
+ }
177
+
178
+ &.ecl-button--inverted {
179
+ @include button(secondary-inverted);
180
+ }
81
181
  }
82
- // stylelint-enable plugin/selector-bem-pattern
83
182
 
84
183
  .ecl-button--tertiary {
85
184
  @include button(tertiary);
86
- }
87
185
 
88
- .ecl-button--cta {
89
- @include button(cta);
90
- }
91
-
92
- .ecl-button--ghost {
93
- @include button(ghost);
94
- }
186
+ &.ecl-button--neutral {
187
+ @include button(tertiary-neutral);
188
+ }
95
189
 
96
- .ecl-button--ghost-inverted {
97
- @include button(ghost-inverted);
190
+ &.ecl-button--inverted {
191
+ @include button(tertiary-inverted);
192
+ }
98
193
  }
package/button.html.twig CHANGED
@@ -4,7 +4,9 @@
4
4
  {#
5
5
  Parameters:
6
6
  - "label" (string) (default: '')
7
- - "variant" (string) (default: 'primary'): can be 'primary', 'secondary', 'cta', 'ghost', 'ghost-inverted', 'tertiary'
7
+ - "size" (string) (default: 'l'): button size
8
+ - "variant" (string) (default: 'primary'): can be 'primary', 'secondary', 'tertiary'
9
+ - "style" (string) (default: ''): can be 'highlight', 'neutral', 'inverted'. Not all styles are available for all variants
8
10
  - "type" (string) (default: 'submit'): can be the same type as HTML button - 'submit', 'reset', 'button'
9
11
  - "icon" (associative array) OR (array) of associative arrays : format
10
12
  {
@@ -43,7 +45,9 @@
43
45
  {% set _css_class = 'ecl-button' %}
44
46
  {% set _extra_attributes = '' %}
45
47
  {% set _label = label|default('') %}
48
+ {% set _size = size|default('l') %}
46
49
  {% set _variant = variant|default('primary') %}
50
+ {% set _style = style|default('') %}
47
51
  {% set _type = type|default('submit') %}
48
52
  {% set _icon_position = icon_position|default('after') %}
49
53
  {% set _disabled = disabled|default(false) %}
@@ -59,6 +63,14 @@
59
63
 
60
64
  {% set _css_class = _css_class ~ ' ecl-button--' ~ _variant %}
61
65
 
66
+ {% if _size != 'l' %}
67
+ {% set _css_class = _css_class ~ ' ecl-button--' ~ _size %}
68
+ {% endif %}
69
+
70
+ {% if _style is not empty %}
71
+ {% set _css_class = _css_class ~ ' ecl-button--' ~ _style %}
72
+ {% endif %}
73
+
62
74
  {% if extra_classes is defined and extra_classes is not empty %}
63
75
  {% set _css_class = _css_class ~ ' ' ~ extra_classes %}
64
76
  {% endif %}
package/button.scss CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  @use 'sass:map';
7
7
  @use '@ecl/utility-screen-reader/screen-reader';
8
+ @use '@ecl/mixins-typography/mixins';
8
9
 
9
10
  // Exposed variables
10
11
  $theme: null !default;
@@ -19,10 +20,7 @@ $button: null !default;
19
20
  box-sizing: border-box;
20
21
  cursor: pointer;
21
22
  display: inline-block;
22
- font: map.get($button, 'font');
23
23
  margin: 0;
24
- min-height: map.get($button, 'min-height');
25
- min-width: map.get($button, 'min-width');
26
24
  text-decoration: none;
27
25
 
28
26
  &:hover {
@@ -53,6 +51,18 @@ $button: null !default;
53
51
 
54
52
  .ecl-button__icon {
55
53
  flex-shrink: 0;
54
+ height: map.get($button, 'large', 'icon-size');
55
+ width: map.get($button, 'large', 'icon-size');
56
+
57
+ .ecl-button--s & {
58
+ height: map.get($button, 'small', 'icon-size');
59
+ width: map.get($button, 'small', 'icon-size');
60
+ }
61
+
62
+ .ecl-button--m & {
63
+ height: map.get($button, 'medium', 'icon-size');
64
+ width: map.get($button, 'medium', 'icon-size');
65
+ }
56
66
  }
57
67
 
58
68
  .ecl-button__icon-container {
@@ -64,13 +74,6 @@ $button: null !default;
64
74
  display: none;
65
75
  }
66
76
 
67
- .ecl-button__icon ~ .ecl-button__label,
68
- .ecl-button__icon-container ~ .ecl-button__label,
69
- .ecl-button__label ~ .ecl-button__icon,
70
- .ecl-button__label ~ .ecl-button__icon-container {
71
- margin-inline-start: var(--s-xs);
72
- }
73
-
74
77
  // Icon only
75
78
  .ecl-button--icon-only {
76
79
  align-items: center;
@@ -82,34 +85,89 @@ $button: null !default;
82
85
  @include screen-reader.sr-only;
83
86
  }
84
87
 
85
- .ecl-button__icon,
86
- .ecl-button__icon-container {
87
- margin: 0;
88
+ .ecl-button__icon {
89
+ height: map.get($button, 'large', 'icon-only-size');
90
+ width: map.get($button, 'large', 'icon-only-size');
88
91
  }
89
92
 
90
- .ecl-button__icon {
91
- height: map.get($theme, 'icon', 'm');
92
- width: map.get($theme, 'icon', 'm');
93
+ &.ecl-button--s .ecl-button__icon {
94
+ height: map.get($button, 'small', 'icon-only-size');
95
+ width: map.get($button, 'small', 'icon-only-size');
96
+ }
97
+
98
+ &.ecl-button--m .ecl-button__icon {
99
+ height: map.get($button, 'medium', 'icon-only-size');
100
+ width: map.get($button, 'medium', 'icon-only-size');
93
101
  }
94
102
  }
95
103
 
96
- /**
97
- * Button styles
98
- */
104
+ .ecl-button:not(.ecl-button--icon-only) {
105
+ .ecl-button__icon ~ .ecl-button__label,
106
+ .ecl-button__icon-container ~ .ecl-button__label,
107
+ .ecl-button__label ~ .ecl-button__icon,
108
+ .ecl-button__label ~ .ecl-button__icon-container {
109
+ margin-inline-start: map.get($button, 'large', 'icon-spacing');
110
+
111
+ .ecl-button--s & {
112
+ margin-inline-start: map.get($button, 'small', 'icon-spacing');
113
+ }
114
+
115
+ .ecl-button--m & {
116
+ margin-inline-start: map.get($button, 'medium', 'icon-spacing');
117
+ }
118
+ }
119
+ }
120
+
121
+ // Button styles
122
+ // stylelint-disable nesting-selector-no-missing-scoping-root
99
123
  @mixin button($variant: null) {
100
124
  background-color: map.get($button, #{$variant}, 'background');
101
125
  border: map.get($button, #{$variant}, 'border-width') solid
102
126
  map.get($button, #{$variant}, 'border-color');
103
127
  color: map.get($button, #{$variant}, 'color');
128
+ min-height: map.get($button, 'large', 'size');
129
+ min-width: map.get($button, 'large', 'size');
104
130
  padding: calc(
105
- #{map.get($button, 'padding-vertical')} -
131
+ #{map.get($button, 'large', 'padding-vertical')} -
106
132
  #{map.get($button, #{$variant}, 'border-width')}
107
133
  )
108
134
  calc(
109
- #{map.get($button, 'padding-horizontal')} -
135
+ #{map.get($button, 'large', 'padding-horizontal')} -
110
136
  #{map.get($button, #{$variant}, 'border-width')}
111
137
  );
112
138
 
139
+ @include mixins.responsive-font(map.get($button, 'large', 'font'));
140
+
141
+ &.ecl-button--s {
142
+ min-height: map.get($button, 'small', 'size');
143
+ min-width: map.get($button, 'small', 'size');
144
+ padding: calc(
145
+ #{map.get($button, 'small', 'padding-vertical')} -
146
+ #{map.get($button, #{$variant}, 'border-width')}
147
+ )
148
+ calc(
149
+ #{map.get($button, 'small', 'padding-horizontal')} -
150
+ #{map.get($button, #{$variant}, 'border-width')}
151
+ );
152
+
153
+ @include mixins.responsive-font(map.get($button, 'small', 'font'));
154
+ }
155
+
156
+ &.ecl-button--m {
157
+ min-height: map.get($button, 'medium', 'size');
158
+ min-width: map.get($button, 'medium', 'size');
159
+ padding: calc(
160
+ #{map.get($button, 'medium', 'padding-vertical')} -
161
+ #{map.get($button, #{$variant}, 'border-width')}
162
+ )
163
+ calc(
164
+ #{map.get($button, 'medium', 'padding-horizontal')} -
165
+ #{map.get($button, #{$variant}, 'border-width')}
166
+ );
167
+
168
+ @include mixins.responsive-font(map.get($button, 'medium', 'font'));
169
+ }
170
+
113
171
  &:hover {
114
172
  background-color: map.get($button, #{$variant}, 'background-hover');
115
173
  border-color: map.get($button, #{$variant}, 'border-color-hover');
@@ -123,6 +181,46 @@ $button: null !default;
123
181
  outline: #{map.get($button, #{$variant}, 'outline-width')} solid
124
182
  #{map.get($button, #{$variant}, 'outline-color')};
125
183
  outline-offset: map.get($button, #{$variant}, 'outline-offset');
184
+
185
+ @if map.has-key($button, #{$variant}, 'shadow-focus') {
186
+ box-shadow: map.get($button, #{$variant}, 'shadow-focus');
187
+ }
188
+ }
189
+
190
+ @if map.has-key($button, #{$variant}, 'border-width-focus') {
191
+ &:focus-visible {
192
+ border-width: map.get($button, #{$variant}, 'border-width-focus');
193
+ padding: calc(
194
+ #{map.get($button, 'large', 'padding-vertical')} -
195
+ #{map.get($button, #{$variant}, 'border-width-focus')}
196
+ )
197
+ calc(
198
+ #{map.get($button, 'large', 'padding-horizontal')} -
199
+ #{map.get($button, #{$variant}, 'border-width-focus')}
200
+ );
201
+ }
202
+
203
+ &.ecl-button--s:focus-visible {
204
+ padding: calc(
205
+ #{map.get($button, 'small', 'padding-vertical')} -
206
+ #{map.get($button, #{$variant}, 'border-width-focus')}
207
+ )
208
+ calc(
209
+ #{map.get($button, 'small', 'padding-horizontal')} -
210
+ #{map.get($button, #{$variant}, 'border-width-focus')}
211
+ );
212
+ }
213
+
214
+ &.ecl-button--m:focus-visible {
215
+ padding: calc(
216
+ #{map.get($button, 'medium', 'padding-vertical')} -
217
+ #{map.get($button, #{$variant}, 'border-width-focus')}
218
+ )
219
+ calc(
220
+ #{map.get($button, 'medium', 'padding-horizontal')} -
221
+ #{map.get($button, #{$variant}, 'border-width-focus')}
222
+ );
223
+ }
126
224
  }
127
225
 
128
226
  &:active {
@@ -131,34 +229,42 @@ $button: null !default;
131
229
  color: map.get($button, #{$variant}, 'color-active');
132
230
  }
133
231
  }
232
+ // stylelint-enable nesting-selector-no-missing-scoping-root
134
233
 
234
+ // Primary
135
235
  .ecl-button--primary {
136
236
  @include button(primary);
237
+
238
+ &.ecl-button--highlight {
239
+ @include button(primary-highlight);
240
+ }
241
+
242
+ &.ecl-button--inverted {
243
+ @include button(primary-inverted);
244
+ }
137
245
  }
138
246
 
139
- // stylelint-disable plugin/selector-bem-pattern
140
247
  .ecl-button--secondary,
141
248
  %ecl-button {
142
249
  @include button(secondary);
143
250
 
144
- &:focus-visible {
145
- box-shadow: map.get($button, 'secondary', 'focus-shadow');
251
+ &.ecl-button--neutral {
252
+ @include button(secondary-neutral);
253
+ }
254
+
255
+ &.ecl-button--inverted {
256
+ @include button(secondary-inverted);
146
257
  }
147
258
  }
148
- // stylelint-enable plugin/selector-bem-pattern
149
259
 
150
260
  .ecl-button--tertiary {
151
261
  @include button(tertiary);
152
- }
153
262
 
154
- .ecl-button--cta {
155
- @include button(cta);
156
- }
157
-
158
- .ecl-button--ghost {
159
- @include button(ghost);
160
- }
263
+ &.ecl-button--neutral {
264
+ @include button(tertiary-neutral);
265
+ }
161
266
 
162
- .ecl-button--ghost-inverted {
163
- @include button(ghost-inverted);
267
+ &.ecl-button--inverted {
268
+ @include button(tertiary-inverted);
269
+ }
164
270
  }
package/package.json CHANGED
@@ -2,18 +2,20 @@
2
2
  "name": "@ecl/button",
3
3
  "author": "European Commission",
4
4
  "license": "EUPL-1.2",
5
- "version": "5.0.0-alpha.14",
5
+ "version": "5.0.0-alpha.16",
6
6
  "description": "ECL Button",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
10
  "style": "button.scss",
11
11
  "dependencies": {
12
- "@ecl/icon": "5.0.0-alpha.14",
13
- "@ecl/indicator": "5.0.0-alpha.14"
12
+ "@ecl/icon": "5.0.0-alpha.16",
13
+ "@ecl/indicator": "5.0.0-alpha.16"
14
14
  },
15
15
  "devDependencies": {
16
- "@ecl/resources-icons": "5.0.0-alpha.14"
16
+ "@ecl/mixins-typography": "5.0.0-alpha.16",
17
+ "@ecl/resources-icons": "5.0.0-alpha.16",
18
+ "@ecl/utility-screen-reader": "5.0.0-alpha.16"
17
19
  },
18
20
  "repository": {
19
21
  "type": "git",
@@ -29,5 +31,5 @@
29
31
  "design-system",
30
32
  "twig"
31
33
  ],
32
- "gitHead": "5f790fa1e567483d23464f81405996c9e1c4f4f5"
34
+ "gitHead": "0842ff3b72ce9099c13e5407ad2b5eda9d06ba69"
33
35
  }