@ons/design-system 52.0.0 → 53.0.0

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.
Files changed (39) hide show
  1. package/components/button/_button.scss +75 -33
  2. package/components/button/_macro.njk +1 -1
  3. package/components/button/_macro.spec.js +2 -2
  4. package/components/external-link/_macro.njk +5 -2
  5. package/components/external-link/_macro.spec.js +18 -1
  6. package/components/footer/_footer.scss +19 -4
  7. package/components/footer/_macro.njk +103 -97
  8. package/components/footer/_macro.spec.js +131 -2
  9. package/components/header/_header.scss +65 -46
  10. package/components/header/_macro.njk +172 -120
  11. package/components/header/_macro.spec.js +85 -29
  12. package/components/hero/_hero.scss +30 -140
  13. package/components/hero/_macro.njk +8 -19
  14. package/components/hero/_macro.spec.js +23 -29
  15. package/components/icons/_macro.njk +257 -29
  16. package/components/icons/_macro.spec.js +6 -6
  17. package/components/input/_input.scss +8 -0
  18. package/components/language-selector/_macro.njk +1 -1
  19. package/components/language-selector/_macro.spec.js +9 -1
  20. package/components/navigation/_macro.njk +42 -35
  21. package/components/navigation/_macro.spec.js +34 -32
  22. package/components/navigation/_navigation.scss +20 -4
  23. package/components/related-content/_macro.njk +13 -21
  24. package/components/related-content/_macro.spec.js +18 -27
  25. package/components/related-content/_section-macro.njk +10 -0
  26. package/components/related-content/_section-macro.spec.js +43 -0
  27. package/components/share-page/_macro.njk +4 -2
  28. package/css/census.css +3 -1
  29. package/css/ids.css +2 -0
  30. package/css/main.css +1 -1
  31. package/img/dummy-brand-logo.svg +1 -0
  32. package/layout/_template.njk +7 -4
  33. package/package.json +1 -1
  34. package/scripts/main.es5.js +2 -2
  35. package/scss/ids.scss +2 -0
  36. package/scss/settings/_census.scss +141 -0
  37. package/scss/settings/_ids.scss +48 -0
  38. package/scss/utilities/_margin.scss +1 -0
  39. package/scss/vars/_colors.scss +5 -2
@@ -1,100 +1,49 @@
1
1
  // Default
2
2
  .ons-hero {
3
3
  background-color: $color-banner-bg;
4
- padding: 2rem 0;
5
-
6
- &__content {
7
- height: 100%;
8
- }
9
- }
10
-
11
- .ons-hero__pre-title {
12
- margin-bottom: 0.5rem;
13
-
14
- @include mq(xxs, m) {
15
- max-width: 145px;
16
- }
17
- }
18
-
19
- .ons-hero__title {
20
- font-size: 2.3rem;
21
- line-height: 1.2;
22
- }
23
-
24
- // Census theme
25
- .ons-hero--census {
26
- background-image: linear-gradient(46deg, $color-branded-tertiary 0%, $color-branded 100%);
27
4
  display: flex;
28
- margin-bottom: 2px;
29
- margin-top: 2px;
30
5
  overflow: hidden;
31
6
  padding: 0;
32
7
  position: relative;
33
- .ons-hero__container {
34
- align-items: flex-end;
8
+
9
+ &__container {
10
+ align-items: center;
35
11
  display: flex;
36
- min-height: 400px;
12
+ min-height: 300px;
37
13
  position: relative;
38
- }
39
- .ons-hero__circle-image,
40
- .ons-hero__circle-gradient,
41
- .ons-hero__circle-lined,
42
- .ons-hero__circle {
43
- position: absolute;
44
- }
45
- .ons-hero__circle-image {
46
- background-color: $color-white;
47
- border-radius: 50%;
48
- height: 300px;
49
- right: -4px;
50
- top: -98px;
51
- width: 300px;
52
- z-index: 2;
53
14
 
54
- img {
55
- border-radius: 50%;
56
- display: block;
57
- height: 100%;
15
+ &--has-collapsible {
16
+ align-items: flex-start; // Prevents undesired shift if not enough content
58
17
  }
59
18
  }
60
- .ons-hero__circle-gradient {
61
- background-image: linear-gradient(-45deg, $color-branded 0%, $color-branded 20%, $color-branded-tertiary 60%, #005489 90%);
62
- border-radius: 50%;
63
- display: block;
64
- height: 182px;
65
- right: -91px; // Half width of circle
66
- top: 0.7rem;
67
- width: 182px;
68
- z-index: 3;
19
+
20
+ &__content {
21
+ height: 100%;
69
22
  }
70
- .ons-hero__circle {
71
- background-color: $color-white;
72
- border-radius: 50%;
73
- display: block;
74
- height: 990px;
75
- left: 50%;
76
- margin-left: -495px; // Half of circle
77
- top: 27px;
78
- width: 990px;
79
- z-index: 1;
23
+
24
+ &__pre-title {
25
+ margin-bottom: 0.5rem;
26
+
27
+ @include mq(xxs, m) {
28
+ max-width: 145px;
29
+ }
80
30
  }
81
- .ons-hero__circle-lined {
82
- fill: $color-white;
83
- height: 133px;
84
- opacity: 0.4;
85
- right: -24px;
86
- top: 114px;
87
- width: 133px;
88
- z-index: 4;
31
+
32
+ &__title {
33
+ font-size: 2.3rem;
34
+ line-height: 1.2;
89
35
  }
90
- .ons-hero__details {
91
- padding-bottom: 1rem;
92
- padding-top: 218px;
36
+
37
+ &__details {
38
+ padding-bottom: 3rem;
39
+ padding-top: 2rem;
93
40
  position: relative;
94
41
  z-index: 5;
42
+ }
95
43
 
96
- &--ondark {
97
- color: $color-text-inverse;
44
+ &--dark & {
45
+ &__details {
46
+ color: $color-text-inverse !important;
98
47
 
99
48
  a {
100
49
  color: inherit;
@@ -105,69 +54,10 @@
105
54
  color: $color-text-inverse-link-hover;
106
55
  text-decoration-thickness: 2px;
107
56
  }
108
- }
109
- }
110
-
111
- @include mq(m) {
112
- .ons-hero__details {
113
- padding-top: 2rem;
114
- }
115
- .ons-hero__circle-image {
116
- height: 382px;
117
- right: -8px;
118
- top: -117px;
119
- width: 382px;
120
- }
121
- .ons-hero__circle-gradient {
122
- height: 234px;
123
- right: -117px; // Half width of circle
124
- top: 1rem;
125
- width: 234px;
126
- }
127
- .ons-hero__circle {
128
- left: -331px;
129
- margin: auto; // Reset
130
- top: -288px;
131
- }
132
- .ons-hero__circle-lined {
133
- height: 171px;
134
- right: -24px;
135
- top: 148px;
136
- width: 171px;
137
- }
138
- .ons-hero__container {
139
- align-items: center;
140
57
 
141
- &--has-collapsible {
142
- align-items: flex-start; // Prevents undesired shift if not enough content
58
+ .ons-collapsible__heading {
59
+ color: inherit;
143
60
  }
144
61
  }
145
62
  }
146
-
147
- @include mq(l) {
148
- .ons-hero__details {
149
- padding-right: 2.5rem;
150
- }
151
- .ons-hero__circle-image {
152
- height: 558px;
153
- margin: auto;
154
- right: 0;
155
- top: -176px;
156
- width: 558px;
157
- }
158
- .ons-hero__circle-gradient {
159
- height: 342px;
160
- right: -171px; // Half width of circle
161
- width: 342px;
162
- }
163
- .ons-hero__circle {
164
- top: -369px;
165
- }
166
- .ons-hero__circle-lined {
167
- height: 243px;
168
- right: 0;
169
- top: 292px; // Reset
170
- width: 243px;
171
- }
172
- }
173
63
  }
@@ -3,7 +3,7 @@
3
3
  {% from "components/icons/_macro.njk" import onsIcon %}
4
4
 
5
5
  {# style adjustments if dark or light skin #}
6
- {% if params.censusThemeDark is defined and params.censusThemeDark %}
6
+ {% if params.variants is defined and 'dark' in params.variants %}
7
7
  {% set skinName = "dark" %}
8
8
  {% else %}
9
9
  {% set skinName = "light" %}
@@ -14,33 +14,22 @@
14
14
  {% set containerClasses = " ons-hero__container--has-collapsible" %}
15
15
  {% endif %}
16
16
 
17
- {# if hero is census-specific or using wide container, change column usage #}
18
- {% if params.censusTheme is defined and params.censusTheme or params.wide is defined and params.wide %}
19
- {% set detailsColumns = "6" %}
20
- {% else %}
21
- {% set detailsColumns = "8" %}
22
- {% endif %}
23
-
24
- {# if hero style is a dark theme, change theme #}
25
- {% if params.censusThemeDark is defined and params.censusThemeDark %}
26
- {% set detailsClasses = " ons-hero__details--ondark" %}
27
- {% endif %}
17
+ {# Set number of columns used for hero content after medium breakpoint #}
18
+ {% set detailsColumns = params.detailsColumns | default ('8') %}
28
19
 
29
- <section class="ons-hero ons-grid--gutterless{% if params.censusTheme is defined and params.censusTheme %} ons-hero--census{% endif %}">
20
+ <section class="ons-hero ons-grid--gutterless{% if params.variants is defined and params.variants %}{% if params.variants is not string %}{% for variant in params.variants %} ons-hero--{{ variant }}{% endfor %}{% else %} ons-hero--{{ params.variants }}{% endif %}{% endif %}">
30
21
 
31
22
  <div class="ons-hero__container ons-container{{ ' ons-container--wide' if params.wide }}{{ containerClasses }}">
32
23
 
33
- <div class="ons-hero__details{{ detailsClasses }} ons-grid__col ons-col-{{ detailsColumns }}@m">
24
+ <div class="ons-hero__details{{ detailsClasses }} ons-grid__col ons-col-{{ detailsColumns }}@m ons-col-10@s@m">
34
25
 
35
26
  <header>
36
27
  {% if params.preTitleImage is defined and params.preTitleImage %}
37
28
  {% set preTitleImageWithModifier = params.preTitleImage.name|replace(r/(\.[^\.]+)$/, "--" + skinName + "$1") %}
38
29
  <img class="ons-hero__pre-title" src="{{ params.placeholderURL }}/img/{{ preTitleImageWithModifier }}" alt="{{ params.preTitleImage.alt }}">
39
30
  {% endif %}
40
- {% if params.censusTheme is defined and params.censusTheme %}
31
+ {% if params.title is defined and params.title %}
41
32
  <h1 class="ons-hero__title ons-u-fs-xxxl">{{ params.title }}</h1>
42
- {% else %}
43
- <h1 class="ons-hero__title">{{ params.title }}</h1>
44
33
  {% endif %}
45
34
  {% if params.subtitle is defined and params.subtitle %}
46
35
  <h2 class="ons-hero__subtitle ons-u-fs-r--b">{{ params.subtitle }}</h2>
@@ -85,7 +74,7 @@
85
74
  {% endif %}
86
75
 
87
76
  </div>
88
- {% if params.censusTheme is defined and params.censusTheme %}
77
+ {% if params.variants is defined and 'census' in params.variants %}
89
78
 
90
79
  {% if params.image is defined and params.image %}
91
80
  <div class="ons-hero__circle-image">
@@ -101,7 +90,7 @@
101
90
 
102
91
  <div class="ons-hero__circle-gradient"></div>
103
92
 
104
- {% if params.censusThemeDark is not defined or params.censusThemeDark == false %}
93
+ {% if (params.variants is defined and 'census' in params.variants) and ('dark' not in params.variants) %}
105
94
  <div class="ons-hero__circle"></div>
106
95
  {% endif %}
107
96
 
@@ -12,13 +12,13 @@ const EXAMPLE_HERO_MINIMAL = {
12
12
  suffixText: 'Hero suffix text',
13
13
  };
14
14
 
15
- const EXAMPLE_HERO_CENSUS_THEME = {
16
- censusTheme: true,
15
+ const EXAMPLE_HERO_CENSUS_VARIANT = {
16
+ variants: 'census',
17
17
  ...EXAMPLE_HERO_MINIMAL,
18
18
  };
19
19
 
20
- const EXAMPLE_HERO_CENSUS_THEME_WITH_IMAGE = {
21
- ...EXAMPLE_HERO_CENSUS_THEME,
20
+ const EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE = {
21
+ ...EXAMPLE_HERO_CENSUS_VARIANT,
22
22
  image: {
23
23
  smallSrc: 'example-small.png',
24
24
  largeSrc: 'example-large.png',
@@ -57,8 +57,8 @@ const EXAMPLE_HERO_WITH_COLLAPSIBLE = {
57
57
  describe('macro: hero', () => {
58
58
  describe.each([
59
59
  ['with text', EXAMPLE_HERO_MINIMAL],
60
- ['with census theme', EXAMPLE_HERO_CENSUS_THEME],
61
- ['with census theme and image', EXAMPLE_HERO_CENSUS_THEME_WITH_IMAGE],
60
+ ['with census variant', EXAMPLE_HERO_CENSUS_VARIANT],
61
+ ['with census variants and image', EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE],
62
62
  ['with button', EXAMPLE_HERO_WITH_BUTTON],
63
63
  ['with pre-title image', EXAMPLE_HERO_WITH_PRETITLE_IMAGE],
64
64
  ['with collapsible', EXAMPLE_HERO_WITH_COLLAPSIBLE],
@@ -70,6 +70,17 @@ describe('macro: hero', () => {
70
70
  expect(results).toHaveNoViolations();
71
71
  });
72
72
 
73
+ it('has provided variant style classes', () => {
74
+ const $ = cheerio.load(
75
+ renderComponent('hero', {
76
+ variants: ['variant-a', 'variant-b'],
77
+ }),
78
+ );
79
+
80
+ expect($('.ons-hero--variant-a').length).toBe(1);
81
+ expect($('.ons-hero--variant-b').length).toBe(1);
82
+ });
83
+
73
84
  it('has expected `title`', () => {
74
85
  const $ = cheerio.load(renderComponent('hero', params));
75
86
 
@@ -112,33 +123,16 @@ describe('macro: hero', () => {
112
123
  });
113
124
  });
114
125
 
115
- describe('mode: with census theme', () => {
116
- it('has the correct theme class', () => {
117
- const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_CENSUS_THEME));
118
- expect($('.ons-hero').hasClass('ons-hero--census')).toBe(true);
119
- });
120
-
121
- it('has the correct grid column class', () => {
122
- const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_CENSUS_THEME));
123
- expect($('.ons-hero__details').hasClass('ons-col-6@m')).toBe(true);
124
- });
125
-
126
- it('has the correct title sizing class', () => {
127
- const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_CENSUS_THEME));
128
- expect($('.ons-hero__title').hasClass('ons-u-fs-xxxl')).toBe(true);
129
- });
130
- });
131
-
132
- describe('mode: with census theme and image', () => {
126
+ describe('mode: with census variant and image', () => {
133
127
  it('has expected `srcset` attribute', () => {
134
- const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_CENSUS_THEME_WITH_IMAGE));
128
+ const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE));
135
129
 
136
130
  const srcset = $('.ons-hero__circle-image img').attr('srcset');
137
131
  expect(srcset).toBe('example-small.png 1x, example-large.png 2x');
138
132
  });
139
133
 
140
134
  it('has expected `src` attribute', () => {
141
- const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_CENSUS_THEME_WITH_IMAGE));
135
+ const $ = cheerio.load(renderComponent('hero', EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE));
142
136
 
143
137
  const src = $('.ons-hero__circle-image img').attr('src');
144
138
  expect(src).toBe('example-small.png');
@@ -148,7 +142,7 @@ describe('macro: hero', () => {
148
142
  const faker = templateFaker();
149
143
  const iconsSpy = faker.spy('icons');
150
144
 
151
- faker.renderComponent('hero', EXAMPLE_HERO_CENSUS_THEME_WITH_IMAGE);
145
+ faker.renderComponent('hero', EXAMPLE_HERO_CENSUS_VARIANT_WITH_IMAGE);
152
146
 
153
147
  expect(iconsSpy.occurrences[0].iconType).toBe('circle-lined');
154
148
  });
@@ -174,10 +168,10 @@ describe('macro: hero', () => {
174
168
  expect(src).toBe('/img/example--light.svg');
175
169
  });
176
170
 
177
- it('has expected `src` attribute with `censusThemeDark`', () => {
171
+ it('has expected `src` attribute with dark variant', () => {
178
172
  const $ = cheerio.load(
179
173
  renderComponent('hero', {
180
- censusThemeDark: true,
174
+ variants: 'dark',
181
175
  ...EXAMPLE_HERO_WITH_PRETITLE_IMAGE,
182
176
  }),
183
177
  );