@nationalarchives/frontend 0.1.5-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 (76) hide show
  1. package/README.md +1 -1
  2. package/govuk-prototype-kit.config.json +16 -1
  3. package/nationalarchives/all.css +1 -1
  4. package/nationalarchives/all.css.map +1 -1
  5. package/nationalarchives/all.js +1 -1
  6. package/nationalarchives/all.js.map +1 -1
  7. package/nationalarchives/all.scss +4 -3
  8. package/nationalarchives/components/_all.scss +6 -7
  9. package/nationalarchives/components/breadcrumbs/_index.scss +68 -0
  10. package/nationalarchives/components/breadcrumbs/breadcrumbs.stories.js +57 -0
  11. package/nationalarchives/components/breadcrumbs/fixtures.json +26 -0
  12. package/nationalarchives/components/breadcrumbs/macro-options.json +40 -0
  13. package/nationalarchives/components/breadcrumbs/macro.njk +3 -0
  14. package/nationalarchives/components/breadcrumbs/template.njk +13 -0
  15. package/nationalarchives/components/button/_index.scss +10 -11
  16. package/nationalarchives/components/button/button.stories.js +2 -3
  17. package/nationalarchives/components/card/_index.scss +48 -10
  18. package/nationalarchives/components/card/card.stories.js +43 -12
  19. package/nationalarchives/components/card/fixtures.json +135 -7
  20. package/nationalarchives/components/card/macro-options.json +42 -10
  21. package/nationalarchives/components/card/template.njk +53 -24
  22. package/nationalarchives/components/footer/_index.scss +33 -23
  23. package/nationalarchives/components/footer/fixtures.json +1 -1
  24. package/nationalarchives/components/footer/footer.stories.js +23 -3
  25. package/nationalarchives/components/footer/macro-options.json +12 -0
  26. package/nationalarchives/components/footer/template.njk +16 -5
  27. package/nationalarchives/components/grid/_index.scss +123 -51
  28. package/nationalarchives/components/grid/grid.stories.js +6 -4
  29. package/nationalarchives/components/grid/macro-options.json +7 -1
  30. package/nationalarchives/components/grid/template.njk +3 -0
  31. package/nationalarchives/components/hero/_index.scss +132 -0
  32. package/nationalarchives/components/hero/fixtures.json +4 -0
  33. package/nationalarchives/components/hero/hero.stories.js +74 -0
  34. package/nationalarchives/components/hero/macro-options.json +58 -0
  35. package/nationalarchives/components/hero/macro.njk +3 -0
  36. package/nationalarchives/components/hero/template.njk +30 -0
  37. package/nationalarchives/components/sensitive-image/_index.scss +10 -17
  38. package/nationalarchives/components/sensitive-image/sensitive-image.js +1 -1
  39. package/nationalarchives/components/sensitive-image/sensitive-image.js.map +1 -1
  40. package/nationalarchives/components/sensitive-image/sensitive-image.mjs +1 -1
  41. package/nationalarchives/components/sensitive-image/sensitive-image.stories.js +38 -3
  42. package/nationalarchives/stories/design/about.mdx +25 -0
  43. package/nationalarchives/stories/development/about.mdx +1 -1
  44. package/nationalarchives/stories/development/publishing.mdx +1 -0
  45. package/nationalarchives/stories/utilities/heading-groups.stories.js +44 -0
  46. package/nationalarchives/stories/{global → utilities}/headings.stories.js +1 -1
  47. package/nationalarchives/stories/utilities/lists.stories.js +38 -0
  48. package/nationalarchives/stories/{global → utilities}/typography.mdx +8 -8
  49. package/nationalarchives/stories/utilities/typography.stories.js +14 -0
  50. package/nationalarchives/templates/homepage.njk +64 -0
  51. package/nationalarchives/templates/layouts/_generic.njk +60 -0
  52. package/nationalarchives/templates/search-results.njk +38 -0
  53. package/nationalarchives/templates/topics.njk +42 -0
  54. package/nationalarchives/tools/_all.scss +3 -2
  55. package/nationalarchives/tools/_grid.scss +8 -95
  56. package/nationalarchives/tools/_media.scss +62 -0
  57. package/nationalarchives/tools/_typography.scss +6 -0
  58. package/nationalarchives/utilities/_all.scss +2 -2
  59. package/nationalarchives/utilities/_global.scss +8 -0
  60. package/nationalarchives/utilities/_typography.scss +126 -55
  61. package/nationalarchives/variables/_all.scss +4 -2
  62. package/nationalarchives/variables/_colour.scss +1 -0
  63. package/nationalarchives/variables/_grid.scss +7 -7
  64. package/nationalarchives/variables/_media.scss +11 -11
  65. package/nationalarchives/variables/_typography.scss +10 -0
  66. package/package.json +13 -5
  67. package/nationalarchives/_base.scss +0 -3
  68. package/nationalarchives/_prototype-kit.scss +0 -3
  69. package/nationalarchives/components/button/_button.scss +0 -2
  70. package/nationalarchives/components/card/_card.scss +0 -2
  71. package/nationalarchives/components/footer/_footer.scss +0 -2
  72. package/nationalarchives/components/grid/_grid.scss +0 -2
  73. package/nationalarchives/components/sensitive-image/_sensitive-image.scss +0 -2
  74. package/nationalarchives/stories/global/heading-groups.stories.js +0 -23
  75. package/nationalarchives/stories/global/typography.stories.js +0 -15
  76. package/nationalarchives/tools/_exports.scss +0 -36
@@ -17,7 +17,7 @@ SensitiveImage.prototype.init = function () {
17
17
  );
18
18
  };
19
19
 
20
- SensitiveImage.prototype.handleImageDetailsToggle = function (e) {
20
+ SensitiveImage.prototype.handleImageDetailsToggle = function () {
21
21
  if (this.$imageDetails.hasAttribute("open")) {
22
22
  this.$image.focus({ preventScroll: true, focusVisible: true });
23
23
  }
@@ -1,7 +1,8 @@
1
1
  import SensitiveImage from "./template.njk";
2
- import "../../all.scss";
3
- import "./_sensitive-image.scss";
2
+ import "./_index.scss";
4
3
  import macroOptions from "./macro-options.json";
4
+ import { expect } from "@storybook/jest";
5
+ import { within, userEvent } from "@storybook/testing-library";
5
6
 
6
7
  const argTypes = {
7
8
  src: { control: "text" },
@@ -9,7 +10,7 @@ const argTypes = {
9
10
  warning: { control: "text" },
10
11
  action: { control: "text" },
11
12
  classes: { control: "text" },
12
- attributes: { control: "text" },
13
+ attributes: { control: "object" },
13
14
  };
14
15
 
15
16
  Object.keys(argTypes).forEach((argType) => {
@@ -46,4 +47,38 @@ Standard.args = {
46
47
  warning: "This is a gory photo",
47
48
  action: "Show me the gory photo",
48
49
  classes: "tna-sensitive-image--demo",
50
+ attributes: {
51
+ "data-testid": "sensitive-image-test",
52
+ },
53
+ };
54
+
55
+ export const Test = Template.bind({});
56
+ Test.args = {
57
+ image: {
58
+ src: "https://picsum.photos/id/237/800/600",
59
+ alt: "A placeholder image",
60
+ width: 800,
61
+ height: 600,
62
+ },
63
+ warning: "This is a gory photo",
64
+ action: "Show me the gory photo",
65
+ classes: "tna-sensitive-image--demo",
66
+ attributes: {
67
+ "data-testid": "sensitive-image-test",
68
+ },
69
+ };
70
+
71
+ Test.play = async ({ args, canvasElement }) => {
72
+ const canvas = within(canvasElement);
73
+
74
+ const image = canvas.getByAltText(args.image.alt);
75
+ await expect(image).not.toBeVisible();
76
+ const warning = canvas.getByText(args.warning);
77
+ await expect(warning).toBeVisible();
78
+ const summaryOpen = canvas.getByText(args.action);
79
+ await expect(summaryOpen).toBeVisible();
80
+
81
+ await userEvent.click(summaryOpen);
82
+ await expect(image).toBeVisible();
83
+ await expect(warning).toBeVisible();
49
84
  };
@@ -0,0 +1,25 @@
1
+ import { Meta } from "@storybook/blocks";
2
+
3
+ <Meta title="Design/Prototyping" />
4
+
5
+ # Prototyping with the styles
6
+
7
+ The National Archives frontend styles include support for the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk/).
8
+
9
+ You can use the components and styles within the prototype kit to make rich HTML prototypes.
10
+
11
+ ## Create a new prototype
12
+
13
+ 1. Create an empty directory `mkdir my-new-prototype`
14
+ 1. Use `npx govuk-prototype-kit create` to create a new prototype project
15
+ 1. Install the frontend styles with `npm install @nationalarchives/frontend`
16
+ 1. Run `npm run dev` to start up the prototype kit
17
+ 1. Use the National Archives components!
18
+
19
+ ```Nunjucks
20
+ {% from "nationalarchives/components/button/macro.njk" import tnaButton %}
21
+ {{ tnaButton({
22
+ text: "I am a button",
23
+ url: "#"
24
+ }) }}
25
+ ```
@@ -15,7 +15,7 @@ TNA needed a frontend toolkit that was:
15
15
  - progressively enhanced - all components should still be operable without JavaScript, CSS or both
16
16
  - importable into projects (via a service such as [NPM](https://www.npmjs.com/search?q=nationalarchives)) - to make dependency management as simple as possible
17
17
  - agnostic - the implementation for the markup of the components can be replicated in any required technology (because we have Python, PHP and Java applications throughout the organisation)
18
- - testable - both from an internal perspective as well as providing scenarios and expected results for language implimentations to be able to validate against
18
+ - testable - both from an internal perspective as well as providing scenarios and expected results for language implementations to be able to validate against
19
19
  - lean - minimal reliance on other languages and dependencies to ensure good extendability and speed of development and deployment
20
20
  - automatically published - leveraging CI/CD, creating a new release version should be as simple as possible
21
21
 
@@ -9,6 +9,7 @@ import { Meta } from "@storybook/blocks";
9
9
  1. Run `nvm use` to ensure the correct Node version is used
10
10
  1. Run `npm install` to update the `package-lock.json`
11
11
  1. Merge all changes to `main` via a pull request
12
+ 1. Wait for the CI to pass
12
13
  1. Tag the version with `git tag v1.0.0` (ensure leading `v` and change version number as necessary)
13
14
  1. Push the new tag with `git push origin --tags`
14
15
  1. Create a [new release on GitHub](https://github.com/nationalarchives/tna-frontend/releases/new) using the tag you just created
@@ -0,0 +1,44 @@
1
+ const argTypes = {
2
+ supertitle: { control: "text" },
3
+ title: { control: "text" },
4
+ level: { control: "number", min: 1, max: 6, step: 1 },
5
+ size: { control: "radio", options: ["m", "l", "xl"] },
6
+ singleSentence: { control: "boolean" },
7
+ };
8
+
9
+ export default {
10
+ title: "Utilities/Typography",
11
+ argTypes,
12
+ };
13
+
14
+ const Template = ({
15
+ supertitle,
16
+ title,
17
+ level = 3,
18
+ size = "l",
19
+ singleSentence,
20
+ }) =>
21
+ singleSentence
22
+ ? `<hgroup class="tna-hgroup tna-hgroup--${size}">
23
+ <h${level} class="tna-hgroup__title">
24
+ <span class="tna-hgroup__supertitle">${supertitle}</span>
25
+ ${title}
26
+ </h${level}>
27
+ </hgroup>`
28
+ : `<hgroup class="tna-hgroup tna-hgroup--${size}">
29
+ <p class="tna-hgroup__supertitle">${supertitle}</p>
30
+ <h${level} class="tna-hgroup__title">${title}</h${level}>
31
+ </hgroup>`;
32
+
33
+ export const HeadingGroup = Template.bind({});
34
+ HeadingGroup.args = {
35
+ supertitle: "The story of",
36
+ title: "Alice Hawkins",
37
+ singleSentence: true,
38
+ };
39
+
40
+ export const HeadingGroupSeparated = Template.bind({});
41
+ HeadingGroupSeparated.args = {
42
+ supertitle: "Record revealed",
43
+ title: "The Monteagle Letter",
44
+ };
@@ -4,7 +4,7 @@ const argTypes = {
4
4
  };
5
5
 
6
6
  export default {
7
- title: "Global styles/Typography",
7
+ title: "Utilities/Typography",
8
8
  argTypes,
9
9
  };
10
10
 
@@ -0,0 +1,38 @@
1
+ const argTypes = {
2
+ items: { control: "object" },
3
+ };
4
+
5
+ export default {
6
+ title: "Utilities/Typography",
7
+ argTypes,
8
+ };
9
+
10
+ const UnorderedListTemplate = ({ items, plain }) =>
11
+ `<ul class="tna-ul${plain ? " tna-ul--plain" : ""}">${items.reduce(
12
+ (list, item) => `${list}<li>${item}</li>`,
13
+ ""
14
+ )}</ul>`;
15
+ export const UnorderedList = UnorderedListTemplate.bind({});
16
+ UnorderedList.args = {
17
+ items: ["Alpha", "Beta", "Gamma"],
18
+ };
19
+ export const UnorderedListPlain = UnorderedListTemplate.bind({});
20
+ UnorderedListPlain.args = {
21
+ items: ["Alpha", "Beta", "Gamma"],
22
+ plain: true,
23
+ };
24
+
25
+ const OrderedListTemplate = ({ items, plain }) =>
26
+ `<ol class="tna-ol${plain ? " tna-ol--plain" : ""}">${items.reduce(
27
+ (list, item) => `${list}<li>${item}</li>`,
28
+ ""
29
+ )}</ol>`;
30
+ export const OrderedList = OrderedListTemplate.bind({});
31
+ OrderedList.args = {
32
+ items: ["Alpha", "Beta", "Gamma"],
33
+ };
34
+ export const OrderedListPlain = OrderedListTemplate.bind({});
35
+ OrderedListPlain.args = {
36
+ items: ["Alpha", "Beta", "Gamma"],
37
+ plain: true,
38
+ };
@@ -1,7 +1,8 @@
1
- import { Meta, Primary, Controls, Story, Canvas, Typeset } from "@storybook/blocks";
1
+ import { Meta, Canvas } from "@storybook/blocks";
2
2
  import * as HeadingStories from './headings.stories';
3
3
  import * as HeadingGroupStories from './heading-groups.stories';
4
4
  import * as TypographyStories from './typography.stories';
5
+ import * as ListStories from './lists.stories';
5
6
 
6
7
  <Meta of={TypographyStories} />
7
8
 
@@ -9,14 +10,13 @@ import * as TypographyStories from './typography.stories';
9
10
 
10
11
  We use a set of typefaces...
11
12
 
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
13
  <Canvas of={HeadingStories.Heading1} />
19
14
  <Canvas of={HeadingStories.Heading2} />
20
15
  <Canvas of={HeadingStories.Heading3} />
21
16
  <Canvas of={HeadingGroupStories.HeadingGroup} />
22
- <Canvas of={TypographyStories.BodyFont} />
17
+ <Canvas of={HeadingGroupStories.HeadingGroupSeparated} />
18
+ <Canvas of={TypographyStories.Paragraph} />
19
+ <Canvas of={ListStories.UnorderedList} />
20
+ <Canvas of={ListStories.UnorderedListPlain} />
21
+ <Canvas of={ListStories.OrderedList} />
22
+ <Canvas of={ListStories.OrderedListPlain} />
@@ -0,0 +1,14 @@
1
+ const argTypes = {
2
+ text: { control: "text" },
3
+ };
4
+
5
+ export default {
6
+ title: "Utilities/Typography",
7
+ argTypes,
8
+ };
9
+
10
+ const ParagraphTemplate = ({ text }) => `<p class="tna-p">${text}</p>`;
11
+ export const Paragraph = ParagraphTemplate.bind({});
12
+ Paragraph.args = {
13
+ text: "This is some body text",
14
+ };
@@ -0,0 +1,64 @@
1
+ {% from "nationalarchives/components/card/macro.njk" import tnaCard %}
2
+
3
+ {% extends "nationalarchives/templates/layouts/_generic.njk" %}
4
+
5
+ {% block pageTitle %}The National Archives | Welcome{% endblock %}
6
+
7
+ {% block content %}
8
+ <div class="tna-container">
9
+ <div class="tna-column tna-column--full">
10
+ <h1 class="tna-heading tna-heading--xl">
11
+ Welcome
12
+ </h1>
13
+ </div>
14
+ <div class="tna-column tna-column--full">
15
+ {{ tnaCard({
16
+ "heading": {
17
+ "supertitle": "Card supertitle",
18
+ "title": "Card title",
19
+ "level": 2,
20
+ "size": "m"
21
+ },
22
+ "href": "#",
23
+ "image": {
24
+ "src": "https://loremflickr.com/640/360",
25
+ "alt": "A placeholder image"
26
+ },
27
+ "body": "<p>Card body</p>",
28
+ "actions": [
29
+ {
30
+ "text": "Card action",
31
+ "href": "#",
32
+ "title": "Go and do the action"
33
+ }
34
+ ],
35
+ "featured": true,
36
+ "htmlElement": "article"
37
+ }) }}
38
+ </div>
39
+ {% for item in range(0, 6) -%}
40
+ <div class="tna-column tna-column--width-1-3 tna-column--width-1-2-medium tna-column--full-small tna-column--full-tiny">
41
+ {{ tnaCard({
42
+ "heading": {
43
+ "supertitle": "Card supertitle",
44
+ "title": "Card title",
45
+ "level": 3
46
+ },
47
+ "href": "#",
48
+ "image": {
49
+ "src": "https://loremflickr.com/640/360",
50
+ "alt": "A placeholder image"
51
+ },
52
+ "body": "<p>Card body</p>",
53
+ "actions": [
54
+ {
55
+ "text": "Card action",
56
+ "href": "#",
57
+ "title": "Go and do the action"
58
+ }
59
+ ]
60
+ }) }}
61
+ </div>
62
+ {%- endfor %}
63
+ </div>
64
+ {% endblock %}
@@ -0,0 +1,60 @@
1
+ {# Based on https://github.com/alphagov/govuk-frontend/blob/8b6bf304b9fc891f64459c25a08f3d623f3fea72/packages/govuk-frontend/src/govuk/template.njk #}
2
+ {#% from "./components/skip-link/macro.njk" import tnaSkipLink -%#}
3
+ <!DOCTYPE html>
4
+ <html lang="{{ htmlLang | default('en') }}" class="tna-template {{ htmlClasses }}">
5
+ <head>
6
+ <meta charset="utf-8">
7
+ <title{% if pageTitleLang %} lang="{{ pageTitleLang }}"{% endif %}>{% block pageTitle %}The National Archives{% endblock %}</title>
8
+ <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
9
+ <meta name="theme-color" content="{{ themeColor | default('#000000') }}">
10
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
11
+
12
+ {% block headIcons %}
13
+ <link rel="shortcut icon" sizes="16x16 32x32 48x48" href="{{ assetPath | default('/assets') }}/images/favicon.ico" type="image/x-icon">
14
+ <link rel="mask-icon" href="{{ assetPath | default('/assets') }}/images/govuk-mask-icon.svg" color="{{ themeColor | default('#0b0c0c') }}"> {# Hardcoded value of $govuk-black #}
15
+ <link rel="apple-touch-icon" sizes="180x180" href="{{ assetPath | default('/assets') }}/images/govuk-apple-touch-icon-180x180.png">
16
+ <link rel="apple-touch-icon" sizes="167x167" href="{{ assetPath | default('/assets') }}/images/govuk-apple-touch-icon-167x167.png">
17
+ <link rel="apple-touch-icon" sizes="152x152" href="{{ assetPath | default('/assets') }}/images/govuk-apple-touch-icon-152x152.png">
18
+ <link rel="apple-touch-icon" href="{{ assetPath | default('/assets') }}/images/govuk-apple-touch-icon.png">
19
+ {% endblock %}
20
+
21
+ {% block head %}{% endblock %}
22
+
23
+ {% block stylesheets %}
24
+ {% include "govuk-prototype-kit/includes/stylesheets-plugins.njk" %}
25
+ {% endblock %}
26
+
27
+ {# OpenGraph images needs to be absolute, so we need either a URL for the image or for assetUrl to be set #}
28
+ {% if opengraphImageUrl or assetUrl %}
29
+ <meta property="og:image" content="{{ opengraphImageUrl | default(assetUrl + '/images/govuk-opengraph-image.png') }}">
30
+ {% endif %}
31
+ </head>
32
+ <body class="tna-template__body {{ bodyClasses }}" {%- for attribute, value in bodyAttributes %} {{attribute}}="{{value}}"{% endfor %}>
33
+
34
+ {% block bodyStart %}{% endblock %}
35
+
36
+ {% block skipLink %}
37
+ {#{ govukSkipLink({
38
+ href: '#main-content',
39
+ text: 'Skip to main content'
40
+ }) }#}
41
+ {% endblock %}
42
+
43
+ {% block header %}
44
+ <h1>HEADER</h1>
45
+ {% endblock %}
46
+
47
+ {% block main %}
48
+ {% block beforeContent %}{% endblock %}
49
+ <main class="tna-main-wrapper {{ mainClasses }}" id="main-content" role="main"{% if mainLang %} lang="{{ mainLang }}"{% endif %}>
50
+ {% block content %}{% endblock %}
51
+ </main>
52
+ {% endblock %}
53
+
54
+ {% block footer %}
55
+ <h1>FOOTER</h1>
56
+ {% endblock %}
57
+
58
+ {% block bodyEnd %}{% endblock %}
59
+ </body>
60
+ </html>
@@ -0,0 +1,38 @@
1
+ {% from "nationalarchives/components/card/macro.njk" import tnaCard %}
2
+
3
+ {% extends "nationalarchives/templates/layouts/_generic.njk" %}
4
+
5
+ {% block pageTitle %}The National Archives | Results{% endblock %}
6
+
7
+ {% block main %}
8
+ <div class="tna-container">
9
+ <div class="tna-column tna-column--1-4 tna-column--width-1-3-medium tna-column--full-small tna-column--full-tiny">
10
+ <h2>Search filters...</h2>
11
+ </div>
12
+ <main class="tna-main-wrapper tna-column tna-column--container tna-column--3-4 tna-column--width-2-3-medium tna-column--full-small tna-column--full-tiny {{ mainClasses }}" id="main-content" role="main"{% if mainLang %} lang="{{ mainLang }}"{% endif %}>
13
+ {% block beforeContent %}{% endblock %}
14
+ <div class="tna-column tna-column--full">
15
+ <h1 class="tna-heading tna-heading--xl">
16
+ Search results for "foobar"
17
+ </h1>
18
+ </div>
19
+ {% for item in range(0, 6) -%}
20
+ <div class="tna-column tna-column--width-1-2 tna-column--width-full-small tna-column--width-full-tiny">
21
+ {{ tnaCard({
22
+ "heading": {
23
+ "supertitle": "Card supertitle",
24
+ "title": "Card title",
25
+ "level": 2
26
+ },
27
+ "href": "#",
28
+ "image": {
29
+ "src": "https://loremflickr.com/640/360",
30
+ "alt": "A placeholder image"
31
+ },
32
+ "body": "<p>Card body</p>",
33
+ }) }}
34
+ </div>
35
+ {%- endfor %}
36
+ </main>
37
+ </div>
38
+ {% endblock %}
@@ -0,0 +1,42 @@
1
+ {% from "nationalarchives/components/card/macro.njk" import tnaCard %}
2
+ {% from "nationalarchives/components/hero/macro.njk" import tnaHero %}
3
+
4
+ {% extends "nationalarchives/templates/layouts/_generic.njk" %}
5
+
6
+ {% block pageTitle %}The National Archives | Topics{% endblock %}
7
+
8
+ {% block main %}
9
+ <main class="tna-main-wrapper">
10
+ {{ tnaHero({
11
+ "heading": "Title",
12
+ "body": "<p>Body</p>",
13
+ "image": {
14
+ "src": "https://picsum.photos/id/29/640/360",
15
+ "alt": "A placeholder image",
16
+ "information": "Photo of some mountains by a famous photographer, ©2012"
17
+ }
18
+ }) }}
19
+ <div class="tna-container">
20
+ <div class="tna-column tna-column--full">
21
+ <h2>Topic title</h2>
22
+ </div>
23
+ {% for item in range(0, 6) -%}
24
+ <div class="tna-column tna-column--width-1-3 tna-column--width-1-2-medium tna-column--width-full-small tna-column--width-full-tiny">
25
+ {{ tnaCard({
26
+ "heading": {
27
+ "supertitle": "Card supertitle",
28
+ "title": "Card title",
29
+ "level": 3
30
+ },
31
+ "href": "#",
32
+ "image": {
33
+ "src": "https://loremflickr.com/640/360",
34
+ "alt": "A placeholder image"
35
+ },
36
+ "body": "<p>Card body</p>",
37
+ }) }}
38
+ </div>
39
+ {%- endfor %}
40
+ </div>
41
+ </main>
42
+ {% endblock %}
@@ -1,2 +1,3 @@
1
- @import "exports";
2
- @import "grid";
1
+ @use "grid";
2
+ @use "media";
3
+ @use "typography";
@@ -1,15 +1,17 @@
1
- @import "../variables/all";
1
+ @use "sass:math";
2
+ @use "../variables/grid";
2
3
 
3
4
  @mixin columns-generator($count, $suffix: "") {
4
5
  @for $i from 1 through $count - 1 {
5
- $simplestFractionFound: false;
6
+ $simplest-fraction-found: false;
6
7
 
7
8
  @for $j from math.div($count, 2) through 1 {
8
9
  @if (
9
- $count % $j == 0 and $i % $j == 0 and $simplestFractionFound != true
10
+ $count % $j == 0 and $i % $j == 0 and $simplest-fraction-found != true
10
11
  ) {
11
12
  .tna-column--width-#{math.div($i, $j)}-#{math.div($count, $j)}#{$suffix} {
12
13
  width: math.div(100%, $count) * $i;
14
+ flex: none;
13
15
  }
14
16
 
15
17
  // .column--margin-right-#{math.div($i, $j)}-#{math.div($count, $j)}#{$suffix} {
@@ -20,13 +22,14 @@
20
22
  // margin-left: math.div(100%, $count) * $i;
21
23
  // }
22
24
 
23
- $simplestFractionFound: true;
25
+ $simplest-fraction-found: true;
24
26
  }
25
27
  }
26
28
 
27
- @if ($simplestFractionFound != true) {
29
+ @if $simplest-fraction-found != true {
28
30
  .tna-column--width-#{$i}-#{$count}#{$suffix} {
29
31
  width: math.div(100%, $count) * $i;
32
+ flex: none;
30
33
  }
31
34
 
32
35
  // .column--margin-right-#{$i}-#{$count}#{$suffix} {
@@ -39,93 +42,3 @@
39
42
  }
40
43
  }
41
44
  }
42
-
43
- @mixin grid-medium {
44
- .tna-column--width-full-medium {
45
- width: 100%;
46
- }
47
-
48
- @for $i from 1 through 3 {
49
- .tna-column--flex-#{$i}-medium {
50
- flex: $i 0;
51
- }
52
- }
53
-
54
- // @for $i from 1 through 3 {
55
- // .column--order-#{$i}-medium {
56
- // order: $i;
57
- // }
58
- // }
59
-
60
- @include columns-generator($column-count-medium, "-medium");
61
- }
62
-
63
- @mixin grid-mobile {
64
- .tna-container {
65
- padding-right: math.div($gutter-width-mobile, 2) + 0.75rem;
66
- padding-left: math.div($gutter-width-mobile, 2) + 0.75rem;
67
- }
68
-
69
- .tna-column {
70
- padding-right: math.div($gutter-width-mobile, 2);
71
- padding-left: math.div($gutter-width-mobile, 2);
72
- }
73
-
74
- // .column--width-full-mobile {
75
- // width: 100%;
76
- // }
77
-
78
- // @for $i from 1 through 3 {
79
- // .column--flex-#{$i}-mobile {
80
- // flex: $i 0;
81
- // }
82
- // }
83
-
84
- // @for $i from 1 through 3 {
85
- // .column--order-#{$i}-mobile {
86
- // order: $i;
87
- // }
88
- // }
89
- }
90
-
91
- @mixin grid-small {
92
- .tna-column--width-full-small {
93
- width: 100%;
94
- }
95
-
96
- @for $i from 1 through 3 {
97
- .tna-column--flex-#{$i}-small {
98
- flex: $i 0;
99
- }
100
- }
101
-
102
- // @for $i from 1 through 3 {
103
- // .column--order-#{$i}-small {
104
- // order: $i;
105
- // }
106
- // }
107
-
108
- @include columns-generator($column-count-small, "-small");
109
- }
110
-
111
- @mixin grid-tiny {
112
- .tna-column--width-full-tiny {
113
- width: 100%;
114
- }
115
-
116
- @for $i from 1 through 3 {
117
- .tna-column--flex-#{$i}-tiny {
118
- width: auto;
119
-
120
- flex: $i 0;
121
- }
122
- }
123
-
124
- // @for $i from 1 through 3 {
125
- // .column--order-#{$i}-tiny {
126
- // order: $i;
127
- // }
128
- // }
129
-
130
- @include columns-generator($column-count-tiny, "-tiny");
131
- }
@@ -0,0 +1,62 @@
1
+ @use "../variables/media";
2
+
3
+ // 0 ============= 480 ===== 768 == 1024 ==========================
4
+ // | | | |
5
+ // | TINY | SMALL | MED | LARGE
6
+ // | | | |
7
+ // |<------------->| . . on-tiny
8
+ // |<----------------------->| . on-mobile
9
+ // |<------------------------------>| on-smaller-than-large
10
+ // . |<------->| . on-small
11
+ // . |<------------------------- on-larger-than-tiny
12
+ // . . |<---->| on-medium
13
+ // . . |<--------------- on-larger-than-mobile
14
+ // . . . |<-------- on-large
15
+
16
+ @mixin on-large() {
17
+ @media #{media.$media-large} {
18
+ @content;
19
+ }
20
+ }
21
+
22
+ @mixin on-medium() {
23
+ @media #{media.$media-medium} {
24
+ @content;
25
+ }
26
+ }
27
+
28
+ @mixin on-small() {
29
+ @media #{media.$media-small} {
30
+ @content;
31
+ }
32
+ }
33
+
34
+ @mixin on-tiny() {
35
+ @media #{media.$media-tiny} {
36
+ @content;
37
+ }
38
+ }
39
+
40
+ @mixin on-larger-than-mobile() {
41
+ @media #{media.$media-gt-mobile} {
42
+ @content;
43
+ }
44
+ }
45
+
46
+ @mixin on-larger-than-tiny() {
47
+ @media #{media.$media-gt-tiny} {
48
+ @content;
49
+ }
50
+ }
51
+
52
+ @mixin on-smaller-than-large() {
53
+ @media #{media.$media-lt-large} {
54
+ @content;
55
+ }
56
+ }
57
+
58
+ @mixin on-mobile() {
59
+ @media #{media.$media-mobile} {
60
+ @content;
61
+ }
62
+ }
@@ -0,0 +1,6 @@
1
+ @use "sass:math";
2
+ @use "../variables/typography";
3
+
4
+ @mixin relative-font-size($fontSizePx) {
5
+ font-size: #{math.div($fontSizePx, typography.$base-font-size-px)}rem;
6
+ }
@@ -1,2 +1,2 @@
1
- @import "global";
2
- @import "typography";
1
+ @use "global";
2
+ @use "typography";