@communitiesuk/svelte-component-library 0.1.17 → 0.1.18
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
CHANGED
|
@@ -1,58 +1,40 @@
|
|
|
1
|
-
#
|
|
1
|
+
# MHCLG Svelte Component Library
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A comprehensive component library for government digital services, built with Svelte 5 and following GOV.UK Design System principles.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Prerequisites
|
|
6
6
|
|
|
7
|
-
|
|
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".
|
|
7
|
+
This component library is designed for use with:
|
|
19
8
|
|
|
20
|
-
|
|
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.
|
|
9
|
+
- **SvelteKit projects** - The components are built for SvelteKit applications
|
|
23
10
|
|
|
24
|
-
|
|
11
|
+
- **Svelte 5** - Components use the latest Svelte 5 syntax and runes
|
|
25
12
|
|
|
26
|
-
|
|
13
|
+
## Documentation and Examples
|
|
27
14
|
|
|
28
|
-
|
|
15
|
+
Visit our [component library documentation](https://communitiesuk.github.io/mhclg_svelte_component_library/) for:
|
|
29
16
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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.
|
|
17
|
+
- Interactive component examples
|
|
18
|
+
- API documentation
|
|
19
|
+
- Usage patterns and best practices
|
|
20
|
+
- Installation guides
|
|
35
21
|
|
|
36
|
-
|
|
37
|
-
> Password: TOKEN
|
|
22
|
+
## Quick Start Installation
|
|
38
23
|
|
|
39
|
-
|
|
24
|
+
The package is publicly available on npm:
|
|
40
25
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
26
|
+
```bash
|
|
27
|
+
npm install @communitiesuk/svelte-component-library@latest
|
|
28
|
+
```
|
|
44
29
|
|
|
45
|
-
|
|
30
|
+
## Usage
|
|
46
31
|
|
|
47
|
-
|
|
48
|
-
import { InternalHeader, NotificationBanner, WarningText, SearchAutocomplete, Accordion} from "@communitiesuk/svelte-component-library";
|
|
49
|
-
```
|
|
32
|
+
### GOV.UK Frontend Styles
|
|
50
33
|
|
|
51
|
-
|
|
34
|
+
To ensure GOV.UK styles are applied correctly, add this script tag to your `app.html` file in the body section:
|
|
52
35
|
|
|
53
|
-
|
|
36
|
+
```html
|
|
54
37
|
|
|
55
|
-
```javascript
|
|
56
38
|
<script>
|
|
57
39
|
document.body.className +=
|
|
58
40
|
" js-enabled" +
|
|
@@ -61,9 +43,26 @@ See the documentation app for examples of how to use the imported components.
|
|
|
61
43
|
: "");
|
|
62
44
|
</script>
|
|
63
45
|
```
|
|
46
|
+
|
|
47
|
+
This is required because the GOV.UK Frontend CSS checks the document body for JavaScript availability to progressively enhance components.
|
|
48
|
+
|
|
49
|
+
### Importing Components
|
|
50
|
+
|
|
51
|
+
Import components directly from the package:
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
import {
|
|
55
|
+
InternalHeader,
|
|
56
|
+
NotificationBanner,
|
|
57
|
+
WarningText,
|
|
58
|
+
SearchAutocomplete,
|
|
59
|
+
Accordion,
|
|
60
|
+
} from "@communitiesuk/svelte-component-library";
|
|
61
|
+
```
|
|
62
|
+
|
|
64
63
|
# Releasing a new version of the Svelte Component Library
|
|
65
64
|
|
|
66
|
-
This guide outlines the steps to bump the version of your package, tag the release in Git, and
|
|
65
|
+
This guide outlines the steps to bump the version of your package, tag the release in Git, and publish to npm.
|
|
67
66
|
|
|
68
67
|
## 1. Commit Your Changes
|
|
69
68
|
|
|
@@ -80,75 +79,80 @@ Make sure you are on your main development branch you want to release (e.g., `ma
|
|
|
80
79
|
|
|
81
80
|
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
81
|
|
|
83
|
-
|
|
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
|
-
```
|
|
82
|
+
- **Patch Release (Bug fixes, tiny changes - e.g., 1.0.0 → 1.0.1):**
|
|
99
83
|
|
|
100
|
-
|
|
84
|
+
```bash
|
|
85
|
+
npm version patch
|
|
86
|
+
```
|
|
101
87
|
|
|
102
|
-
|
|
88
|
+
- **Minor Release (New features, backwards compatible - e.g., 1.0.0 → 1.1.0):**
|
|
103
89
|
|
|
104
|
-
```bash
|
|
105
|
-
|
|
106
|
-
```
|
|
90
|
+
```bash
|
|
91
|
+
npm version minor
|
|
92
|
+
```
|
|
107
93
|
|
|
108
|
-
|
|
109
|
-
|
|
94
|
+
- **Major Release (Breaking changes - e.g., 1.0.0 → 2.0.0):**
|
|
95
|
+
```bash
|
|
96
|
+
npm version major
|
|
97
|
+
```
|
|
110
98
|
|
|
111
|
-
|
|
99
|
+
This command will:
|
|
112
100
|
|
|
113
|
-
|
|
101
|
+
- Update the version number in `package.json` and `package-lock.json`
|
|
102
|
+
- Create a new commit with the version bump
|
|
103
|
+
- Create a Git tag with the new version number
|
|
114
104
|
|
|
115
|
-
|
|
105
|
+
## 3. Push Changes and Tags
|
|
116
106
|
|
|
117
|
-
|
|
107
|
+
Push the commit and the new tag created by `npm version` to the remote Git repository (e.g., GitHub):
|
|
118
108
|
|
|
119
|
-
|
|
109
|
+
```bash
|
|
110
|
+
git push && git push --tags
|
|
111
|
+
```
|
|
120
112
|
|
|
121
|
-
|
|
113
|
+
- `git push`: Pushes the version commit.
|
|
114
|
+
- `git push --tags`: Pushes the newly created version tag.
|
|
122
115
|
|
|
123
|
-
|
|
116
|
+
## 4. Create a GitHub Release
|
|
124
117
|
|
|
125
|
-
|
|
118
|
+
1. Go to the GitHub repository
|
|
119
|
+
2. Click on "Releases" in the right sidebar
|
|
120
|
+
3. Click "Create a new release"
|
|
121
|
+
4. Select the tag you just created (e.g., `v1.0.1`)
|
|
122
|
+
5. Add a release title and description
|
|
123
|
+
6. Click "Publish release"
|
|
126
124
|
|
|
127
|
-
|
|
125
|
+
## 5. Automatic Publishing
|
|
128
126
|
|
|
129
|
-
If you now go to the "Actions" tab in the repo's horizontal nav bar, you'll see the publish workflow being triggered.
|
|
127
|
+
Once you create the GitHub release, If you now go to the "Actions" tab in the repo's horizontal nav bar, you'll see the publish workflow being triggered. The GitHub Actions workflow (`.github/workflows/npm-publish.yml`) will automatically:
|
|
130
128
|
|
|
131
|
-
|
|
129
|
+
- Build the package
|
|
130
|
+
- Publish it to npm public registry
|
|
131
|
+
- Make it available for installation via `npm install @communitiesuk/svelte-component-library`
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
## 6. Verify the Release
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
After the GitHub Action completes, verify that your package was published successfully:
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
1. Check the [npm package page](https://www.npmjs.com/package/@communitiesuk/svelte-component-library)
|
|
138
|
+
2. Try installing the new version in a test project:
|
|
139
|
+
```bash
|
|
140
|
+
npm install @communitiesuk/svelte-component-library@latest
|
|
141
|
+
```
|
|
138
142
|
|
|
139
|
-
|
|
143
|
+
## Notes
|
|
140
144
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
145
|
+
- Only create releases from the "main" branch to ensure stability
|
|
146
|
+
- Always test changes thoroughly before creating a release
|
|
147
|
+
- Consider creating pre-release versions for testing: `npm version prerelease --preid=alpha`
|
|
144
148
|
|
|
145
|
-
#
|
|
146
|
-
|
|
147
|
-
|
|
149
|
+
# Developing and Building Commands
|
|
150
|
+
|
|
151
|
+
This project is built with [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte). Read more about creating a library [in the docs](https://svelte.dev/docs/kit/packaging).
|
|
148
152
|
|
|
149
153
|
## Developing
|
|
150
154
|
|
|
151
|
-
|
|
155
|
+
Start a development server:
|
|
152
156
|
|
|
153
157
|
```bash
|
|
154
158
|
npm run dev
|
|
@@ -176,13 +180,3 @@ npm run build
|
|
|
176
180
|
You can preview the production build with `npm run preview`.
|
|
177
181
|
|
|
178
182
|
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
|
|
179
|
-
|
|
180
|
-
## Publishing
|
|
181
|
-
|
|
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/)).
|
|
183
|
-
|
|
184
|
-
To publish your library to [npm](https://www.npmjs.com):
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
npm publish
|
|
188
|
-
```
|