@nationalarchives/frontend 0.1.3-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.
- package/README.md +191 -0
- package/govuk-prototype-kit.config.json +14 -0
- package/nationalarchives/_base.scss +6 -0
- package/nationalarchives/_prototype-kit.scss +3 -0
- package/nationalarchives/all.css +1 -0
- package/nationalarchives/all.css.map +1 -0
- package/nationalarchives/all.js +2 -0
- package/nationalarchives/all.js.map +1 -0
- package/nationalarchives/all.mjs +13 -0
- package/nationalarchives/all.scss +9 -0
- package/nationalarchives/assets/images/apple-touch-icon-152x152.png +0 -0
- package/nationalarchives/assets/images/apple-touch-icon-167x167.png +0 -0
- package/nationalarchives/assets/images/apple-touch-icon-180x180.png +0 -0
- package/nationalarchives/assets/images/apple-touch-icon.png +0 -0
- package/nationalarchives/assets/images/favicon.ico +0 -0
- package/nationalarchives/assets/images/mask-icon.svg +6 -0
- package/nationalarchives/assets/images/nationalarchives-opengraph-image.png +0 -0
- package/nationalarchives/assets/images/tna-horizontal-logo-inverted.svg +51 -0
- package/nationalarchives/assets/images/tna-horizontal-logo.svg +51 -0
- package/nationalarchives/assets/images/tna-square-logo-inverted.svg +47 -0
- package/nationalarchives/assets/images/tna-square-logo.svg +47 -0
- package/nationalarchives/components/_all.scss +7 -0
- package/nationalarchives/components/button/_button.scss +2 -0
- package/nationalarchives/components/button/_index.scss +26 -0
- package/nationalarchives/components/button/button.stories.js +52 -0
- package/nationalarchives/components/button/fixtures.json +56 -0
- package/nationalarchives/components/button/macro-options.json +38 -0
- package/nationalarchives/components/button/macro.njk +3 -0
- package/nationalarchives/components/button/template.njk +7 -0
- package/nationalarchives/components/card/_card.scss +2 -0
- package/nationalarchives/components/card/_index.scss +37 -0
- package/nationalarchives/components/card/card.stories.js +77 -0
- package/nationalarchives/components/card/fixtures.json +29 -0
- package/nationalarchives/components/card/macro-options.json +96 -0
- package/nationalarchives/components/card/macro.njk +3 -0
- package/nationalarchives/components/card/template.njk +33 -0
- package/nationalarchives/components/footer/_footer.scss +2 -0
- package/nationalarchives/components/footer/_index.scss +77 -0
- package/nationalarchives/components/footer/fixtures.json +11 -0
- package/nationalarchives/components/footer/footer.stories.js +170 -0
- package/nationalarchives/components/footer/macro-options.json +80 -0
- package/nationalarchives/components/footer/macro.njk +3 -0
- package/nationalarchives/components/footer/template.njk +46 -0
- package/nationalarchives/components/grid/_grid.scss +2 -0
- package/nationalarchives/components/grid/_index.scss +84 -0
- package/nationalarchives/components/grid/fixtures.json +273 -0
- package/nationalarchives/components/grid/grid.stories.js +192 -0
- package/nationalarchives/components/grid/macro-options.json +106 -0
- package/nationalarchives/components/grid/macro.njk +3 -0
- package/nationalarchives/components/grid/template.njk +44 -0
- package/nationalarchives/components/sensitive-image/_index.scss +84 -0
- package/nationalarchives/components/sensitive-image/_sensitive-image.scss +2 -0
- package/nationalarchives/components/sensitive-image/fixtures.json +54 -0
- package/nationalarchives/components/sensitive-image/macro-options.json +58 -0
- package/nationalarchives/components/sensitive-image/macro.njk +3 -0
- package/nationalarchives/components/sensitive-image/sensitive-image.js +2 -0
- package/nationalarchives/components/sensitive-image/sensitive-image.js.map +1 -0
- package/nationalarchives/components/sensitive-image/sensitive-image.mjs +26 -0
- package/nationalarchives/components/sensitive-image/sensitive-image.stories.js +49 -0
- package/nationalarchives/components/sensitive-image/template.njk +10 -0
- package/nationalarchives/stories/development/structure.mdx +7 -0
- package/nationalarchives/stories/global/heading-groups.stories.js +23 -0
- package/nationalarchives/stories/global/headings.stories.js +40 -0
- package/nationalarchives/stories/global/typography.mdx +22 -0
- package/nationalarchives/stories/global/typography.stories.js +15 -0
- package/nationalarchives/tools/_all.scss +1 -0
- package/nationalarchives/tools/_exports.scss +36 -0
- package/nationalarchives/utilities/_all.scss +3 -0
- package/nationalarchives/utilities/_global.scss +39 -0
- package/nationalarchives/utilities/_grid.scss +131 -0
- package/nationalarchives/utilities/_typography.scss +82 -0
- package/nationalarchives/variables/_all.scss +2 -0
- package/nationalarchives/variables/_grid.scss +9 -0
- package/nationalarchives/variables/_media.scss +12 -0
- package/package.json +70 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "columns",
|
4
|
+
"type": "array",
|
5
|
+
"required": false,
|
6
|
+
"description": "An array of column item objects.",
|
7
|
+
"params": [
|
8
|
+
{
|
9
|
+
"name": "html",
|
10
|
+
"type": "string",
|
11
|
+
"required": true,
|
12
|
+
"description": ""
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"name": "width",
|
16
|
+
"type": "string",
|
17
|
+
"required": false,
|
18
|
+
"description": ""
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"name": "widthMedium",
|
22
|
+
"type": "string",
|
23
|
+
"required": false,
|
24
|
+
"description": ""
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "widthSmall",
|
28
|
+
"type": "string",
|
29
|
+
"required": false,
|
30
|
+
"description": ""
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"name": "widthTiny",
|
34
|
+
"type": "string",
|
35
|
+
"required": false,
|
36
|
+
"description": ""
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"name": "flex",
|
40
|
+
"type": "number",
|
41
|
+
"required": false,
|
42
|
+
"description": ""
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"name": "flexMedium",
|
46
|
+
"type": "number",
|
47
|
+
"required": false,
|
48
|
+
"description": ""
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"name": "flexSmall",
|
52
|
+
"type": "number",
|
53
|
+
"required": false,
|
54
|
+
"description": ""
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"name": "flexTiny",
|
58
|
+
"type": "number",
|
59
|
+
"required": false,
|
60
|
+
"description": ""
|
61
|
+
},
|
62
|
+
{
|
63
|
+
"name": "classes",
|
64
|
+
"type": "string",
|
65
|
+
"required": false,
|
66
|
+
"description": "Classes to add to the column."
|
67
|
+
},
|
68
|
+
{
|
69
|
+
"name": "attributes",
|
70
|
+
"type": "object",
|
71
|
+
"required": false,
|
72
|
+
"description": "HTML attributes (for example data attributes) to add to the navigation item."
|
73
|
+
}
|
74
|
+
]
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"name": "maxWidth",
|
78
|
+
"type": "boolean",
|
79
|
+
"required": false,
|
80
|
+
"description": ""
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"name": "noPadding",
|
84
|
+
"type": "string",
|
85
|
+
"required": false,
|
86
|
+
"description": ""
|
87
|
+
},
|
88
|
+
{
|
89
|
+
"name": "htmlElement",
|
90
|
+
"type": "string",
|
91
|
+
"required": false,
|
92
|
+
"description": "HTML element of the container."
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"name": "classes",
|
96
|
+
"type": "string",
|
97
|
+
"required": false,
|
98
|
+
"description": "Classes to add to the container."
|
99
|
+
},
|
100
|
+
{
|
101
|
+
"name": "attributes",
|
102
|
+
"type": "object",
|
103
|
+
"required": false,
|
104
|
+
"description": "HTML attributes (for example data attributes) to add to the container."
|
105
|
+
}
|
106
|
+
]
|
@@ -0,0 +1,44 @@
|
|
1
|
+
{%- set htmlElement = params.htmlElement if params.htmlElement else 'div' -%}
|
2
|
+
{%- set containerClasses = [params.classes] if params.classes else [] -%}
|
3
|
+
{%- if params.maxWidth -%}
|
4
|
+
{%- set containerClasses = containerClasses.concat('tna-container--max') -%}
|
5
|
+
{%- endif -%}
|
6
|
+
{%- if params.noPadding -%}
|
7
|
+
{%- set containerClasses = containerClasses.concat('tna-container--no-padding') -%}
|
8
|
+
{%- endif -%}
|
9
|
+
<{{ htmlElement }} class="tna-container {{ containerClasses | join(' ') }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
10
|
+
{%- for item in params.columns -%}
|
11
|
+
{%- set columnHtmlElement = item.htmlElement if item.htmlElement else 'div' -%}
|
12
|
+
{%- set columnClasses = [item.classes] if item.classes else [] -%}
|
13
|
+
{%- if item.width -%}
|
14
|
+
{%- set columnClasses = columnClasses.concat('tna-column--full') if item.width == 'full' else ( columnClasses.concat('tna-column--width-' + item.width) ) -%}
|
15
|
+
{%- endif -%}
|
16
|
+
{%- if item.widthMedium -%}
|
17
|
+
{%- set columnClasses = columnClasses.concat('tna-column--full-medium') if item.widthMedium == 'full' else ( columnClasses.concat('tna-column--width-' + item.widthMedium + '-medium') ) -%}
|
18
|
+
{%- endif -%}
|
19
|
+
{%- if item.widthSmall -%}
|
20
|
+
{%- set columnClasses = columnClasses.concat('tna-column--full-small') if item.widthSmall == 'full' else ( columnClasses.concat('tna-column--width-' + item.widthSmall + '-small') ) -%}
|
21
|
+
{%- endif -%}
|
22
|
+
{%- if item.widthTiny -%}
|
23
|
+
{%- set columnClasses = columnClasses.concat('tna-column--full-tiny') if item.widthTiny == 'full' else ( columnClasses.concat('tna-column--width-' + item.widthTiny + '-tiny') ) -%}
|
24
|
+
{%- endif -%}
|
25
|
+
{%- if item.flex -%}
|
26
|
+
{%- set columnClasses = columnClasses.concat('tna-column--flex-' + item.flex) -%}
|
27
|
+
{%- endif -%}
|
28
|
+
{%- if item.flexMedium -%}
|
29
|
+
{%- set columnClasses = columnClasses.concat('tna-column--flex-' + item.flexMedium + '-medium') -%}
|
30
|
+
{%- endif -%}
|
31
|
+
{%- if item.flexSmall -%}
|
32
|
+
{%- set columnClasses = columnClasses.concat('tna-column--flex-' + item.flexSmall + '-small') -%}
|
33
|
+
{%- endif -%}
|
34
|
+
{%- if item.flexTiny -%}
|
35
|
+
{%- set columnClasses = columnClasses.concat('tna-column--flex-' + item.flexTiny + '-tiny') -%}
|
36
|
+
{%- endif -%}
|
37
|
+
{%- if item.noPadding -%}
|
38
|
+
{%- set columnClasses = columnClasses.concat('tna-column--noPadding') -%}
|
39
|
+
{%- endif -%}
|
40
|
+
<{{ columnHtmlElement }} class="tna-column {{ columnClasses | join(' ') }}" {%- for attribute, value in item.attributes %} {{attribute}}="{{value}}"{% endfor %}>
|
41
|
+
{{ item.html | safe }}
|
42
|
+
</{{ columnHtmlElement }}>
|
43
|
+
{%- endfor -%}
|
44
|
+
</{{ htmlElement }}>
|
@@ -0,0 +1,84 @@
|
|
1
|
+
@include nationalarchives-exports(
|
2
|
+
"nationalarchives/components/sensitive-image"
|
3
|
+
) {
|
4
|
+
.tna-sensitive-image {
|
5
|
+
}
|
6
|
+
|
7
|
+
.tna-sensitive-image__warning {
|
8
|
+
}
|
9
|
+
|
10
|
+
.tna-sensitive-image__details {
|
11
|
+
position: relative;
|
12
|
+
|
13
|
+
// overflow: hidden;
|
14
|
+
|
15
|
+
&::after {
|
16
|
+
width: 100%;
|
17
|
+
padding-bottom: calc(
|
18
|
+
100% * var(--sensitive-image-height) / var(--sensitive-image-width)
|
19
|
+
);
|
20
|
+
|
21
|
+
display: block;
|
22
|
+
|
23
|
+
position: relative;
|
24
|
+
z-index: -1;
|
25
|
+
|
26
|
+
background-image: var(--sensitive-image);
|
27
|
+
background-clip: padding-box;
|
28
|
+
background-size: contain;
|
29
|
+
|
30
|
+
filter: blur(15px) saturate(0);
|
31
|
+
|
32
|
+
content: "";
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
.tna-sensitive-image__show {
|
37
|
+
display: flex;
|
38
|
+
align-items: center;
|
39
|
+
justify-content: center;
|
40
|
+
|
41
|
+
position: absolute;
|
42
|
+
top: 0;
|
43
|
+
right: 0;
|
44
|
+
bottom: 0;
|
45
|
+
left: 0;
|
46
|
+
z-index: 1;
|
47
|
+
|
48
|
+
font-size: 0;
|
49
|
+
|
50
|
+
cursor: pointer;
|
51
|
+
|
52
|
+
&::after {
|
53
|
+
padding: 0.5rem 2rem;
|
54
|
+
|
55
|
+
font-size: 1rem;
|
56
|
+
|
57
|
+
background-color: #ff0;
|
58
|
+
|
59
|
+
content: attr(data-action);
|
60
|
+
}
|
61
|
+
|
62
|
+
&:hover {
|
63
|
+
&::after {
|
64
|
+
color: #fff;
|
65
|
+
|
66
|
+
background-color: #000;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
.tna-sensitive-image__container {
|
72
|
+
}
|
73
|
+
|
74
|
+
.tna-sensitive-image__image {
|
75
|
+
width: 100%;
|
76
|
+
}
|
77
|
+
|
78
|
+
.tna-sensitive-image__details[open] {
|
79
|
+
&::after,
|
80
|
+
.tna-sensitive-image__show {
|
81
|
+
display: none;
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
{
|
2
|
+
"component": "sensitive image",
|
3
|
+
"fixtures": [
|
4
|
+
{
|
5
|
+
"name": "minimal",
|
6
|
+
"options": {
|
7
|
+
"image": {
|
8
|
+
"src": "https://picsum.photos/id/237/800/600",
|
9
|
+
"alt": "A placeholder image",
|
10
|
+
"width": 800,
|
11
|
+
"height": 600
|
12
|
+
},
|
13
|
+
"warning": "This is a gory photo",
|
14
|
+
"action": "Show me the gory photo"
|
15
|
+
},
|
16
|
+
"html": "<div class=\"tna-sensitive-image \" data-module=\"tna-sensitive-image\" style=\"--sensitive-image: url('https://picsum.photos/id/237/800/600'); --sensitive-image-width: 800; --sensitive-image-height: 600\">\n <p class=\"tna-sensitive-image__warning\">This is a gory photo</p>\n <details class=\"tna-sensitive-image__details\">\n <summary class=\"tna-sensitive-image__show\" data-action=\"Show me the gory photo\">Show me the gory photo</summary>\n <div class=\"tna-sensitive-image__container\">\n <img src=\"https://picsum.photos/id/237/800/600\" alt=\"A placeholder image\" class=\"tna-sensitive-image__image\" />\n </div>\n </details>\n</div>",
|
17
|
+
"hidden": false
|
18
|
+
},
|
19
|
+
{
|
20
|
+
"name": "with classes",
|
21
|
+
"options": {
|
22
|
+
"image": {
|
23
|
+
"src": "https://picsum.photos/id/237/800/600",
|
24
|
+
"alt": "A placeholder image",
|
25
|
+
"width": 800,
|
26
|
+
"height": 600
|
27
|
+
},
|
28
|
+
"warning": "This is a gory photo",
|
29
|
+
"action": "Show me the gory photo",
|
30
|
+
"classes": "sensitive-image__test-class"
|
31
|
+
},
|
32
|
+
"html": "<div class=\"tna-sensitive-image sensitive-image__test-class\" data-module=\"tna-sensitive-image\" style=\"--sensitive-image: url('https://picsum.photos/id/237/800/600'); --sensitive-image-width: 800; --sensitive-image-height: 600\">\n <p class=\"tna-sensitive-image__warning\">This is a gory photo</p>\n <details class=\"tna-sensitive-image__details\">\n <summary class=\"tna-sensitive-image__show\" data-action=\"Show me the gory photo\">Show me the gory photo</summary>\n <div class=\"tna-sensitive-image__container\">\n <img src=\"https://picsum.photos/id/237/800/600\" alt=\"A placeholder image\" class=\"tna-sensitive-image__image\" />\n </div>\n </details>\n</div>",
|
33
|
+
"hidden": false
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"name": "with attributes",
|
37
|
+
"options": {
|
38
|
+
"image": {
|
39
|
+
"src": "https://picsum.photos/id/237/800/600",
|
40
|
+
"alt": "A placeholder image",
|
41
|
+
"width": 800,
|
42
|
+
"height": 600
|
43
|
+
},
|
44
|
+
"warning": "This is a gory photo",
|
45
|
+
"action": "Show me the gory photo",
|
46
|
+
"attributes": {
|
47
|
+
"data-testattribute": "foobar"
|
48
|
+
}
|
49
|
+
},
|
50
|
+
"html": "<div class=\"tna-sensitive-image \" data-module=\"tna-sensitive-image\" style=\"--sensitive-image: url('https://picsum.photos/id/237/800/600'); --sensitive-image-width: 800; --sensitive-image-height: 600\" data-testattribute=\"foobar\">\n <p class=\"tna-sensitive-image__warning\">This is a gory photo</p>\n <details class=\"tna-sensitive-image__details\">\n <summary class=\"tna-sensitive-image__show\" data-action=\"Show me the gory photo\">Show me the gory photo</summary>\n <div class=\"tna-sensitive-image__container\">\n <img src=\"https://picsum.photos/id/237/800/600\" alt=\"A placeholder image\" class=\"tna-sensitive-image__image\" />\n </div>\n </details>\n</div>",
|
51
|
+
"hidden": false
|
52
|
+
}
|
53
|
+
]
|
54
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"name": "image",
|
4
|
+
"type": "object",
|
5
|
+
"required": true,
|
6
|
+
"description": "",
|
7
|
+
"params": [
|
8
|
+
{
|
9
|
+
"name": "src",
|
10
|
+
"type": "string",
|
11
|
+
"required": true,
|
12
|
+
"description": ""
|
13
|
+
},
|
14
|
+
{
|
15
|
+
"name": "alt",
|
16
|
+
"type": "string",
|
17
|
+
"required": true,
|
18
|
+
"description": ""
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"name": "width",
|
22
|
+
"type": "string",
|
23
|
+
"required": true,
|
24
|
+
"description": ""
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"name": "height",
|
28
|
+
"type": "string",
|
29
|
+
"required": true,
|
30
|
+
"description": ""
|
31
|
+
}
|
32
|
+
]
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"name": "warning",
|
36
|
+
"type": "string",
|
37
|
+
"required": true,
|
38
|
+
"description": ""
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"name": "action",
|
42
|
+
"type": "string",
|
43
|
+
"required": true,
|
44
|
+
"description": ""
|
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,2 @@
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("TNAFrontend",[],t):"object"==typeof exports?exports.TNAFrontend=t():(e.TNAFrontend=e.TNAFrontend||{},e.TNAFrontend["components/sensitive-image/sensitive-image"]=t())}(self,(()=>(()=>{"use strict";var e={d:(t,i)=>{for(var o in i)e.o(i,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:i[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function i(e){this.$module=e,this.$imageDetails=e&&e.querySelector(".tna-sensitive-image__details"),this.$image=e&&e.querySelector(".tna-sensitive-image__image"),this.imageIsVisible=!1}e.r(t),e.d(t,{default:()=>o}),i.prototype.init=function(){console.log(this),this.$module&&this.$imageDetails&&this.$image&&this.$imageDetails.addEventListener("toggle",this.handleImageDetailsToggle.bind(this))},i.prototype.handleImageDetailsToggle=function(e){this.$imageDetails.hasAttribute("open")&&this.$image.focus({preventScroll:!0,focusVisible:!0})};const o=i;return t})()));
|
2
|
+
//# sourceMappingURL=sensitive-image.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"components/sensitive-image/sensitive-image.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,cAAe,GAAIH,GACA,iBAAZC,QACdA,QAAqB,YAAID,KAEzBD,EAAkB,YAAIA,EAAkB,aAAK,CAAC,EAAGA,EAAkB,YAAE,8CAAgDC,IACtH,CATD,CASGK,MAAM,I,mBCRT,IAAIC,EAAsB,CCA1BA,EAAwB,CAACL,EAASM,KACjC,IAAI,IAAIC,KAAOD,EACXD,EAAoBG,EAAEF,EAAYC,KAASF,EAAoBG,EAAER,EAASO,IAC5EE,OAAOC,eAAeV,EAASO,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDF,EAAwB,CAACQ,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFT,EAAyBL,IACH,oBAAXkB,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeV,EAASkB,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeV,EAAS,aAAc,CAAEoB,OAAO,GAAO,G,KCL9D,SAASC,EAAeC,GACtBC,KAAKD,QAAUA,EACfC,KAAKC,cACHF,GAAWA,EAAQG,cAAc,iCACnCF,KAAKG,OAASJ,GAAWA,EAAQG,cAAc,+BAC/CF,KAAKI,gBAAiB,CACxB,C,8BAEAN,EAAeN,UAAUa,KAAO,WAC9BC,QAAQC,IAAIP,MACPA,KAAKD,SAAYC,KAAKC,eAAkBD,KAAKG,QAGlDH,KAAKC,cAAcO,iBACjB,SACAR,KAAKS,yBAAyBC,KAAKV,MAEvC,EAEAF,EAAeN,UAAUiB,yBAA2B,SAAUE,GACxDX,KAAKC,cAAcW,aAAa,SAClCZ,KAAKG,OAAOU,MAAM,CAAEC,eAAe,EAAMC,cAAc,GAE3D,EAEA,U","sources":["webpack://TNAFrontend/webpack/universalModuleDefinition","webpack://TNAFrontend/webpack/bootstrap","webpack://TNAFrontend/webpack/runtime/define property getters","webpack://TNAFrontend/webpack/runtime/hasOwnProperty shorthand","webpack://TNAFrontend/webpack/runtime/make namespace object","webpack://TNAFrontend/./src/nationalarchives/components/sensitive-image/sensitive-image.mjs"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"TNAFrontend\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"TNAFrontend\"] = factory();\n\telse\n\t\troot[\"TNAFrontend\"] = root[\"TNAFrontend\"] || {}, root[\"TNAFrontend\"][\"components/sensitive-image/sensitive-image\"] = factory();\n})(self, () => {\nreturn ","// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","function SensitiveImage($module) {\n this.$module = $module;\n this.$imageDetails =\n $module && $module.querySelector(\".tna-sensitive-image__details\");\n this.$image = $module && $module.querySelector(\".tna-sensitive-image__image\");\n this.imageIsVisible = false;\n}\n\nSensitiveImage.prototype.init = function () {\n console.log(this);\n if (!this.$module || !this.$imageDetails || !this.$image) {\n return;\n }\n this.$imageDetails.addEventListener(\n \"toggle\",\n this.handleImageDetailsToggle.bind(this)\n );\n};\n\nSensitiveImage.prototype.handleImageDetailsToggle = function (e) {\n if (this.$imageDetails.hasAttribute(\"open\")) {\n this.$image.focus({ preventScroll: true, focusVisible: true });\n }\n};\n\nexport default SensitiveImage;\n"],"names":["root","factory","exports","module","define","amd","self","__webpack_require__","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","SensitiveImage","$module","this","$imageDetails","querySelector","$image","imageIsVisible","init","console","log","addEventListener","handleImageDetailsToggle","bind","e","hasAttribute","focus","preventScroll","focusVisible"],"sourceRoot":""}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
function SensitiveImage($module) {
|
2
|
+
this.$module = $module;
|
3
|
+
this.$imageDetails =
|
4
|
+
$module && $module.querySelector(".tna-sensitive-image__details");
|
5
|
+
this.$image = $module && $module.querySelector(".tna-sensitive-image__image");
|
6
|
+
this.imageIsVisible = false;
|
7
|
+
}
|
8
|
+
|
9
|
+
SensitiveImage.prototype.init = function () {
|
10
|
+
console.log(this);
|
11
|
+
if (!this.$module || !this.$imageDetails || !this.$image) {
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
this.$imageDetails.addEventListener(
|
15
|
+
"toggle",
|
16
|
+
this.handleImageDetailsToggle.bind(this)
|
17
|
+
);
|
18
|
+
};
|
19
|
+
|
20
|
+
SensitiveImage.prototype.handleImageDetailsToggle = function (e) {
|
21
|
+
if (this.$imageDetails.hasAttribute("open")) {
|
22
|
+
this.$image.focus({ preventScroll: true, focusVisible: true });
|
23
|
+
}
|
24
|
+
};
|
25
|
+
|
26
|
+
export default SensitiveImage;
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import SensitiveImage from "./template.njk";
|
2
|
+
import "../../all.scss";
|
3
|
+
import "./_sensitive-image.scss";
|
4
|
+
import macroOptions from "./macro-options.json";
|
5
|
+
|
6
|
+
const argTypes = {
|
7
|
+
src: { control: "text" },
|
8
|
+
alt: { control: "text" },
|
9
|
+
warning: { control: "text" },
|
10
|
+
action: { control: "text" },
|
11
|
+
classes: { control: "text" },
|
12
|
+
attributes: { control: "text" },
|
13
|
+
};
|
14
|
+
|
15
|
+
Object.keys(argTypes).forEach((argType) => {
|
16
|
+
argTypes[argType].description = macroOptions.find(
|
17
|
+
(option) => option.name === argType
|
18
|
+
)?.description;
|
19
|
+
});
|
20
|
+
|
21
|
+
export default {
|
22
|
+
title: "Components/Sensitive image",
|
23
|
+
argTypes,
|
24
|
+
};
|
25
|
+
|
26
|
+
const Template = ({ image, warning, action, classes, attributes }) => {
|
27
|
+
return SensitiveImage({
|
28
|
+
params: {
|
29
|
+
image,
|
30
|
+
warning,
|
31
|
+
action,
|
32
|
+
classes,
|
33
|
+
attributes,
|
34
|
+
},
|
35
|
+
});
|
36
|
+
};
|
37
|
+
|
38
|
+
export const Standard = Template.bind({});
|
39
|
+
Standard.args = {
|
40
|
+
image: {
|
41
|
+
src: "https://picsum.photos/id/237/800/600",
|
42
|
+
alt: "A placeholder image",
|
43
|
+
width: 800,
|
44
|
+
height: 600,
|
45
|
+
},
|
46
|
+
warning: "This is a gory photo",
|
47
|
+
action: "Show me the gory photo",
|
48
|
+
classes: "tna-sensitive-image--demo",
|
49
|
+
};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
{%- set containerClasses = [params.classes] if params.classes else [] -%}
|
2
|
+
<div class="tna-sensitive-image {{ containerClasses | join(' ') }}" data-module="tna-sensitive-image" style="--sensitive-image: url('{{ params.image.src }}'); --sensitive-image-width: {{ params.image.width }}; --sensitive-image-height: {{ params.image.height }}" {%- for attribute, value in params.attributes %} {{ attribute }}="{{ value }}"{% endfor %}>
|
3
|
+
<p class="tna-sensitive-image__warning">{{ params.warning }}</p>
|
4
|
+
<details class="tna-sensitive-image__details">
|
5
|
+
<summary class="tna-sensitive-image__show" data-action="{{ params.action }}">{{ params.action }}</summary>
|
6
|
+
<div class="tna-sensitive-image__container">
|
7
|
+
<img src="{{ params.image.src }}" alt="{{ params.image.alt }}" class="tna-sensitive-image__image" />
|
8
|
+
</div>
|
9
|
+
</details>
|
10
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
const argTypes = {
|
2
|
+
supertitle: { control: "text" },
|
3
|
+
title: { control: "text" },
|
4
|
+
};
|
5
|
+
|
6
|
+
export default {
|
7
|
+
title: "Global styles/Typography",
|
8
|
+
argTypes,
|
9
|
+
};
|
10
|
+
|
11
|
+
const Template = ({
|
12
|
+
supertitle,
|
13
|
+
title,
|
14
|
+
}) => `<hgroup class="tna-hgroup tna-hgroup--heading-2">
|
15
|
+
<p class="tna-hgroup__supertitle">${supertitle}</p>
|
16
|
+
<h2 class="tna-hgroup__title">${title}</h2>
|
17
|
+
</hgroup>`;
|
18
|
+
|
19
|
+
export const HeadingGroup = Template.bind({});
|
20
|
+
HeadingGroup.args = {
|
21
|
+
supertitle: "The story of",
|
22
|
+
title: "This is a title",
|
23
|
+
};
|
@@ -0,0 +1,40 @@
|
|
1
|
+
const argTypes = {
|
2
|
+
text: { control: "text" },
|
3
|
+
size: { control: "text" },
|
4
|
+
};
|
5
|
+
|
6
|
+
export default {
|
7
|
+
title: "Global styles/Typography",
|
8
|
+
argTypes,
|
9
|
+
};
|
10
|
+
|
11
|
+
const HeadingTemplate = ({ params }, level) => `<h${level} class="tna-heading${
|
12
|
+
params.size ? ` tna-heading--${params.size}` : ""
|
13
|
+
}">
|
14
|
+
${params.text} (level ${level})
|
15
|
+
</h${level}>`;
|
16
|
+
|
17
|
+
const Heading1Template = ({ text, size }) =>
|
18
|
+
HeadingTemplate({ params: { text, size } }, 1);
|
19
|
+
const Heading2Template = ({ text, size }) =>
|
20
|
+
HeadingTemplate({ params: { text, size } }, 2);
|
21
|
+
const Heading3Template = ({ text, size }) =>
|
22
|
+
HeadingTemplate({ params: { text, size } }, 3);
|
23
|
+
|
24
|
+
export const Heading1 = Heading1Template.bind({});
|
25
|
+
Heading1.args = {
|
26
|
+
text: "This is a heading",
|
27
|
+
size: "xl",
|
28
|
+
};
|
29
|
+
|
30
|
+
export const Heading2 = Heading2Template.bind({});
|
31
|
+
Heading2.args = {
|
32
|
+
text: "This is a heading",
|
33
|
+
size: "l",
|
34
|
+
};
|
35
|
+
|
36
|
+
export const Heading3 = Heading3Template.bind({});
|
37
|
+
Heading3.args = {
|
38
|
+
text: "This is a heading",
|
39
|
+
size: "m",
|
40
|
+
};
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { Meta, Primary, Controls, Story, Canvas, Typeset } from "@storybook/blocks";
|
2
|
+
import * as HeadingStories from './headings.stories';
|
3
|
+
import * as HeadingGroupStories from './heading-groups.stories';
|
4
|
+
import * as TypographyStories from './typography.stories';
|
5
|
+
|
6
|
+
<Meta of={TypographyStories} />
|
7
|
+
|
8
|
+
# Typography
|
9
|
+
|
10
|
+
We use a set of typefaces...
|
11
|
+
|
12
|
+
<Story of={HeadingStories.Heading1} />
|
13
|
+
<Story of={HeadingStories.Heading2} />
|
14
|
+
<Story of={HeadingStories.Heading3} />
|
15
|
+
<Story of={HeadingGroupStories.HeadingGroup} />
|
16
|
+
<Story of={TypographyStories.BodyFont} />
|
17
|
+
|
18
|
+
<Canvas of={HeadingStories.Heading1} />
|
19
|
+
<Canvas of={HeadingStories.Heading2} />
|
20
|
+
<Canvas of={HeadingStories.Heading3} />
|
21
|
+
<Canvas of={HeadingGroupStories.HeadingGroup} />
|
22
|
+
<Canvas of={TypographyStories.BodyFont} />
|
@@ -0,0 +1,15 @@
|
|
1
|
+
const argTypes = {
|
2
|
+
text: { control: "text" },
|
3
|
+
};
|
4
|
+
|
5
|
+
export default {
|
6
|
+
title: "Global styles/Typography",
|
7
|
+
argTypes,
|
8
|
+
};
|
9
|
+
|
10
|
+
const BodyFontTemplate = ({ text }) => `<p>${text}</p>`;
|
11
|
+
|
12
|
+
export const BodyFont = BodyFontTemplate.bind({});
|
13
|
+
BodyFont.args = {
|
14
|
+
text: "This is some body text",
|
15
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "exports";
|
@@ -0,0 +1,36 @@
|
|
1
|
+
////
|
2
|
+
/// @group tools
|
3
|
+
////
|
4
|
+
|
5
|
+
/// List of modules which have already been exported
|
6
|
+
///
|
7
|
+
/// @type List
|
8
|
+
/// @access private
|
9
|
+
|
10
|
+
$_nationalarchives-imported-modules: () !default;
|
11
|
+
|
12
|
+
/// Export module
|
13
|
+
///
|
14
|
+
/// Ensure that the modules of CSS that we define throughout Frontend are only
|
15
|
+
/// included in the generated CSS once, no matter how many times they are
|
16
|
+
/// imported across the individual components.
|
17
|
+
///
|
18
|
+
/// @param {String} $name - Name of module - must be unique within the codebase
|
19
|
+
/// @content The passed content will only be outputted if a module of the same
|
20
|
+
/// $name has not already been outputted
|
21
|
+
/// @access public
|
22
|
+
|
23
|
+
@mixin nationalarchives-exports($name) {
|
24
|
+
// If the mixin is not in the list of modules already exported...
|
25
|
+
@if not index($_nationalarchives-imported-modules, $name) {
|
26
|
+
// ... then add it to the list
|
27
|
+
$_nationalarchives-imported-modules: append(
|
28
|
+
$_nationalarchives-imported-modules,
|
29
|
+
$name
|
30
|
+
) !global;
|
31
|
+
// ... and output the CSS for that module
|
32
|
+
@content;
|
33
|
+
}
|
34
|
+
// The next time exports is called for the module of the same name, it will be
|
35
|
+
// found in the list and so nothing will be outputted.
|
36
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
.tna-template {
|
2
|
+
min-width: 320px;
|
3
|
+
width: 100%;
|
4
|
+
height: 100%;
|
5
|
+
|
6
|
+
overflow-x: hidden;
|
7
|
+
overflow-y: auto;
|
8
|
+
-webkit-overflow-scrolling: touch;
|
9
|
+
|
10
|
+
@media (prefers-reduced-motion) {
|
11
|
+
* {
|
12
|
+
animation: none !important;
|
13
|
+
transition: none !important;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
.tna-template__body {
|
19
|
+
margin: 0;
|
20
|
+
padding: 0;
|
21
|
+
|
22
|
+
background-color: #fff;
|
23
|
+
|
24
|
+
overflow: auto;
|
25
|
+
}
|
26
|
+
|
27
|
+
img,
|
28
|
+
svg,
|
29
|
+
video,
|
30
|
+
canvas {
|
31
|
+
max-width: 100%;
|
32
|
+
|
33
|
+
display: block;
|
34
|
+
}
|
35
|
+
|
36
|
+
video,
|
37
|
+
canvas {
|
38
|
+
width: 100%;
|
39
|
+
}
|