@nationalarchives/frontend 0.1.6-prerelease → 0.1.7-prerelease

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 (49) hide show
  1. package/govuk-prototype-kit.config.json +12 -5
  2. package/nationalarchives/all.css +1 -1
  3. package/nationalarchives/all.css.map +1 -1
  4. package/nationalarchives/all.js +1 -1
  5. package/nationalarchives/all.js.map +1 -1
  6. package/nationalarchives/components/_all.scss +1 -0
  7. package/nationalarchives/components/breadcrumbs/_index.scss +68 -0
  8. package/nationalarchives/components/breadcrumbs/breadcrumbs.stories.js +57 -0
  9. package/nationalarchives/components/breadcrumbs/fixtures.json +26 -0
  10. package/nationalarchives/components/breadcrumbs/macro-options.json +40 -0
  11. package/nationalarchives/components/breadcrumbs/macro.njk +3 -0
  12. package/nationalarchives/components/breadcrumbs/template.njk +13 -0
  13. package/nationalarchives/components/button/_index.scss +6 -6
  14. package/nationalarchives/components/button/button.stories.js +1 -1
  15. package/nationalarchives/components/card/_index.scss +52 -61
  16. package/nationalarchives/components/card/card.stories.js +3 -3
  17. package/nationalarchives/components/card/template.njk +1 -1
  18. package/nationalarchives/components/footer/_index.scss +54 -54
  19. package/nationalarchives/components/footer/footer.stories.js +1 -1
  20. package/nationalarchives/components/grid/_index.scss +79 -82
  21. package/nationalarchives/components/grid/grid.stories.js +4 -1
  22. package/nationalarchives/components/grid/macro-options.json +7 -1
  23. package/nationalarchives/components/grid/template.njk +3 -0
  24. package/nationalarchives/components/hero/_index.scss +132 -0
  25. package/nationalarchives/components/hero/fixtures.json +4 -0
  26. package/nationalarchives/components/hero/hero.stories.js +74 -0
  27. package/nationalarchives/components/hero/macro-options.json +58 -0
  28. package/nationalarchives/components/hero/macro.njk +3 -0
  29. package/nationalarchives/components/hero/template.njk +30 -0
  30. package/nationalarchives/components/sensitive-image/_index.scss +49 -53
  31. package/nationalarchives/components/sensitive-image/sensitive-image.js +1 -1
  32. package/nationalarchives/components/sensitive-image/sensitive-image.js.map +1 -1
  33. package/nationalarchives/components/sensitive-image/sensitive-image.mjs +1 -1
  34. package/nationalarchives/components/sensitive-image/sensitive-image.stories.js +37 -1
  35. package/nationalarchives/stories/development/about.mdx +1 -1
  36. package/nationalarchives/stories/development/publishing.mdx +1 -0
  37. package/nationalarchives/templates/homepage.njk +2 -2
  38. package/nationalarchives/templates/search-results.njk +38 -0
  39. package/nationalarchives/templates/topics.njk +42 -0
  40. package/nationalarchives/tools/_all.scss +1 -0
  41. package/nationalarchives/tools/_grid.scss +4 -4
  42. package/nationalarchives/tools/_media.scss +62 -0
  43. package/nationalarchives/tools/_typography.scss +2 -2
  44. package/nationalarchives/utilities/_global.scss +1 -1
  45. package/nationalarchives/utilities/_typography.scss +104 -141
  46. package/nationalarchives/variables/_all.scss +1 -0
  47. package/nationalarchives/variables/_colour.scss +1 -0
  48. package/nationalarchives/variables/_typography.scss +7 -7
  49. package/package.json +13 -5
@@ -5,83 +5,83 @@
5
5
  color: #fff;
6
6
 
7
7
  background-color: #26262a;
8
- }
9
8
 
10
- .tna-footer__link {
11
- color: inherit;
9
+ &__link {
10
+ color: inherit;
12
11
 
13
- &:hover {
14
- color: #f0a;
12
+ &:hover {
13
+ color: #f0a;
14
+ }
15
15
  }
16
- }
17
16
 
18
- .tna-footer__navigation {
19
- padding-bottom: 3rem;
20
- }
17
+ &__navigation {
18
+ padding-bottom: 3rem;
19
+ }
21
20
 
22
- .tna-footer__navigation-group {
23
- }
21
+ &__navigation-group {
22
+ }
24
23
 
25
- .tna-footer__navigation-group-title {
26
- }
24
+ &__navigation-group-title {
25
+ }
27
26
 
28
- .tna-footer__navigation-group-items {
29
- padding-left: 0;
27
+ &__navigation-group-items {
28
+ padding-left: 0;
30
29
 
31
- list-style: none;
32
- }
30
+ list-style: none;
31
+ }
33
32
 
34
- .tna-footer__navigation-group-item {
35
- }
33
+ &__navigation-group-item {
34
+ }
36
35
 
37
- .tna-footer__navigation-group-item-link {
38
- }
36
+ &__navigation-group-item-link {
37
+ }
39
38
 
40
- .tna-footer__social {
41
- padding-bottom: 4rem;
39
+ &__social {
40
+ padding-bottom: 4rem;
42
41
 
43
- &.tna-container {
44
- align-items: flex-end;
42
+ &.tna-container {
43
+ align-items: flex-end;
44
+ }
45
45
  }
46
- }
47
46
 
48
- .tna-footer__social-item {
49
- text-align: center;
50
- }
47
+ &__social-item {
48
+ text-align: center;
49
+ }
51
50
 
52
- .tna-footer__social-item-link {
53
- display: block;
54
- }
51
+ &__social-item-link {
52
+ display: block;
53
+ }
55
54
 
56
- .tna-footer__social-item-link-image {
57
- display: block;
58
- }
55
+ &__social-item-link-image {
56
+ display: block;
57
+ }
59
58
 
60
- .tna-footer__licence {
61
- &.tna-container {
62
- align-items: center;
59
+ &__licence {
60
+ &.tna-container {
61
+ align-items: center;
62
+ }
63
63
  }
64
- }
65
64
 
66
- .tna-footer__licence-logo {
67
- display: block;
68
- }
65
+ &__licence-logo {
66
+ display: block;
67
+ }
69
68
 
70
- .tna-footer__govuk-link {
71
- display: inline-block;
69
+ &__govuk-link {
70
+ display: inline-block;
72
71
 
73
- color: inherit;
74
- fill: #fff;
72
+ color: inherit;
73
+ fill: #fff;
75
74
 
76
- &:hover {
77
- color: #f0a;
78
- fill: #f0a;
75
+ &:hover {
76
+ color: #f0a;
77
+ fill: #f0a;
78
+ }
79
79
  }
80
- }
81
80
 
82
- .tna-footer__govuk-logotype-crown {
83
- margin: 0 auto;
84
- display: block;
81
+ &__govuk-logotype-crown {
82
+ margin: 0 auto;
83
+ display: block;
85
84
 
86
- fill: inherit;
85
+ fill: inherit;
86
+ }
87
87
  }
@@ -6,7 +6,7 @@ const argTypes = {
6
6
  navigation: { control: "object" },
7
7
  social: { control: "object" },
8
8
  classes: { control: "text" },
9
- attributes: { control: "text" },
9
+ attributes: { control: "object" },
10
10
  };
11
11
 
12
12
  Object.keys(argTypes).forEach((argType) => {
@@ -1,6 +1,6 @@
1
1
  @use "sass:math";
2
2
  @use "../../variables/grid";
3
- @use "../../variables/media";
3
+ @use "../../tools/media";
4
4
  @use "../../tools/grid" as tools;
5
5
 
6
6
  .tna-container {
@@ -19,19 +19,13 @@
19
19
  justify-content: stretch;
20
20
  align-items: stretch;
21
21
 
22
- &.tna-container--max {
23
- max-width: none;
24
- }
25
-
26
- &.tna-container--no-padding {
22
+ &--no-padding,
23
+ &--no-padding-all {
27
24
  max-width: grid.$largest-container-width - (grid.$gutter-width * 2);
28
- padding-right: 0;
29
- padding-left: 0;
25
+ }
30
26
 
31
- .tna-column {
32
- padding-right: 0;
33
- padding-left: 0;
34
- }
27
+ &--max {
28
+ max-width: none;
35
29
  }
36
30
  }
37
31
 
@@ -41,52 +35,67 @@
41
35
 
42
36
  box-sizing: border-box;
43
37
 
44
- &.tna-column--full {
38
+ &--full {
45
39
  width: 100%;
46
40
  }
47
41
 
48
- // &.column--no-padding {
49
- // padding-right: 0;
50
- // padding-left: 0;
51
- // }
52
- }
42
+ &--container {
43
+ display: -ms-flexbox;
44
+ display: flex;
45
+ flex-wrap: wrap;
46
+ justify-content: stretch;
47
+ align-items: stretch;
48
+ }
53
49
 
54
- @for $i from 1 through 3 {
55
- .tna-column--flex-#{$i} {
56
- flex: $i 0;
50
+ @for $i from 1 through 3 {
51
+ &--flex-#{$i} {
52
+ flex: $i 0;
53
+ }
57
54
  }
58
55
  }
59
56
 
57
+ .tna-container--no-padding,
58
+ .tna-container--no-padding-all,
59
+ .tna-container--no-padding-all > .tna-column,
60
+ .tna-column--no-padding,
61
+ .tna-column--container--no-padding-all,
62
+ .tna-column--container--no-padding-all > .tna-column {
63
+ padding-right: 0;
64
+ padding-left: 0;
65
+ }
66
+
60
67
  // @for $i from 1 through 3 {
61
- // .column--order-#{$i} {
68
+ // .tna-column--order-#{$i} {
62
69
  // order: $i;
63
70
  // }
64
71
  // }
65
72
 
66
73
  @include tools.columns-generator(grid.$column-count);
67
74
 
68
- @media #{media.$media-medium} {
69
- .tna-column--full-medium {
70
- width: 100%;
71
- flex: none;
72
- }
75
+ @include media.on-medium {
76
+ .tna-column {
77
+ &--full-medium {
78
+ width: 100%;
79
+ flex: none;
80
+ }
73
81
 
74
- @for $i from 1 through 3 {
75
- .tna-column--flex-#{$i}-medium {
76
- flex: $i 0;
82
+ @for $i from 1 through 3 {
83
+ &--flex-#{$i}-medium {
84
+ flex: $i 0;
85
+ }
77
86
  }
78
- }
79
87
 
80
- // @for $i from 1 through 3 {
81
- // .column--order-#{$i}-medium {
82
- // order: $i;
83
- // }
84
- // }
88
+ // @for $i from 1 through 3 {
89
+ // &--order-#{$i}-medium {
90
+ // order: $i;
91
+ // }
92
+ // }
93
+ }
85
94
 
86
95
  @include tools.columns-generator(grid.$column-count-medium, "-medium");
87
96
  }
88
97
 
89
- @media #{media.$media-mobile} {
98
+ @include media.on-mobile {
90
99
  .tna-container {
91
100
  padding-right: math.div(grid.$gutter-width-mobile, 2) + 0.75rem;
92
101
  padding-left: math.div(grid.$gutter-width-mobile, 2) + 0.75rem;
@@ -96,64 +105,52 @@
96
105
  padding-right: math.div(grid.$gutter-width-mobile, 2);
97
106
  padding-left: math.div(grid.$gutter-width-mobile, 2);
98
107
  }
99
-
100
- // .column--width-full-mobile {
101
- // width: 100%;
102
- // }
103
-
104
- // @for $i from 1 through 3 {
105
- // .column--flex-#{$i}-mobile {
106
- // flex: $i 0;
107
- // }
108
- // }
109
-
110
- // @for $i from 1 through 3 {
111
- // .column--order-#{$i}-mobile {
112
- // order: $i;
113
- // }
114
- // }
115
108
  }
116
109
 
117
- @media #{media.$media-small} {
118
- .tna-column--full-small {
119
- width: 100%;
120
- flex: none;
121
- }
110
+ @include media.on-small {
111
+ .tna-column {
112
+ &--full-small {
113
+ width: 100%;
114
+ flex: none;
115
+ }
122
116
 
123
- @for $i from 1 through 3 {
124
- .tna-column--flex-#{$i}-small {
125
- flex: $i 0;
117
+ @for $i from 1 through 3 {
118
+ &--flex-#{$i}-small {
119
+ flex: $i 0;
120
+ }
126
121
  }
127
- }
128
122
 
129
- // @for $i from 1 through 3 {
130
- // .column--order-#{$i}-small {
131
- // order: $i;
132
- // }
133
- // }
123
+ // @for $i from 1 through 3 {
124
+ // &--order-#{$i}-small {
125
+ // order: $i;
126
+ // }
127
+ // }
128
+ }
134
129
 
135
130
  @include tools.columns-generator(grid.$column-count-small, "-small");
136
131
  }
137
132
 
138
- @media #{media.$media-tiny} {
139
- .tna-column--full-tiny {
140
- width: 100%;
141
- flex: none;
142
- }
133
+ @include media.on-tiny {
134
+ .tna-column {
135
+ &--full-tiny {
136
+ width: 100%;
137
+ flex: none;
138
+ }
143
139
 
144
- @for $i from 1 through 3 {
145
- .tna-column--flex-#{$i}-tiny {
146
- width: auto;
140
+ @for $i from 1 through 3 {
141
+ &--flex-#{$i}-tiny {
142
+ width: auto;
147
143
 
148
- flex: $i 0;
144
+ flex: $i 0;
145
+ }
149
146
  }
150
- }
151
147
 
152
- // @for $i from 1 through 3 {
153
- // .column--order-#{$i}-tiny {
154
- // order: $i;
155
- // }
156
- // }
148
+ // @for $i from 1 through 3 {
149
+ // &--order-#{$i}-tiny {
150
+ // order: $i;
151
+ // }
152
+ // }
153
+ }
157
154
 
158
155
  @include tools.columns-generator(grid.$column-count-tiny, "-tiny");
159
156
  }
@@ -6,9 +6,10 @@ const argTypes = {
6
6
  columns: { control: "object" },
7
7
  maxWidth: { control: "boolean" },
8
8
  noPadding: { control: "boolean" },
9
+ noPaddingAll: { control: "boolean" },
9
10
  htmlElement: { control: "text" },
10
11
  classes: { control: "text" },
11
- attributes: { control: "text" },
12
+ attributes: { control: "object" },
12
13
  };
13
14
 
14
15
  Object.keys(argTypes).forEach((argType) => {
@@ -26,6 +27,7 @@ const Template = ({
26
27
  columns,
27
28
  maxWidth,
28
29
  noPadding,
30
+ noPaddingAll,
29
31
  htmlElement,
30
32
  classes,
31
33
  attributes,
@@ -35,6 +37,7 @@ const Template = ({
35
37
  columns,
36
38
  maxWidth,
37
39
  noPadding,
40
+ noPaddingAll,
38
41
  htmlElement,
39
42
  classes,
40
43
  attributes,
@@ -81,7 +81,13 @@
81
81
  },
82
82
  {
83
83
  "name": "noPadding",
84
- "type": "string",
84
+ "type": "boolean",
85
+ "required": false,
86
+ "description": ""
87
+ },
88
+ {
89
+ "name": "noPaddingAll",
90
+ "type": "boolean",
85
91
  "required": false,
86
92
  "description": ""
87
93
  },
@@ -6,6 +6,9 @@
6
6
  {%- if params.noPadding -%}
7
7
  {%- set containerClasses = containerClasses.concat('tna-container--no-padding') -%}
8
8
  {%- endif -%}
9
+ {%- if params.noPaddingAll -%}
10
+ {%- set containerClasses = containerClasses.concat('tna-container--no-padding-all') -%}
11
+ {%- endif -%}
9
12
  <{{ htmlElement }} class="tna-container {{ containerClasses | join(' ') }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
10
13
  {%- for item in params.columns -%}
11
14
  {%- set columnHtmlElement = item.htmlElement if item.htmlElement else 'div' -%}
@@ -0,0 +1,132 @@
1
+ @use "../../tools/media";
2
+
3
+ .tna-hero {
4
+ min-height: min(20vw, 300px);
5
+ padding-top: 5.25rem;
6
+ padding-bottom: 3.25rem;
7
+
8
+ display: -ms-flexbox;
9
+ display: flex;
10
+ align-items: end;
11
+
12
+ position: relative;
13
+
14
+ background-color: #000;
15
+
16
+ &__image {
17
+ width: 100%;
18
+ height: 100%;
19
+
20
+ position: absolute;
21
+ inset: 0;
22
+ z-index: 1;
23
+
24
+ object-fit: cover;
25
+ }
26
+
27
+ &__image-details {
28
+ position: absolute;
29
+ right: 1.25rem;
30
+ bottom: 1.25rem;
31
+ z-index: 3;
32
+ }
33
+
34
+ &__image-details-summary {
35
+ width: 2rem;
36
+ height: 2rem;
37
+
38
+ position: relative;
39
+ z-index: 2;
40
+
41
+ font-size: 0;
42
+ text-align: center;
43
+ line-height: 2rem;
44
+ list-style: none;
45
+
46
+ background-color: #fc0;
47
+
48
+ border-radius: 1rem;
49
+
50
+ cursor: pointer;
51
+ }
52
+
53
+ &__image-details-summary-icon {
54
+ font-size: 1.25rem;
55
+ font-style: normal;
56
+ font-weight: 700;
57
+ text-transform: lowercase;
58
+ }
59
+
60
+ &__image-information {
61
+ width: 20rem;
62
+ max-width: 45vw;
63
+ padding: 0.5rem 1rem;
64
+
65
+ position: absolute;
66
+ right: 0;
67
+ bottom: 2.5rem;
68
+ z-index: 1;
69
+
70
+ background-color: #fc0;
71
+ }
72
+
73
+ &__inner {
74
+ position: relative;
75
+ z-index: 2;
76
+ }
77
+
78
+ &__content {
79
+ padding-top: 1.5rem;
80
+ padding-bottom: 1.5rem;
81
+
82
+ background-color: #fff;
83
+ }
84
+
85
+ &__heading {
86
+ margin-bottom: 0;
87
+ }
88
+
89
+ &__body {
90
+ }
91
+
92
+ @include media.on-mobile {
93
+ padding: 0;
94
+
95
+ display: block;
96
+
97
+ &__image {
98
+ position: static;
99
+ }
100
+
101
+ &__image-details {
102
+ bottom: auto;
103
+ top: 1.25rem;
104
+ }
105
+
106
+ &__image-details-summary {
107
+ }
108
+
109
+ &__image-details-summary-icon {
110
+ }
111
+
112
+ &__image-information {
113
+ top: 2.5rem;
114
+ bottom: auto;
115
+ }
116
+
117
+ &__inner {
118
+ }
119
+
120
+ &__content {
121
+ color: #fff;
122
+
123
+ background-color: inherit;
124
+ }
125
+
126
+ &__heading {
127
+ }
128
+
129
+ &__body {
130
+ }
131
+ }
132
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": "hero",
3
+ "fixtures": []
4
+ }
@@ -0,0 +1,74 @@
1
+ import Hero from "./template.njk";
2
+ import "./_index.scss";
3
+ import macroOptions from "./macro-options.json";
4
+ import { expect } from "@storybook/jest";
5
+ import { within, userEvent } from "@storybook/testing-library";
6
+
7
+ const argTypes = {
8
+ heading: { control: "text" },
9
+ body: { control: "text" },
10
+ text: { control: "text" },
11
+ image: { control: "object" },
12
+ classes: { control: "text" },
13
+ attributes: { control: "object" },
14
+ };
15
+
16
+ Object.keys(argTypes).forEach((argType) => {
17
+ argTypes[argType].description = macroOptions.find(
18
+ (option) => option.name === argType
19
+ )?.description;
20
+ });
21
+
22
+ export default {
23
+ title: "Components/Hero",
24
+ argTypes,
25
+ };
26
+
27
+ const Template = ({ heading, body, text, image, classes, attributes }) => {
28
+ return Hero({
29
+ params: {
30
+ heading,
31
+ body,
32
+ text,
33
+ image,
34
+ classes,
35
+ attributes,
36
+ },
37
+ });
38
+ };
39
+
40
+ export const Standard = Template.bind({});
41
+ Standard.args = {
42
+ heading: "Title",
43
+ body: "<p>Body</p>",
44
+ image: {
45
+ src: "https://picsum.photos/id/29/640/360",
46
+ alt: "A placeholder image",
47
+ information: "Photo of some mountains by a famous photographer, ©2012",
48
+ },
49
+ classes: "tna-hero--demo",
50
+ };
51
+
52
+ Standard.play = async ({ args, canvasElement }) => {
53
+ const canvas = within(canvasElement);
54
+ const image = canvas.getByAltText(args.image.alt);
55
+ const title = canvas.getByText(args.heading);
56
+ const summary = canvasElement.querySelector(
57
+ ".tna-hero__image-details-summary"
58
+ );
59
+ const information = canvas.getByText(args.image.information);
60
+
61
+ await expect(image).toBeVisible();
62
+ await expect(title).toBeVisible();
63
+ await expect(summary).toBeVisible();
64
+ await expect(information).not.toBeVisible();
65
+
66
+ await userEvent.click(summary);
67
+ await expect(image).toBeVisible();
68
+ await expect(title).toBeVisible();
69
+ await expect(summary).toBeVisible();
70
+ await expect(information).toBeVisible();
71
+
72
+ await userEvent.click(summary);
73
+ await expect(information).not.toBeVisible();
74
+ };
@@ -0,0 +1,58 @@
1
+ [
2
+ {
3
+ "name": "heading",
4
+ "type": "string",
5
+ "required": false,
6
+ "description": ""
7
+ },
8
+ {
9
+ "name": "body",
10
+ "type": "string",
11
+ "required": false,
12
+ "description": ""
13
+ },
14
+ {
15
+ "name": "text",
16
+ "type": "string",
17
+ "required": false,
18
+ "description": ""
19
+ },
20
+ {
21
+ "name": "image",
22
+ "type": "object",
23
+ "required": false,
24
+ "description": "",
25
+ "params": [
26
+ {
27
+ "name": "src",
28
+ "type": "string",
29
+ "required": true,
30
+ "description": ""
31
+ },
32
+ {
33
+ "name": "alt",
34
+ "type": "string",
35
+ "required": true,
36
+ "description": ""
37
+ },
38
+ {
39
+ "name": "information",
40
+ "type": "string",
41
+ "required": false,
42
+ "description": ""
43
+ }
44
+ ]
45
+ },
46
+ {
47
+ "name": "classes",
48
+ "type": "string",
49
+ "required": false,
50
+ "description": "Classes to add to the card."
51
+ },
52
+ {
53
+ "name": "attributes",
54
+ "type": "object",
55
+ "required": false,
56
+ "description": "HTML attributes (for example data attributes) to add to the card."
57
+ }
58
+ ]
@@ -0,0 +1,3 @@
1
+ {% macro tnaHero(params) %}
2
+ {%- include "./template.njk" -%}
3
+ {% endmacro %}