-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update release workflow * Update documentation * Update CHANGELOG.md
- Loading branch information
Showing
10 changed files
with
180 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
src/nationalarchives/stories/development/relationships.mdx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import { Meta } from "@storybook/blocks"; | ||
|
||
<Meta title="Development/Structure" /> | ||
|
||
# Structure | ||
|
||
The layers of the TNA frontend SCSS library is built as: | ||
|
||
1. [Variables](#variables) | ||
1. [Tools](#tools) | ||
1. [Libraries](#libraries)/[Utilities](#utilities) | ||
1. [Components](#components) | ||
1. [Overrides](#overrides) | ||
|
||
## Variables | ||
|
||
TNA frontend variables are defined in `src/nationalarchives/variables`. | ||
|
||
Lots of variables can be modified but some are fixed, such as our brand colours. | ||
|
||
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: | ||
|
||
| Pixels | REM | | ||
| ------ | ----------- | | ||
| `1px` | `0.0625rem` | | ||
| `2px` | `0.125rem` | | ||
| `4px` | `0.25rem` | | ||
| `8px` | `0.5rem` | | ||
| `16px` | `1rem` | | ||
| `32px` | `2rem` | | ||
| `64px` | `4rem` | | ||
|
||
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. | ||
|
||
## Tools | ||
|
||
The tools provided are reusable `@mixin` and `@function` blocks to make writing styles easier. They are defined in `src/nationalarchives/tools`. | ||
|
||
Tools rely directly on variables and can be used throughout the frontend library. | ||
|
||
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. | ||
|
||
## Libraries | ||
|
||
The libraries in `src/nationalarchives/lib` are a mix of third party libraries as well as some TNA ones. | ||
|
||
They can join up tools to make larger, more useful elements. | ||
|
||
## Utilities | ||
|
||
The utilities in `src/nationalarchives/utilities` are some global styles that aren't associated with a specific component. | ||
|
||
This layer is where we define some general purpose elements such as: | ||
|
||
- The `tna-template` and `tna-template__body` elements | ||
- Headings | ||
- Lists | ||
- Chips | ||
- `<p>` elements | ||
- General media elements like `<img>`, `<svg>`, `<picture>`, `<video>` and `<canvas>` | ||
- Columns | ||
- General form elements | ||
|
||
These elements all still adhere to the [BEM methodology](https://getbem.com/). | ||
|
||
Utilities should not implement any `!important` rules. | ||
|
||
## Components | ||
|
||
The most prominent layer of styling, the components in `src/nationalarchives/components` should use the tools already defined. | ||
|
||
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. | ||
|
||
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. | ||
|
||
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. | ||
|
||
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. | ||
|
||
## Overrides | ||
|
||
Overrides start with `tna-!--` and can only be used in HTML classes. They have `!important` rules. | ||
|
||
Examples of overrides are: | ||
|
||
- Spacing (margin, padding etc.) | ||
- No focus style (`.tna-!--no-focus-style`) for items such as the target element of a skip link | ||
- Visibly hidden content (used to add extra descriptions which appear for screenreaders only) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Meta } from "@storybook/blocks"; | ||
|
||
<Meta title="Development/Using/Compiled" /> | ||
|
||
# Using the compiled files | ||
|
||
Each release (as of `v0.1.21-prerelease`) should contain a ZIP of the package. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Meta } from "@storybook/blocks"; | ||
|
||
<Meta title="Development/Using/Hosted" /> | ||
|
||
# Using with a hosted solution | ||
|
||
The `@nationalarchives/frontend` package is available on [jsdelivr.com](https://www.jsdelivr.com/package/npm/@nationalarchives/frontend). | ||
|
||
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. | ||
|
||
As a result, **using a hosted solution is not the preferred method for using the `tna-frontend` library**. | ||
|
||
## All components and styles | ||
|
||
Include the CSS in the `<head>` element of your page: | ||
|
||
```html | ||
<link href="https://cdn.jsdelivr.net/npm/@nationalarchives/[email protected]/nationalarchives/all.css" rel="stylesheet" integrity="sha384-6Egfw6aX1Jrwuf+APn+BMPswroudkIQ6StU095OPkNCKLEzj7ksWGmYxjend8P7g" crossorigin="anonymous"> | ||
``` | ||
|
||
### JavaScript | ||
|
||
Add the JavaScript to the end of your page just before your closing `</body>` tag: | ||
|
||
```html | ||
<script src="https://cdn.jsdelivr.net/npm/@nationalarchives/[email protected]/nationalarchives/all.js" integrity="sha384-sBkiMlxl9svXopGxNSMVAdALjzyvh6sQHp+21PE3LGfTxAEbG4EIpK" crossorigin="anonymous"></script> | ||
<script> | ||
// Initialise all TNA components | ||
window.TNAFrontend.initAll(); | ||
</script> | ||
``` | ||
|
||
...or use the module syntax: | ||
|
||
``` | ||
<script type="module"> | ||
import { initAll } from "https://cdn.jsdelivr.net/npm/@nationalarchives/[email protected]/nationalarchives/all.js"; | ||
initAll(); | ||
</script> | ||
``` | ||
|
||
## Specific components | ||
|
||
```html | ||
<link href="https://cdn.jsdelivr.net/npm/@nationalarchives/[email protected]/nationalarchives/components/tabs.css" rel="stylesheet" integrity="sha384-hkx4svJn1A7pWYlzaDRMmtIBBijZdEop+M1Y/H4Hdg8aAqZRJHG56RokLk/eqJYl" crossorigin="anonymous"> | ||
``` | ||
|
||
### JavaScript | ||
|
||
```html | ||
<!-- JavaScript for a single component --> | ||
<script src="https://cdn.jsdelivr.net/npm/@nationalarchives/[email protected]/nationalarchives/components/tabs.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import { Meta } from "@storybook/blocks"; | ||
|
||
<Meta title="Development/Using" /> | ||
<Meta title="Development/Using/NPM" /> | ||
|
||
# Using the styles | ||
|
||
## NPM | ||
# Using with npm | ||
|
||
Install the frontend package from NPM with: | ||
|
||
```sh | ||
npm install @nationalarchives/frontend | ||
``` | ||
|
||
### CSS | ||
## CSS | ||
|
||
From here, you have access to include the SCSS files from the package so you can compile the package yourself: | ||
|
||
|
@@ -43,7 +41,7 @@ From here, you have access to include the SCSS files from the package so you can | |
- `node_modules/@nationalarchives/frontend/nationalarchives/components/tabs.css` | ||
- `node_modules/@nationalarchives/frontend/nationalarchives/components/tabs.css.map` | ||
|
||
### JavaScript | ||
## JavaScript | ||
|
||
```JavaScript | ||
// Import all the JavaScript | ||
|
@@ -59,29 +57,3 @@ import "node_modules/@nationalarchives/frontend/nationalarchives/components/tabs | |
- `node_modules/@nationalarchives/frontend/nationalarchives/all.js.map` | ||
- `node_modules/@nationalarchives/frontend/nationalarchives/components/tabs.js` | ||
- `node_modules/@nationalarchives/frontend/nationalarchives/components/tabs.js.map` | ||
|
||
## Hosted | ||
|
||
### CSS | ||
|
||
Include the CSS in the `<head>` element of your page: | ||
|
||
```html | ||
<!-- All styles --> | ||
<link href="https://cdn.jsdelivr.net/npm/@nationalarchives/[email protected]/nationalarchives/all.css" rel="stylesheet" integrity="sha384-6Egfw6aX1Jrwuf+APn+BMPswroudkIQ6StU095OPkNCKLEzj7ksWGmYxjend8P7g" crossorigin="anonymous"> | ||
|
||
<!-- Styles for a single component --> | ||
<link href="https://cdn.jsdelivr.net/npm/@nationalarchives/[email protected]/nationalarchives/components/tabs.css" rel="stylesheet" integrity="sha384-hkx4svJn1A7pWYlzaDRMmtIBBijZdEop+M1Y/H4Hdg8aAqZRJHG56RokLk/eqJYl" crossorigin="anonymous"> | ||
``` | ||
|
||
### JavaScript | ||
|
||
Add the JavaScript to the end of your page just before your closing `</body>` tag: | ||
|
||
```html | ||
<!-- All JavaScript --> | ||
<script src="https://cdn.jsdelivr.net/npm/@nationalarchives/[email protected]/nationalarchives/all.js" integrity="sha384-sBkiMlxl9svXopGxNSMVAdALjzyvh6sQHp+21PE3LGfTxAEbG4EIpK" crossorigin="anonymous"></script> | ||
|
||
<!-- JavaScript for a single component --> | ||
<script src="https://cdn.jsdelivr.net/npm/@nationalarchives/[email protected]/nationalarchives/components/tabs.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | ||
``` |