energy-foundations 2.4.0 → 2.5.0-beta.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.
@@ -1,31 +1,194 @@
1
+ @use 'sass:list';
1
2
  @use 'sass:map';
3
+ @use 'sass:selector';
4
+ @use 'sass:string';
5
+ @use '../variables/grid' as *;
2
6
  @use '../variables/layout' as *;
7
+ @use 'breakpoint-fixed' as *;
3
8
 
4
- // Responsive media queries
9
+ $_layout-b-keys: (
10
+ mobile: mobile-v2,
11
+ tablet: tablet-v2,
12
+ desktop: desktop-v2,
13
+ desktop-large: desktop-large-v2,
14
+ ultrawide: ultrawide-v2
15
+ );
16
+
17
+ $_layout-conditions: (
18
+ a: ":not([data-rds-layout='b'])",
19
+ b: "[data-rds-layout='b']"
20
+ );
21
+
22
+ // Layout resolved by an enclosing breakpoint; nested calls reuse it instead of adding a second body context.
23
+ $_active-layout: null;
24
+
25
+ // Responsive media queries that follow the layout declared on body[data-rds-layout].
26
+ // Semantic keys use Layout A by default and their *-v2 values with body[data-rds-layout='b'].
27
+ // Explicit *-v2 and custom keys are fixed media queries.
5
28
  // use:
6
29
  // .element {
7
- // @include breakpoint(mobile|tablet|desktop|desktop-large|ultrawide){
30
+ // @include breakpoint(mobile|tablet|desktop|desktop-large|ultrawide) {
31
+ // ...
32
+ // }
33
+ // }
34
+ // or at the root:
35
+ // @include breakpoint(tablet) {
36
+ // .element {
8
37
  // ...
9
38
  // }
10
- // }
39
+ // }
11
40
  @mixin breakpoint($breakpoint) {
12
- $value: map.get($breakpoints, $breakpoint);
41
+ @if map.has-key($_layout-b-keys, $breakpoint) {
42
+ $layout-b-key: map.get($_layout-b-keys, $breakpoint);
43
+
44
+ @if not map.get($breakpoints, $breakpoint) or not map.get($breakpoints, $layout-b-key) {
45
+ @error 'Missing layout A/B values for breakpoint: #{$breakpoint}.';
46
+ }
13
47
 
14
- // If the key exists in the map
15
- @if $value {
16
- @if $breakpoint == mobile or $breakpoint == mobile-v2 {
17
- @media (max-width: $value) {
48
+ @if $_active-layout == a {
49
+ @include fixed-breakpoint($breakpoint) {
18
50
  @content;
19
51
  }
20
- } @else {
21
- @media (min-width: $value) {
52
+ } @else if $_active-layout == b {
53
+ @include fixed-breakpoint($layout-b-key) {
22
54
  @content;
23
55
  }
56
+ } @else {
57
+ @include _layout-context(a) {
58
+ @include fixed-breakpoint($breakpoint) {
59
+ @content;
60
+ }
61
+ }
62
+
63
+ @include _layout-context(b) {
64
+ @include fixed-breakpoint($layout-b-key) {
65
+ @content;
66
+ }
67
+ }
68
+ }
69
+ } @else {
70
+ @include fixed-breakpoint($breakpoint) {
71
+ @content;
72
+ }
73
+ }
74
+ }
75
+
76
+ @mixin _layout-context($layout) {
77
+ $previous-layout: $_active-layout;
78
+ $condition: map.get($_layout-conditions, $layout);
79
+
80
+ @if $previous-layout == $layout {
81
+ // Already resolved by an enclosing breakpoint: do not add a second body condition.
82
+ @content;
83
+ } @else if $previous-layout {
84
+ // Nested inside the other layout: these rules can never match.
85
+ } @else if & {
86
+ $_active-layout: $layout !global;
87
+
88
+ @at-root #{_contextualize(&, $condition)} {
89
+ @content;
90
+ }
91
+ } @else {
92
+ $_active-layout: $layout !global;
93
+
94
+ // At the root the context prefixes the selectors written inside the content.
95
+ :where(body#{$condition}) {
96
+ @content;
24
97
  }
25
98
  }
26
99
 
27
- // If the key doesn't exist in the map
28
- @else {
29
- @warn "Unfortunately, no value could be retrieved from `#{$breakpoint}`. " + "Please make sure it is defined in `$breakpoints` map.";
100
+ $_active-layout: $previous-layout !global;
101
+ }
102
+
103
+ // Page container that follows the layout declared on body[data-rds-layout].
104
+ // Layout A: 16/24/32px gutters and 1600px max width. Layout B: up to 72px gutters and 1584px max width.
105
+ // use:
106
+ // .portal-main {
107
+ // @include layout-max;
108
+ // }
109
+ @mixin layout-max {
110
+ @if not & {
111
+ @error 'layout-max must be included inside a selector, e.g. `.portal-main { @include layout-max; }`.';
112
+ }
113
+
114
+ padding: 0 $g-padding-mobile;
115
+
116
+ @include breakpoint(tablet) {
117
+ padding: 0 $g-padding-tablet;
30
118
  }
119
+
120
+ @include breakpoint(desktop) {
121
+ padding: 0 $g-padding-desktop;
122
+ }
123
+
124
+ @include _layout-context(a) {
125
+ @include fixed-breakpoint(ultrawide) {
126
+ margin: 0 auto;
127
+ max-width: 1600px;
128
+ padding: 0 $g-padding-ultrawide;
129
+ }
130
+ }
131
+
132
+ @include _layout-context(b) {
133
+ @include fixed-breakpoint(desktop-large-v2) {
134
+ padding: 0 72px;
135
+ }
136
+
137
+ @include fixed-breakpoint(ultrawide-v2) {
138
+ margin: 0 auto;
139
+ max-width: 1584px;
140
+ padding: 0 72px;
141
+ }
142
+ }
143
+ }
144
+
145
+ // The condition is checked on the selected element itself, so other conditions such as `.dark` or `[dir='rtl']`
146
+ // keep working when they live on body or html. It is inserted at the start of the last compound (after a type
147
+ // selector), so `&--modifier`, `&__element` and pseudo-elements can still be appended by the content.
148
+ @function _contextualize($selector, $condition) {
149
+ $result: ();
150
+
151
+ @each $complex in selector.parse($selector) {
152
+ $subject: list.nth($complex, -1);
153
+ $check: ':where(body#{$condition}, body#{$condition} *)';
154
+
155
+ @if _starts-with-type($subject, 'html') or _starts-with-type($subject, ':root') {
156
+ // html and :root are never inside body: they check their child body, which requires :has().
157
+ $check: ':where(:has(> body#{$condition}))';
158
+ }
159
+
160
+ $result: list.append($result, list.set-nth($complex, -1, _insert-after-type($subject, $check)), $separator: comma);
161
+ }
162
+
163
+ @return $result;
164
+ }
165
+
166
+ // A type or universal selector must stay first in a compound selector.
167
+ @function _insert-after-type($compound, $check) {
168
+ $compound: '#{$compound}';
169
+ $position: 1;
170
+
171
+ @if not string.index('.#[:', string.slice($compound, 1, 1)) {
172
+ @while $position <= string.length($compound) and not string.index('.#[:', string.slice($compound, $position, $position)) {
173
+ $position: $position + 1;
174
+ }
175
+ }
176
+
177
+ @return string.unquote(string.insert($compound, $check, $position));
178
+ }
179
+
180
+ @function _starts-with-type($compound, $type) {
181
+ $compound: string.to-lower-case('#{$compound}');
182
+
183
+ @if string.index($compound, $type) != 1 {
184
+ @return false;
185
+ }
186
+
187
+ @if string.length($compound) == string.length($type) {
188
+ @return true;
189
+ }
190
+
191
+ $next: string.slice($compound, string.length($type) + 1, string.length($type) + 1);
192
+
193
+ @return not string.index('abcdefghijklmnopqrstuvwxyz0123456789-_', $next);
31
194
  }
@@ -3,7 +3,7 @@
3
3
 
4
4
  @use '../variables/typography' as *;
5
5
  @use '../mixins/utils' as *;
6
- @use '../mixins/layout' as *;
6
+ @use '../mixins/breakpoint-fixed' as *;
7
7
 
8
8
  @mixin numeric-typography($name) {
9
9
  @if string.index($name, 'numbers') {
@@ -34,7 +34,7 @@
34
34
  }
35
35
  }
36
36
 
37
- // Include font styles. Three versions: ld, sd or fluid
37
+ // Include font styles. Mobile, Desktop or responsive.
38
38
  // use:
39
39
  // .element {
40
40
  // @include rds-font-style(rds-typography-headline-1);
@@ -70,22 +70,37 @@
70
70
 
71
71
  @mixin rds-font-style($name) {
72
72
  @if map.has-key($rds-types-fluid, $name) {
73
-
74
73
  @include rds-font-style-sd($name);
75
74
 
76
-
77
- @include breakpoint(tablet) {
75
+ @include fixed-breakpoint(tablet) {
78
76
  @include rds-font-style-md($name);
79
77
  }
80
78
 
81
- @include breakpoint(desktop) {
79
+ @include fixed-breakpoint(desktop) {
82
80
  @include rds-font-style-ld($name);
83
81
  }
84
82
 
85
- @include breakpoint(ultrawide) {
83
+ @include fixed-breakpoint(ultrawide) {
86
84
  @include rds-font-style-xd($name);
87
85
  }
88
-
86
+
87
+ :where(body[data-rds-layout='b']) & {
88
+ @include fixed-breakpoint(tablet) {
89
+ @include rds-font-style-sd($name);
90
+ }
91
+
92
+ @include fixed-breakpoint(tablet-v2) {
93
+ @include rds-font-style-md($name);
94
+ }
95
+
96
+ @include fixed-breakpoint(desktop-v2) {
97
+ @include rds-font-style-ld($name);
98
+ }
99
+
100
+ @include fixed-breakpoint(ultrawide-v2) {
101
+ @include rds-font-style-xd($name);
102
+ }
103
+ }
89
104
  } @else {
90
105
  @include rds-font-style-sd($name);
91
106
  }
@@ -5,7 +5,7 @@ $grid-config: (
5
5
  desktop: (max-columns: 12, gap: 24px)
6
6
  ) !default;
7
7
 
8
- $grid-config-editorial: (
8
+ $grid-config-b: (
9
9
  mobile-v2: (max-columns: 4, gap: 16px),
10
10
  tablet-v2: (max-columns: 8, gap: 24px),
11
11
  desktop-v2: (max-columns: 12, gap: 24px)
@@ -56,7 +56,7 @@ $rds-typography-body-01-bold: (
56
56
  );
57
57
 
58
58
  $rds-typography-body-01-underline: (
59
- font: #{calc(16 / $f-base) + rem} / #{calc(21 / $f-base) + rem} $rds-typography-f-text,
59
+ font: #{calc(16 / $f-base) + rem} / #{calc(24 / $f-base) + rem} $rds-typography-f-text,
60
60
  );
61
61
 
62
62
  $rds-typography-body-02: (
@@ -124,7 +124,7 @@ $rds-typography-headline-00: (
124
124
  font: #{calc(40 / $f-base) + rem} / #{calc(48 / $f-base) + rem} $rds-typography-f-headline
125
125
  ),
126
126
  md: (
127
- font: #{calc(56 / $f-base) + rem} / #{calc(68 / $f-base) + rem} $rds-typography-f-headline
127
+ font: #{calc(40 / $f-base) + rem} / #{calc(48 / $f-base) + rem} $rds-typography-f-headline
128
128
  ),
129
129
  ld: (
130
130
  font: #{calc(64 / $f-base) + rem} / #{calc(80 / $f-base) + rem} $rds-typography-f-headline
@@ -139,7 +139,7 @@ $rds-typography-headline-01: (
139
139
  font: #{calc(32 / $f-base) + rem} / #{calc(40 / $f-base) + rem} $rds-typography-f-headline
140
140
  ),
141
141
  md: (
142
- font: #{calc(40 / $f-base) + rem} / #{calc(48 / $f-base) + rem} $rds-typography-f-headline
142
+ font: #{calc(32 / $f-base) + rem} / #{calc(40 / $f-base) + rem} $rds-typography-f-headline
143
143
  ),
144
144
  ld: (
145
145
  font: #{calc(48 / $f-base) + rem} / #{calc(60 / $f-base) + rem} $rds-typography-f-headline
@@ -155,7 +155,7 @@ $rds-typography-headline-02: (
155
155
  font: #{calc(28 / $f-base) + rem} / #{calc(36 / $f-base) + rem} $rds-typography-f-headline
156
156
  ),
157
157
  md: (
158
- font: #{calc(32 / $f-base) + rem} / #{calc(40 / $f-base) + rem} $rds-typography-f-headline
158
+ font: #{calc(28 / $f-base) + rem} / #{calc(36 / $f-base) + rem} $rds-typography-f-headline
159
159
  ),
160
160
  ld: (
161
161
  font: #{calc(36 / $f-base) + rem} / #{calc(48 / $f-base) + rem} $rds-typography-f-headline
@@ -170,7 +170,7 @@ $rds-typography-headline-03: (
170
170
  font: #{calc(22 / $f-base) + rem} / #{calc(30 / $f-base) + rem} $rds-typography-f-headline
171
171
  ),
172
172
  md: (
173
- font: #{calc(24 / $f-base) + rem} / #{calc(32 / $f-base) + rem} $rds-typography-f-headline
173
+ font: #{calc(22 / $f-base) + rem} / #{calc(30 / $f-base) + rem} $rds-typography-f-headline
174
174
  ),
175
175
  ld: (
176
176
  font: #{calc(28 / $f-base) + rem} / #{calc(36 / $f-base) + rem} $rds-typography-f-headline
@@ -265,9 +265,9 @@ $rds-types-all: (
265
265
  caption-tag: $rds-typography-caption-tag,
266
266
  body-01: $rds-typography-body-01,
267
267
  body-02: $rds-typography-body-02,
268
- body-01-bold: $rds-typography-body-01-underline,
268
+ body-01-bold: $rds-typography-body-01-bold,
269
269
  body-01-underline: $rds-typography-body-01-underline,
270
- body-02-bold: $rds-typography-body-02-underline,
270
+ body-02-bold: $rds-typography-body-02-bold,
271
271
  body-02-underline: $rds-typography-body-02-underline,
272
272
  button-01: $rds-typography-button-01,
273
273
  button-02: $rds-typography-button-02,
package/src/variables.css CHANGED
@@ -28,7 +28,7 @@
28
28
  --rds-body-01: 1rem/1.5rem RepsolSoleTextRegular;
29
29
  --rds-body-02: 0.875rem/1.25rem RepsolSoleTextRegular;
30
30
  --rds-body-01-bold: 1rem/1.5rem RepsolSoleTextBold;
31
- --rds-body-01-underline: 1rem/1.3125rem RepsolSoleTextRegular;
31
+ --rds-body-01-underline: 1rem/1.5rem RepsolSoleTextRegular;
32
32
  --rds-body-02-bold: 0.875rem/1.25rem RepsolSoleTextBold;
33
33
  --rds-body-02-underline: 0.875rem/1.25rem RepsolSoleTextRegular;
34
34
  --rds-button-01: 1rem/1.5rem RepsolSoleTextBold;
@@ -44,19 +44,19 @@
44
44
  --rds-title-01: 1.125rem/1.625rem RepsolSoleTextBold;
45
45
  --rds-title-02: 1rem/1.5rem RepsolSoleTextBold;
46
46
  --rds-headline-00-sd: 2.5rem/3rem RepsolSoleDisplayRegular;
47
- --rds-headline-00-md: 3.5rem/4.25rem RepsolSoleDisplayRegular;
47
+ --rds-headline-00-md: 2.5rem/3rem RepsolSoleDisplayRegular;
48
48
  --rds-headline-00-ld: 4rem/5rem RepsolSoleDisplayRegular;
49
49
  --rds-headline-00-xd: 4.5rem/5.75rem RepsolSoleDisplayRegular;
50
50
  --rds-headline-01-sd: 2rem/2.5rem RepsolSoleDisplayRegular;
51
- --rds-headline-01-md: 2.5rem/3rem RepsolSoleDisplayRegular;
51
+ --rds-headline-01-md: 2rem/2.5rem RepsolSoleDisplayRegular;
52
52
  --rds-headline-01-ld: 3rem/3.75rem RepsolSoleDisplayRegular;
53
53
  --rds-headline-01-xd: 3.5rem/4.25rem RepsolSoleDisplayRegular;
54
54
  --rds-headline-02-sd: 1.75rem/2.25rem RepsolSoleDisplayRegular;
55
- --rds-headline-02-md: 2rem/2.5rem RepsolSoleDisplayRegular;
55
+ --rds-headline-02-md: 1.75rem/2.25rem RepsolSoleDisplayRegular;
56
56
  --rds-headline-02-ld: 2.25rem/3rem RepsolSoleDisplayRegular;
57
57
  --rds-headline-02-xd: 2.75rem/3.5rem RepsolSoleDisplayRegular;
58
58
  --rds-headline-03-sd: 1.375rem/1.875rem RepsolSoleDisplayRegular;
59
- --rds-headline-03-md: 1.5rem/2rem RepsolSoleDisplayRegular;
59
+ --rds-headline-03-md: 1.375rem/1.875rem RepsolSoleDisplayRegular;
60
60
  --rds-headline-03-ld: 1.75rem/2.25rem RepsolSoleDisplayRegular;
61
61
  --rds-headline-03-xd: 2rem/2.5rem RepsolSoleDisplayRegular;
62
62
  --rds-headline-04-sd: 1.125rem/1.625rem RepsolSoleDisplayRegular;