@nationalarchives/frontend 0.1.20-prerelease → 0.1.22-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 +1 -1
- package/govuk-prototype-kit.config.json +7 -2
- package/nationalarchives/_prototype-kit.scss +16 -0
- package/nationalarchives/all.css +3 -3
- package/nationalarchives/all.css.map +1 -1
- package/nationalarchives/all.js +1 -1
- package/nationalarchives/all.js.map +1 -1
- package/nationalarchives/all.mjs +17 -10
- package/nationalarchives/all.scss +1 -5
- package/nationalarchives/assets/images/favicon.ico +0 -0
- package/nationalarchives/assets/images/mask-icon.svg +17 -5
- package/nationalarchives/assets/images/mstile-150x150.png +0 -0
- package/nationalarchives/components/_index.scss +1 -0
- package/nationalarchives/components/breadcrumbs/breadcrumbs.css +1 -1
- package/nationalarchives/components/breadcrumbs/breadcrumbs.css.map +1 -1
- package/nationalarchives/components/breadcrumbs/breadcrumbs.js +1 -1
- package/nationalarchives/components/breadcrumbs/breadcrumbs.js.map +1 -1
- package/nationalarchives/components/breadcrumbs/breadcrumbs.mjs +5 -15
- package/nationalarchives/components/breadcrumbs/breadcrumbs.scss +12 -4
- package/nationalarchives/components/breadcrumbs/breadcrumbs.stories.js +64 -0
- package/nationalarchives/components/breadcrumbs/fixtures.json +2 -2
- package/nationalarchives/components/breadcrumbs/template.njk +11 -15
- package/nationalarchives/components/button/_button-group.scss +1 -1
- package/nationalarchives/components/button/button.css +1 -13
- package/nationalarchives/components/button/button.css.map +1 -1
- package/nationalarchives/components/button/button.scss +24 -6
- package/nationalarchives/components/card/card.css +1 -13
- package/nationalarchives/components/card/card.css.map +1 -1
- package/nationalarchives/components/card/card.scss +52 -7
- package/nationalarchives/components/card/card.stories.js +78 -36
- package/nationalarchives/components/card/fixtures.json +40 -16
- package/nationalarchives/components/card/macro-options.json +26 -0
- package/nationalarchives/components/card/template.njk +38 -26
- package/nationalarchives/components/cookie-banner/cookie-banner.css +1 -13
- package/nationalarchives/components/cookie-banner/cookie-banner.css.map +1 -1
- package/nationalarchives/components/cookie-banner/cookie-banner.js +1 -1
- package/nationalarchives/components/cookie-banner/cookie-banner.js.map +1 -1
- package/nationalarchives/components/cookie-banner/cookie-banner.mjs +15 -7
- package/nationalarchives/components/cookie-banner/cookie-banner.scss +9 -1
- package/nationalarchives/components/cookie-banner/cookie-banner.stories.js +23 -10
- package/nationalarchives/components/cookie-banner/macro-options.json +1 -1
- package/nationalarchives/components/cookie-banner/template.njk +4 -4
- package/nationalarchives/components/filters/filters.css +1 -1
- package/nationalarchives/components/filters/filters.css.map +1 -1
- package/nationalarchives/components/filters/filters.scss +2 -2
- package/nationalarchives/components/footer/fixtures.json +1 -1
- package/nationalarchives/components/footer/footer.css +1 -13
- package/nationalarchives/components/footer/footer.css.map +1 -1
- package/nationalarchives/components/footer/footer.scss +8 -55
- package/nationalarchives/components/footer/footer.stories.js +1 -1
- package/nationalarchives/components/footer/template.njk +16 -14
- package/nationalarchives/components/gallery/gallery.css +1 -13
- package/nationalarchives/components/gallery/gallery.css.map +1 -1
- package/nationalarchives/components/gallery/template.njk +2 -2
- package/nationalarchives/components/grid/grid.css +1 -1
- package/nationalarchives/components/grid/grid.css.map +1 -1
- package/nationalarchives/components/grid/grid.scss +15 -11
- package/nationalarchives/components/grid/grid.stories.js +21 -0
- package/nationalarchives/components/grid/macro-options.json +48 -0
- package/nationalarchives/components/grid/template.njk +29 -3
- package/nationalarchives/components/header/header.css +1 -1
- package/nationalarchives/components/header/header.css.map +1 -1
- package/nationalarchives/components/header/header.scss +60 -145
- package/nationalarchives/components/header/header.stories.js +2 -0
- package/nationalarchives/components/header/macro-options.json +12 -0
- package/nationalarchives/components/header/template.njk +6 -1
- package/nationalarchives/components/hero/fixtures.json +166 -6
- package/nationalarchives/components/hero/hero.css +1 -1
- package/nationalarchives/components/hero/hero.css.map +1 -1
- package/nationalarchives/components/hero/hero.scss +187 -64
- package/nationalarchives/components/hero/hero.stories.js +98 -23
- package/nationalarchives/components/hero/macro-options.json +48 -12
- package/nationalarchives/components/hero/template.njk +34 -24
- package/nationalarchives/components/index-grid/index-grid.css +1 -1
- package/nationalarchives/components/index-grid/index-grid.css.map +1 -1
- package/nationalarchives/components/index-grid/template.njk +2 -2
- package/nationalarchives/components/message/message.css +1 -1
- package/nationalarchives/components/message/message.css.map +1 -1
- package/nationalarchives/components/message/message.scss +4 -0
- package/nationalarchives/components/pagination/_index.scss +1 -0
- package/nationalarchives/components/pagination/fixtures.json +4 -0
- package/nationalarchives/components/pagination/macro-options.json +116 -0
- package/nationalarchives/components/pagination/macro.njk +3 -0
- package/nationalarchives/components/pagination/pagination.css +1 -0
- package/nationalarchives/components/pagination/pagination.css.map +1 -0
- package/nationalarchives/components/pagination/pagination.scss +98 -0
- package/nationalarchives/components/pagination/pagination.stories.js +73 -0
- package/nationalarchives/components/pagination/template.njk +38 -0
- package/nationalarchives/components/phase-banner/phase-banner.css +1 -1
- package/nationalarchives/components/phase-banner/phase-banner.css.map +1 -1
- package/nationalarchives/components/phase-banner/phase-banner.scss +5 -1
- package/nationalarchives/components/picture/picture.css +1 -13
- package/nationalarchives/components/picture/picture.css.map +1 -1
- package/nationalarchives/components/picture/picture.scss +1 -1
- package/nationalarchives/components/picture/picture.stories.js +2 -2
- package/nationalarchives/components/profile/profile.css +1 -1
- package/nationalarchives/components/profile/profile.css.map +1 -1
- package/nationalarchives/components/profile/template.njk +2 -2
- package/nationalarchives/components/sensitive-image/sensitive-image.css +1 -1
- package/nationalarchives/components/sensitive-image/sensitive-image.css.map +1 -1
- package/nationalarchives/components/skip-link/fixtures.json +1 -1
- package/nationalarchives/components/skip-link/skip-link.css +1 -1
- package/nationalarchives/components/skip-link/skip-link.css.map +1 -1
- package/nationalarchives/components/skip-link/skip-link.js +2 -0
- package/nationalarchives/components/skip-link/skip-link.js.map +1 -0
- package/nationalarchives/components/skip-link/skip-link.mjs +40 -0
- package/nationalarchives/components/skip-link/skip-link.scss +18 -16
- package/nationalarchives/components/skip-link/skip-link.stories.js +48 -6
- package/nationalarchives/components/skip-link/template.njk +1 -1
- package/nationalarchives/components/tabs/tabs.css +1 -1
- package/nationalarchives/components/tabs/tabs.css.map +1 -1
- package/nationalarchives/components/tabs/tabs.js +1 -1
- package/nationalarchives/components/tabs/tabs.js.map +1 -1
- package/nationalarchives/components/tabs/tabs.mjs +6 -2
- package/nationalarchives/components/tabs/tabs.scss +17 -2
- package/nationalarchives/components/tabs/tabs.stories.js +6 -6
- package/nationalarchives/lib/_font-awesome.scss +3 -2
- package/nationalarchives/lib/cookies.mjs +122 -50
- package/nationalarchives/stories/development/contributing.mdx +0 -10
- package/nationalarchives/stories/development/cookies.mdx +82 -0
- package/nationalarchives/stories/development/structure.mdx +88 -0
- package/nationalarchives/stories/development/using/compiled.mdx +9 -0
- package/nationalarchives/stories/development/using/hosted.mdx +53 -0
- package/nationalarchives/stories/development/using/npm.mdx +59 -0
- package/nationalarchives/stories/utilities/colour-schemes/colour-schemes.stories.js +333 -72
- package/nationalarchives/stories/utilities/overrides/overrides.stories.js +10 -21
- package/nationalarchives/stories/utilities/typography/heading-groups.stories.js +2 -2
- package/nationalarchives/stories/utilities/typography/headings.stories.js +6 -3
- package/nationalarchives/stories/utilities/typography/lists.stories.js +93 -0
- package/nationalarchives/stories/utilities/typography/typography.mdx +11 -1
- package/nationalarchives/stories/utilities/typography/typography.stories.js +1 -1
- package/nationalarchives/templates/homepage.njk +11 -58
- package/nationalarchives/templates/layouts/_generic.njk +31 -14
- package/nationalarchives/templates/layouts/_prototype-kit.njk +11 -0
- package/nationalarchives/templates/search-results.njk +11 -15
- package/nationalarchives/templates/topics.njk +18 -22
- package/nationalarchives/tools/_colour.scss +77 -23
- package/nationalarchives/tools/_grid.scss +12 -12
- package/nationalarchives/tools/_media.scss +6 -0
- package/nationalarchives/tools/_spacing.scss +6 -6
- package/nationalarchives/tools/_typography.scss +4 -2
- package/nationalarchives/utilities/_a11y.scss +15 -0
- package/nationalarchives/utilities/_columns.scss +42 -0
- package/nationalarchives/utilities/_debug.scss +1 -1
- package/nationalarchives/utilities/_global.scss +32 -32
- package/nationalarchives/utilities/_index.scss +2 -0
- package/nationalarchives/utilities/_lists.scss +181 -0
- package/nationalarchives/utilities/_typography.scss +129 -138
- package/nationalarchives/variables/_assets.scss +2 -1
- package/nationalarchives/variables/_colour.scss +94 -74
- package/nationalarchives/variables/_features.scss +1 -0
- package/nationalarchives/variables/_grid.scss +5 -5
- package/nationalarchives/variables/_index.scss +1 -0
- package/nationalarchives/variables/_media.scss +29 -29
- package/nationalarchives/variables/_typography.scss +15 -12
- package/package.json +15 -14
- package/nationalarchives/_features.scss +0 -1
- package/nationalarchives/assets/images/tna-horizontal-logo-inverted.svg +0 -51
- package/nationalarchives/assets/images/tna-horizontal-logo.svg +0 -51
- package/nationalarchives/stories/design/about.mdx +0 -25
- package/nationalarchives/stories/development/relationships.mdx +0 -57
- package/nationalarchives/stories/development/using.mdx +0 -75
@@ -30,13 +30,3 @@ import { Meta } from "@storybook/blocks";
|
|
30
30
|
1. Import and initialise your component as part of the `initAll` function in `src/nationalarchives/all.mjs`
|
31
31
|
1. Update the check in `tasks/test-package.js` to add the JavaScript class to check for
|
32
32
|
1. If your component uses JavaScript, ensure you add interaction tests using `@storybook/testing-library`
|
33
|
-
|
34
|
-
### Best practices
|
35
|
-
|
36
|
-
- [HTML standards](https://nationalarchives.github.io/developer-handbook/technology/html/)
|
37
|
-
- [JavaScript standards](https://nationalarchives.github.io/developer-handbook/technology/javascript/)
|
38
|
-
- [CSS standards](https://nationalarchives.github.io/developer-handbook/technology/css/)
|
39
|
-
|
40
|
-
## Updating a component
|
41
|
-
|
42
|
-
[TODO]
|
@@ -0,0 +1,82 @@
|
|
1
|
+
import { Meta } from "@storybook/blocks";
|
2
|
+
import { Mermaid } from 'mdx-mermaid/Mermaid';
|
3
|
+
|
4
|
+
<Meta title="Development/Cookies" />
|
5
|
+
|
6
|
+
# Cookies handling
|
7
|
+
|
8
|
+
The principles of cookie handling are:
|
9
|
+
|
10
|
+
- Create cookies on the client side (apart from session cookies)
|
11
|
+
- Update cookies on the client side (apart from session cookies)
|
12
|
+
- Reject by default (don't assume acceptance and don't add tracking until after they agree)
|
13
|
+
|
14
|
+
## Policies
|
15
|
+
|
16
|
+
As standard we should use at least these three classes of cookies:
|
17
|
+
|
18
|
+
- `essential` - we don't need to ask permission for these
|
19
|
+
- `usage` - analytics, tracking, data gathering
|
20
|
+
- `settings` - configured options for the site (e.g. default results view or static light/dark mode)
|
21
|
+
|
22
|
+
## Process
|
23
|
+
|
24
|
+
### First visit
|
25
|
+
|
26
|
+
<Mermaid chart={`sequenceDiagram
|
27
|
+
User->>Browser: Request page
|
28
|
+
Browser->>Server: HTTP request with no cookies
|
29
|
+
Server->>Browser: Rendered HTML with cookie banner and no analytics
|
30
|
+
Browser->>User: Accept cookies?
|
31
|
+
alt Accept
|
32
|
+
User->>Browser: Accept cookies
|
33
|
+
Browser->>Browser: Create cookie policy with all accepted
|
34
|
+
Browser->>Browser: Add analytics code with JavaScript
|
35
|
+
else Reject
|
36
|
+
User->>Browser: Reject cookies
|
37
|
+
Browser->>Browser: Create cookie policy with all rejected
|
38
|
+
end
|
39
|
+
opt Next request
|
40
|
+
User->>Browser: Request page
|
41
|
+
Browser->>Server: HTTP request with cookie policy
|
42
|
+
Server->>Browser: Rendered HTML with analytics but no cookie banner
|
43
|
+
end
|
44
|
+
`} />
|
45
|
+
|
46
|
+
### Repeat visit
|
47
|
+
|
48
|
+
<Mermaid chart={`sequenceDiagram
|
49
|
+
User->>Browser: Request page
|
50
|
+
Browser->>Server: HTTP request with cookie policy
|
51
|
+
Server->>Browser: Rendered HTML with analytics but no cookie banner
|
52
|
+
`} />
|
53
|
+
|
54
|
+
## Cookie library
|
55
|
+
|
56
|
+
When you load in the tna-frontend JavaScript, it comes with a [cookie library](https://github.com/nationalarchives/tna-frontend/blob/main/src/nationalarchives/lib/cookies.mjs).
|
57
|
+
|
58
|
+
This is loaded into the `window` object as `TNAFrontend.Cookies`:
|
59
|
+
|
60
|
+
```JavaScript
|
61
|
+
// Initialise a new Cookie instance
|
62
|
+
const cookies = new TNAFrontend.Cookies();
|
63
|
+
|
64
|
+
// Log all the cookies to the console
|
65
|
+
console.log(cookies.all);
|
66
|
+
```
|
67
|
+
|
68
|
+
### Functions
|
69
|
+
|
70
|
+
- `cookies.all` - Returns all the cookies
|
71
|
+
- `cookies.exists(key)` - Returns `true` if a cookie exists with the name `key`
|
72
|
+
- `cookies.hasValue(key, value)` - Returns `true` if the cookie with the name `key` is equal to `value`
|
73
|
+
- `cookies.get(key)` - Returns the cookie with the name `key`
|
74
|
+
- `cookies.set(key, value, maxAge, path)` - Set a cookie (max age default is one year, default path is `/`)
|
75
|
+
- `cookies.delete(key)` - Deletes the cookie with the name `key`
|
76
|
+
- `cookies.allPolicies` - Returns all the cookie policies
|
77
|
+
- `cookies.acceptPolicy(policy)` - Accepts the policy with the name `policy`
|
78
|
+
- `cookies.rejectPolicy(policy)` - Rejects the policy with the name `policy`
|
79
|
+
- `cookies.setPolicy(policy, accepted)` - Accepts or rejects the policy with the name `policy` depending on the value of `accepted`
|
80
|
+
- `cookies.acceptAllPolicies()` - Accepts all policies
|
81
|
+
- `cookies.rejectAllPolicies()` - Rejects all policies
|
82
|
+
- `cookies.isPolicyAccepted(policy)` - Returns `true` or `false` depending on whether the policy has been accepted
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import { Meta } from "@storybook/blocks";
|
2
|
+
|
3
|
+
<Meta title="Development/Structure" />
|
4
|
+
|
5
|
+
# Structure
|
6
|
+
|
7
|
+
The layers of the TNA frontend SCSS library is built as:
|
8
|
+
|
9
|
+
1. [Variables](#variables)
|
10
|
+
1. [Tools](#tools)
|
11
|
+
1. [Libraries](#libraries)/[Utilities](#utilities)
|
12
|
+
1. [Components](#components)
|
13
|
+
1. [Overrides](#overrides)
|
14
|
+
|
15
|
+
## Variables
|
16
|
+
|
17
|
+
TNA frontend variables are defined in `src/nationalarchives/variables`.
|
18
|
+
|
19
|
+
Lots of variables can be modified but some are fixed, such as our brand colours.
|
20
|
+
|
21
|
+
An example fixed variable is `$relative-1rem-px` where we set the value of `1rem` to `16px` which makes it easier to define widths as a function of `1rem` as we mostly work on a 4px grid:
|
22
|
+
|
23
|
+
| Pixels | REM |
|
24
|
+
| ------ | ----------- |
|
25
|
+
| `1px` | `0.0625rem` |
|
26
|
+
| `2px` | `0.125rem` |
|
27
|
+
| `4px` | `0.25rem` |
|
28
|
+
| `8px` | `0.5rem` |
|
29
|
+
| `16px` | `1rem` |
|
30
|
+
| `32px` | `2rem` |
|
31
|
+
| `64px` | `4rem` |
|
32
|
+
|
33
|
+
An example of a variable that can be modified is `$body-font-size-px` which we set to `18px` by default. This font size might not be right for all services so we have allowed it to be modified.
|
34
|
+
|
35
|
+
## Tools
|
36
|
+
|
37
|
+
The tools provided are reusable `@mixin` and `@function` blocks to make writing styles easier. They are defined in `src/nationalarchives/tools`.
|
38
|
+
|
39
|
+
Tools rely directly on variables and can be used throughout the frontend library.
|
40
|
+
|
41
|
+
As an exmaple, `colour-font()` will apply a font colour in a way that should work for all browsers and takes into consideration the light/dark theme used.
|
42
|
+
|
43
|
+
## Libraries
|
44
|
+
|
45
|
+
The libraries in `src/nationalarchives/lib` are a mix of third party libraries as well as some TNA ones.
|
46
|
+
|
47
|
+
They can join up tools to make larger, more useful elements.
|
48
|
+
|
49
|
+
## Utilities
|
50
|
+
|
51
|
+
The utilities in `src/nationalarchives/utilities` are some global styles that aren't associated with a specific component.
|
52
|
+
|
53
|
+
This layer is where we define some general purpose elements such as:
|
54
|
+
|
55
|
+
- The `tna-template` and `tna-template__body` elements
|
56
|
+
- Headings
|
57
|
+
- Lists
|
58
|
+
- Chips
|
59
|
+
- `<p>` elements
|
60
|
+
- General media elements like `<img>`, `<svg>`, `<picture>`, `<video>` and `<canvas>`
|
61
|
+
- Columns
|
62
|
+
- General form elements
|
63
|
+
|
64
|
+
These elements all still adhere to the [BEM methodology](https://getbem.com/).
|
65
|
+
|
66
|
+
Utilities should not implement any `!important` rules.
|
67
|
+
|
68
|
+
## Components
|
69
|
+
|
70
|
+
The most prominent layer of styling, the components in `src/nationalarchives/components` should use the tools already defined.
|
71
|
+
|
72
|
+
Components shouldn't use variables directly. They shouldn't use static values for colour unless the colour of that component will never change, for example the message component which is always yellow.
|
73
|
+
|
74
|
+
Some components may use utilities such as headings. Where these styles have already been defined, they should not be redefined. The heading in a cookie banner should use the existing `tna-heading` and `tna-heading--m` styles that already exist rather than implimenting its own.
|
75
|
+
|
76
|
+
Components should not implement any `!important` rules. There are exceptions such as the skip link that needs to be visually hidden in a way that it is still available for someone navigating a site with a keyboard.
|
77
|
+
|
78
|
+
Components should not care about the context or layout within which they are used. As an example, a breadcrumb *could* be placed within a card or a footer element although in reality we wouldn't allow this.
|
79
|
+
|
80
|
+
## Overrides
|
81
|
+
|
82
|
+
Overrides start with `tna-!--` and can only be used in HTML classes. They have `!important` rules.
|
83
|
+
|
84
|
+
Examples of overrides are:
|
85
|
+
|
86
|
+
- Spacing (margin, padding etc.)
|
87
|
+
- No focus style (`.tna-!--no-focus-style`) for items such as the target element of a skip link
|
88
|
+
- Visibly hidden content (used to add extra descriptions which appear for screenreaders only)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Meta } from "@storybook/blocks";
|
2
|
+
|
3
|
+
<Meta title="Development/Using/Compiled" />
|
4
|
+
|
5
|
+
# Using the compiled files
|
6
|
+
|
7
|
+
Each release (as of `v0.1.21-prerelease`) should contain a ZIP of the package.
|
8
|
+
|
9
|
+
Find the release you want on the `tna-frontend` [releases page](https://github.com/nationalarchives/tna-frontend/releases) and download the package from the "Assets" dropdown.
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import { Meta } from "@storybook/blocks";
|
2
|
+
|
3
|
+
<Meta title="Development/Using/Hosted" />
|
4
|
+
|
5
|
+
# Using with a hosted solution
|
6
|
+
|
7
|
+
The `@nationalarchives/frontend` package is available on [jsdelivr.com](https://www.jsdelivr.com/package/npm/@nationalarchives/frontend).
|
8
|
+
|
9
|
+
While you can use the CSS and JavaScript from there, the font files which includes the icon font will have to be hosted from your web application.
|
10
|
+
|
11
|
+
As a result, **using a hosted solution is not the preferred method for using the `tna-frontend` library**.
|
12
|
+
|
13
|
+
## All components and styles
|
14
|
+
|
15
|
+
Include the CSS in the `<head>` element of your page:
|
16
|
+
|
17
|
+
```html
|
18
|
+
<link href="https://cdn.jsdelivr.net/npm/@nationalarchives/frontend@0.1.18-prerelease/nationalarchives/all.css" rel="stylesheet" integrity="sha384-6Egfw6aX1Jrwuf+APn+BMPswroudkIQ6StU095OPkNCKLEzj7ksWGmYxjend8P7g" crossorigin="anonymous">
|
19
|
+
```
|
20
|
+
|
21
|
+
### JavaScript
|
22
|
+
|
23
|
+
Add the JavaScript to the end of your page just before your closing `</body>` tag:
|
24
|
+
|
25
|
+
```html
|
26
|
+
<script src="https://cdn.jsdelivr.net/npm/@nationalarchives/frontend@0.1.18-prerelease/nationalarchives/all.js" integrity="sha384-sBkiMlxl9svXopGxNSMVAdALjzyvh6sQHp+21PE3LGfTxAEbG4EIpK" crossorigin="anonymous"></script>
|
27
|
+
<script>
|
28
|
+
// Initialise all TNA components
|
29
|
+
window.TNAFrontend.initAll();
|
30
|
+
</script>
|
31
|
+
```
|
32
|
+
|
33
|
+
...or use the module syntax:
|
34
|
+
|
35
|
+
```
|
36
|
+
<script type="module">
|
37
|
+
import { initAll } from "https://cdn.jsdelivr.net/npm/@nationalarchives/frontend@0.1.18-prerelease/nationalarchives/all.js";
|
38
|
+
initAll();
|
39
|
+
</script>
|
40
|
+
```
|
41
|
+
|
42
|
+
## Specific components
|
43
|
+
|
44
|
+
```html
|
45
|
+
<link href="https://cdn.jsdelivr.net/npm/@nationalarchives/frontend@0.1.18-prerelease/nationalarchives/components/tabs.css" rel="stylesheet" integrity="sha384-hkx4svJn1A7pWYlzaDRMmtIBBijZdEop+M1Y/H4Hdg8aAqZRJHG56RokLk/eqJYl" crossorigin="anonymous">
|
46
|
+
```
|
47
|
+
|
48
|
+
### JavaScript
|
49
|
+
|
50
|
+
```html
|
51
|
+
<!-- JavaScript for a single component -->
|
52
|
+
<script src="https://cdn.jsdelivr.net/npm/@nationalarchives/frontend@0.1.18-prerelease/nationalarchives/components/tabs.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
53
|
+
```
|
@@ -0,0 +1,59 @@
|
|
1
|
+
import { Meta } from "@storybook/blocks";
|
2
|
+
|
3
|
+
<Meta title="Development/Using/NPM" />
|
4
|
+
|
5
|
+
# Using with npm
|
6
|
+
|
7
|
+
Install the frontend package from NPM with:
|
8
|
+
|
9
|
+
```sh
|
10
|
+
npm install @nationalarchives/frontend
|
11
|
+
```
|
12
|
+
|
13
|
+
## CSS
|
14
|
+
|
15
|
+
From here, you have access to include the SCSS files from the package so you can compile the package yourself:
|
16
|
+
|
17
|
+
```css
|
18
|
+
// OPTIONAL: Override any variables
|
19
|
+
@use "node_modules/@nationalarchives/frontend/nationalarchives/variables/assets" with (
|
20
|
+
$tna-font-path: "/MY_CUSTOM_FONTS_PATH",
|
21
|
+
$fa-font-path: "/MY_CUSTOM_FONT_AWESOME_PATH"
|
22
|
+
);
|
23
|
+
@use "node_modules/@nationalarchives/frontend/nationalarchives/variables/grid" with (
|
24
|
+
$largest-container-width: 1337px
|
25
|
+
);
|
26
|
+
@use "node_modules/@nationalarchives/frontend/nationalarchives/variables/typography" with (
|
27
|
+
$body-font-size-px: 17
|
28
|
+
);
|
29
|
+
|
30
|
+
// Include all the styles
|
31
|
+
@use "node_modules/@nationalarchives/frontend/nationalarchives/all";
|
32
|
+
|
33
|
+
// ...or just include a single component
|
34
|
+
@use "node_modules/@nationalarchives/frontend/nationalarchives/components/tabs";
|
35
|
+
```
|
36
|
+
|
37
|
+
...or you can copy any of the compiled CSS files into your distribution:
|
38
|
+
|
39
|
+
- `node_modules/@nationalarchives/frontend/nationalarchives/all.css`
|
40
|
+
- `node_modules/@nationalarchives/frontend/nationalarchives/all.css.map`
|
41
|
+
- `node_modules/@nationalarchives/frontend/nationalarchives/components/tabs.css`
|
42
|
+
- `node_modules/@nationalarchives/frontend/nationalarchives/components/tabs.css.map`
|
43
|
+
|
44
|
+
## JavaScript
|
45
|
+
|
46
|
+
```JavaScript
|
47
|
+
// Import all the JavaScript
|
48
|
+
import "node_modules/@nationalarchives/frontend/nationalarchives/all.mjs";
|
49
|
+
|
50
|
+
// ...or import just the JavaScript for a single component
|
51
|
+
import "node_modules/@nationalarchives/frontend/nationalarchives/components/tabs/tabs.mjs";
|
52
|
+
```
|
53
|
+
|
54
|
+
...or you can copy any of the compiled JavaScript files into your distribution:
|
55
|
+
|
56
|
+
- `node_modules/@nationalarchives/frontend/nationalarchives/all.js`
|
57
|
+
- `node_modules/@nationalarchives/frontend/nationalarchives/all.js.map`
|
58
|
+
- `node_modules/@nationalarchives/frontend/nationalarchives/components/tabs.js`
|
59
|
+
- `node_modules/@nationalarchives/frontend/nationalarchives/components/tabs.js.map`
|