Skip to content

Commit 312147f

Browse files
committed
Merge branch 'main-check-merge'
2 parents 941d6ca + 989aa11 commit 312147f

File tree

405 files changed

+139568
-5851
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

405 files changed

+139568
-5851
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3+
4+
name: Node.js Package
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-node@v4
16+
with:
17+
node-version: 20
18+
- run: npm ci
19+
# - run: npm test
20+
21+
publish-gpr:
22+
needs: build
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
packages: write
27+
steps:
28+
- uses: actions/checkout@v4
29+
- uses: actions/setup-node@v4
30+
with:
31+
node-version: 20
32+
registry-url: https://npm.pkg.github.com/
33+
- run: npm ci
34+
- run: npm publish
35+
env:
36+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ Thumbs.db
2020
# Vite
2121
vite.config.js.timestamp-*
2222
vite.config.ts.timestamp-*
23+
24+
*.mdc
25+
.github/*.md

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
engine-strict=true
2+
@communitiesuk:registry=https://npm.pkg.github.com
3+
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}

README.md

Lines changed: 132 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,133 @@
1+
# Quick Start Installation
2+
3+
Because this package is currently privately published to the GitHub npm package registry, you'll need to log in to the package registry before you can install the package. To log in you'll need your GitHub username and a personal access token with the correct permissions.
4+
5+
## 1. To get your personal access token on GitHub, follow these steps:
6+
7+
1. **Log in to GitHub**: Go to your GitHub account.
8+
2. **Navigate to Developer Settings**:
9+
* Click on your profile photo in the upper-right corner of the page.
10+
* Select Settings.
11+
* In the left sidebar, click Developer settings.
12+
3. **Access Personal Access Tokens**:
13+
* Under the Personal access tokens section in the sidebar, click either Tokens (classic) or Fine-grained tokens, depending on your preference.
14+
4. **Generate a New Token**:
15+
* Click Generate new token (for classic tokens, select Generate new token (classic)).
16+
* Provide a descriptive name in the "Note" field.
17+
* Set an expiration date if needed.
18+
* Choose the required scopes or permissions for the token. For installing the package, we will need "write:packages" (Upload packages to GitHub Package Registry), "read:packages" (Download packages from GitHub Package Registry) and "repo".
19+
20+
5. **Generate and Save the Token**:
21+
* Click Generate token.
22+
* Optionally, copy the new token to your clipboard for immediate use. Make sure to save it securely, as you won’t be able to view it again.
23+
24+
## 2. Next, you will need to add the GitHub registry path to the npm config file `.npmrc` so that npm knows to look for the package we want to authenticate for within the GitHub registry rather than the npm website.
25+
26+
1. Add this line to the `.npmrc` file: `@communitiesuk:registry=https://npm.pkg.github.com`
27+
28+
## 3. Now we can log in:
29+
30+
1. Enter the following command into the terminal:
31+
```bash
32+
npm login --scope=@communitiesuk --auth-type=legacy --registry=https://npm.pkg.github.com
33+
```
34+
2. Enter your GitHub username, followed by the PAT token we obtained in the previous step as the password. When copying the token into the terminal, it may not be visible. Press the "Enter" key regardless and it should submit.
35+
36+
> Username: USERNAME
37+
> Password: TOKEN
38+
39+
More information about the GitHub npm registry can be found here: [https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry)
40+
41+
## 4. Now you are logged in, you can install the package:
42+
43+
1. Enter the npm install command for this package, using the latest version. The package should start installing.
44+
45+
To import a component from the newly installed package, you can add an import statement in the following structure to your Svelte page file:
46+
47+
```javascript
48+
import { InternalHeader, NotificationBanner, WarningText, SearchAutocomplete, Accordion} from "@communitiesuk/svelte-component-library";
49+
```
50+
51+
See the documentation app for examples of how to use the imported components.
52+
53+
2. To make sure govuk styles are applied correctly add this script tag to the app.html body tag section:
54+
55+
```javascript
56+
<script>
57+
document.body.className +=
58+
" js-enabled" +
59+
("noModule" in HTMLScriptElement.prototype
60+
? " govuk-frontend-supported"
61+
: "");
62+
</script>
63+
```
64+
# Releasing a new version of the Svelte Component Library
65+
66+
This guide outlines the steps to bump the version of your package, tag the release in Git, and push it to prepare for publishing.
67+
68+
## 1. Commit Your Changes
69+
70+
Before versioning, ensure all your code changes are committed to Git:
71+
72+
```bash
73+
git add .
74+
git commit -m "Your descriptive commit message"
75+
```
76+
77+
Make sure you are on your main development branch you want to release (e.g., `main`).
78+
79+
## 2. Bump the Package Version
80+
81+
Use the `npm version` command to update `package.json` and `package-lock.json`, create a commit, and create an annotated Git tag. Choose **one** of the following based on [Semantic Versioning (SemVer)](https://semver.org/):
82+
83+
* **Patch Release (Bug fixes, tiny changes - e.g., 0.1.8 -> 0.1.9):**
84+
```bash
85+
npm version patch
86+
```
87+
* **Minor Release (New features, backward-compatible - e.g., 0.1.8 -> 0.2.0):**
88+
```bash
89+
npm version minor
90+
```
91+
* **Major Release (Breaking changes - e.g., 0.1.8 -> 1.0.0):**
92+
```bash
93+
npm version major
94+
```
95+
* **Specific Version:**
96+
```bash
97+
npm version <new-version> # Replace <new-version> with the desired version, e.g., 1.2.3
98+
```
99+
100+
## 3. Push Changes and Tags
101+
102+
Push the commit and the new tag created by `npm version` to your remote Git repository (e.g., GitHub):
103+
104+
```bash
105+
git push && git push --tags
106+
```
107+
108+
* `git push`: Pushes the version commit.
109+
* `git push --tags`: Pushes the newly created version tag.
110+
111+
## 4. Publishing (Automatic via GitHub Actions)
112+
113+
Now the tag has been pushed, we can create a release on GitHub to trigger the GitHub Actions workflow defined in `.github/workflows/npm-publish-github-packages.yml`, which will handle the actual `npm publish` step to GitHub Packages.
114+
115+
Click on "create new release" from the repo homepage.
116+
117+
Choose the target branch that you want to release (e.g. main).
118+
119+
Choose the tag version pushed to GitHub in a previous step.
120+
121+
Click generate release notes, and add any additional write-up to describe the changes in this release.
122+
123+
Amend the release title to something appropriate, including the version number in the title.
124+
125+
Click "Set as pre-release" given the package is not stable yet.
126+
127+
Click the publish release button.
128+
129+
If you now go to the "Actions" tab in the repo's horizontal nav bar, you'll see the publish workflow being triggered. Once complete, the package will be uploaded and the new version can be installed.
130+
1131
# create-svelte
2132
3133
Everything you need to build a Svelte library, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).
@@ -49,10 +179,10 @@ You can preview the production build with `npm run preview`.
49179
50180
## Publishing
51181
52-
Go into the `package.json` and give your package the desired name through the `"name"` option. Also consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
182+
Go into the `package.json` and give your package the desired name through the `"name"` option. Also, consider adding a `"license"` field and point it to a `LICENSE` file which you can create from a template (one popular option is the [MIT license](https://opensource.org/license/mit/)).
53183
54184
To publish your library to [npm](https://www.npmjs.com):
55185
56186
```bash
57187
npm publish
58-
```
188+
```

docs/ResponsiveDesign.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Introduction
2+
3+
Plain HTML will work on any screen. Therefore, failure to display content properly on different screen sizes is generally caused by CSS.[^1]
4+
5+
[^1]:[Responsive columns without media queries](https://medium.com/@hayavuk/responsive-columns-without-media-queries-1dd92dc0f5e6)
6+
7+
# Breakpoints and media queries
8+
9+
> Breakpoints should be content-based, not device based - *Kaloyan Kosev*[^1]
10+
11+
> Start with the small screen first, then expand until it looks like s\*\*t. Time for a breakpoint! – *Stephen Hay*[^3]
12+
13+
You don't want everything to scale proportionally. On larger screens, images can become very large, forcing other content off the screen[^4].
14+
15+
It's common to use viewport width in media queries, but there are a large range of media features that can be detected (color, color index, aspect ratio, device aspect ratio, width, device width, height, device height, orientation, monochrome, resolution, scan, pixel-density, and more)[^3].
16+
17+
There are several reasons not to use device pixel dimensions as breakpoints. One is that new devices are likely to have different dimensions, making the older ones abritrary[^3].
18+
19+
Sometimes a design needs to change significantly when the available space (or other parameter) renders it unsuitable. Other times, it might only be necessary to change one aspect. This is known as a minor breakpoint or a tweakpoint [^3].
20+
21+
Developers are warned that highly complex media queries pose a danger: they can be difficult to manage long-term [^3].
22+
23+
Older advice on the internet suggests that pixel-based media queries didn't function as expected when a user zoomed in. This issue is now outdated. However, it's still recommended to use em-based media queries because they will still function when a browser's font size isn't the default 16px [^1]
24+
25+
It's recommended that lines of text aren't too short or long, ideally 45-90 characters. It's possible to achieve this with different font sizes by specifying font size and element width as a proportion of viewport width, and scaling them at the same rate [^3].
26+
27+
Progressive enhancement is...
28+
Min-width is better suited to progressive enhancement than max-width, because styles are overridden at smaller screens, not larger ones[^5]
29+
30+
[^1] [Journey to highly effective and maintainable CSS media queries](https://notes.devlabs.bg/journey-to-highly-effective-and-maintainable-css-media-queries-876e5b92f918)
31+
32+
[^2] [7 habits of highly effective media queries](https://bradfrost.com/blog/post/7-habits-of-highly-effective-media-queries/)
33+
34+
[^3] [Responsive web design](https://practicaltypography.com/responsive-web-design.html)
35+
36+
[^4] [Responsive web design](https://alistapart.com/article/responsive-web-design/)
37+
38+
[^5] [Avoiding common mistakes with CSS media queries](https://blog.pixelfreestudio.com/avoiding-common-mistakes-with-css-media-queries/)
39+
40+
# Units
41+
42+
Units are used to define the size of elements on a screen. Using appropriate units is important for ensuring designs scale properly on different screen sizes.
43+
44+
rem units are defined by the font size of the root element (16px by default).
45+
em units are defined by the font size of the parent element.
46+
47+
Font sizes should be set using rem units; values in pixels won't scale properly if the browser's font size changes. By default, 1rem = 16px, so 1.5rem = 24px.
48+
49+
Margins and padding should be set using em units.
50+
51+
When defining CSS width and height values, percentages are recommended (as a proportion of the parent element).
52+
53+
Properties that don't need to be responsive (e.g. border-width) can be set using pixels.
54+
55+
From: [Why CSS units matter to your responsive website designs](https://pieces.app/blog/css-units-responsive-website-designs)
56+
57+
See also: [whatunit.com](https://whatunit.com/)
58+
59+
# Interaction
60+
61+
Touch targets should be large enough (Apple recomends 44x44 pixels[^1]) and should be sufficient spaced apart [^2]
62+
63+
[^1] [A Hands-On Guide to Mobile-First Design](https://www.uxpin.com/studio/blog/a-hands-on-guide-to-mobile-first-design/)
64+
[^2] [Common Mobile Design Mistake on Your Website](https://conroycreativecounsel.com/avoid-these-common-mobile-design-mistakes-on-your-website/)
65+
66+
# Progressive Enhancement
67+
68+
# Common Pitfalls of Mobile-First
69+
70+
> Porting an unchanged UI to a different platform hurts UX. - *NN Group*[^3]
71+
72+
A one-size-fits-all approach might be appealing, but it's possible to focus on smaller screens *at the expense of* larger screens. Desktops are more 'robust' - they can handle more complexity.
73+
74+
This involves dailing to 'flesh out' a design for screens that can handle it [^1]. This is known as 'mobile everything'[^2] or 'mobile-only'[^3].
75+
76+
Consider a hamburger icon to find the links to toggle between views. On mobile, there might be insufficient space, but not so on desktop. Displaying these links permanently would reduce clicks from one to two [^2]. Futhermore, interactive elements like a hamburger icon might be easily noticed on a mobile screen, but overlooked on a large desktop screen [^3].
77+
78+
Other examples include hiding functionality in drawers, using icons instead of/without text, and breaking content into several screens [^2].
79+
80+
Research has found that navigation isn't used as frequently when it's hidden within a menu [^3].
81+
82+
Some argue that the importance of consistency across devices is overestimated [^1].
83+
The context is different on different devices, so the interfaces should be adapted to suit the context [^1].
84+
Input differs across devices too, so design should be modified accordingly. Phones are typically used in portrait mode, and thumbs will be able to respond to functionality near the bottom. Tablets are often used with both hands, so there's greater scope for where interactive elements are placed. Desktop users have more fine-grained control, due to using a mouse or trackpad. Desktop users might expect key functionality to be positioned towards the top of the screen [^1].
85+
86+
[^1] [Why is mobile-first design failing](https://jamesarcher.co/170/mobile-first-why-are-we-getting-it-wrong)
87+
[^3] [Mobile-first not mobile-only](https://www.nngroup.com/articles/mobile-first-not-mobile-only/)
88+
[^2] [Mobile first, desktop worst](https://blog.prototypr.io/mobile-first-desktop-worst-f900909ae9e2)

0 commit comments

Comments
 (0)