Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 43d999d

Browse files
authored
docs: remove Link component usage (#221)
1 parent 62cee01 commit 43d999d

File tree

8 files changed

+33
-35
lines changed

8 files changed

+33
-35
lines changed

.storybook/preview.jsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* eslint-disable import/no-webpack-loader-syntax */
33
import React, { useEffect } from 'react';
44
import { DocsContainer } from '@storybook/addon-docs';
5+
import { Link } from '../storybook/stories/components/Link';
56
// import cssVariablesTheme from '@etchteam/storybook-addon-css-variables-theme'
67

78
// import hseTheme from '!!style-loader?injectType=lazyStyleTag!css-loader!./assets/themes/hse.css';
@@ -54,11 +55,7 @@ export const parameters = {
5455
return <DocsContainer context={context}>{children}</DocsContainer>;
5556
},
5657
components: {
57-
a: ({ children, ...args }) => (
58-
<a className="govie-link" {...args}>
59-
{children}
60-
</a>
61-
),
58+
a: ({ children, ...args }) => <Link {...args}>{children}</Link>,
6259
p: ({ children, ...args }) => (
6360
<p className="govie-body" {...args}>
6461
{children}

storybook/stories/api-reference/javascript-api-reference.mdx

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { Canvas, Meta } from '@storybook/blocks';
2-
import { Link } from '../components/Link.jsx';
32

43
<Meta title="Docs/JavaScript API Reference" />
54

65
# JavaScript API Reference
76

8-
Some of our components can receive configuration options when you create an instance in JavaScript. This page lists the available options for these components. You can find further information on how to <Link href='?path=/docs/docs-configure-components-with-javascript--docs'>configure these options in our guidance</Link>.
7+
Some of our components can receive configuration options when you create an instance in JavaScript. This page lists the available options for these components. You can find further information on how to [configure these options in our guidance](?path=/docs/docs-configure-components-with-javascript--docs).
98

109
You can pass these options in an object either as:
1110

@@ -164,7 +163,7 @@ Default: see properties
164163

165164
Type: `object`
166165

167-
Message displayed when the number of characters is under the configured maximum, `maxlength`. This message is displayed visually and through assistive technologies. The component will replace the `{'%{count}'}` placeholder with the number of remaining characters. This is a <Link href='?path=/story/docs-localise-ogcio-ds--docs#pluralisation-rules'>pluralised list of messages</Link>.
166+
Message displayed when the number of characters is under the configured maximum, `maxlength`. This message is displayed visually and through assistive technologies. The component will replace the `{'%{count}'}` placeholder with the number of remaining characters. This is a [pluralised list of messages](?path=/story/docs-localise-ogcio-ds--docs#pluralisation-rules).
168167

169168
Default:
170169

@@ -191,7 +190,7 @@ You have 0 characters remaining
191190

192191
Type: `object`
193192

194-
Message displayed when the number of characters is over the configured maximum, `maxlength`. This message is displayed visually and through assistive technologies. The component will replace the `{'%{count}'}` placeholder with the number of remaining characters. This is a <Link href='?path=/story/docs-localise-ogcio-ds--docs#pluralisation-rules'>pluralised list of messages</Link>.
193+
Message displayed when the number of characters is over the configured maximum, `maxlength`. This message is displayed visually and through assistive technologies. The component will replace the `{'%{count}'}` placeholder with the number of remaining characters. This is a [pluralised list of messages](?path=/story/docs-localise-ogcio-ds--docs#pluralisation-rules).
195194

196195
Default:
197196

@@ -207,7 +206,7 @@ Default:
207206
Type: `object`
208207

209208
Message displayed when the number of words is under the configured maximum, `maxwords`. This message is displayed visually and through assistive technologies. The component will replace the `{'%{count}'}` placeholder
210-
with the number of remaining words. This is a <Link href='?path=/story/docs-localise-ogcio-ds--docs#pluralisation-rules'>pluralised list of messages</Link>
209+
with the number of remaining words. This is a [pluralised list of messages](?path=/story/docs-localise-ogcio-ds--docs#pluralisation-rules)
211210

212211
Default:
213212

@@ -234,7 +233,7 @@ You have 0 words remaining
234233

235234
Type: `object`
236235

237-
Message displayed when the number of words is over the configured maximum, `maxwords`. This message is displayed visually and through assistive technologies. The component will replace the `{'%{count}'}` placeholder with the number of remaining words. This is a <Link href='?path=/story/docs-localise-ogcio-ds--docs#pluralisation-rules'>pluralised list of messages</Link>.
236+
Message displayed when the number of words is over the configured maximum, `maxwords`. This message is displayed visually and through assistive technologies. The component will replace the `{'%{count}'}` placeholder with the number of remaining words. This is a [pluralised list of messages](?path=/story/docs-localise-ogcio-ds--docs#pluralisation-rules).
238237

239238
Default:
240239

storybook/stories/components/Link.jsx

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
import packageJson from '../../../package.json';
22
import React from 'react';
33

4-
export const Link = ({ children, href }) => (
5-
<a className="govie-link" href={`${import.meta.env.BASE_URL}${href}`}>
6-
{children}
7-
</a>
8-
);
4+
export const Link = ({ children, href }) => {
5+
const url = href.startsWith('https://')
6+
? href
7+
: `${import.meta.env.BASE_URL}${href}`;
8+
9+
return (
10+
<a className="govie-link" href={url}>
11+
{children}
12+
</a>
13+
);
14+
};
915

1016
export const ReleaseLink = ({ children }) => {
1117
const version = packageJson.version;

storybook/stories/get-started/configure-components-javascript.mdx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Canvas, Meta } from '@storybook/blocks';
2-
import { Link } from '../components/Link.jsx';
32

43
<Meta title="Docs/Configure components with JavaScript" />
54

@@ -41,7 +40,7 @@ If your configuration contains [quotes or other reserved HTML characters](https:
4140

4241
Configuration is read from data attributes when the component is initialised. Changes to the data attributes made after the component has been initialised will have no effect on the behaviour of the component.
4342

44-
Read the <Link href='?path=/docs/docs-javascript-api-reference--docs'>JavaScript API Reference</Link> for the configuration accepted by each component. You'll need to convert the configuration names into kebab-case.
43+
Read the [JavaScript API Reference](?path=/docs/docs-javascript-api-reference--docs) for the configuration accepted by each component. You'll need to convert the configuration names into kebab-case.
4544

4645
## Passing configuration to a new instance of a component in JavaScript
4746

@@ -73,7 +72,7 @@ new CharacterCount($element, {
7372
}).init();
7473
```
7574

76-
Read the <Link href='?path=/docs/docs-javascript-api-reference--docs'>JavaScript API Reference</Link> to see what configuration each component accepts.
75+
Read the [JavaScript API Reference](?path=/docs/docs-javascript-api-reference--docs) to see what configuration each component accepts.
7776

7877
## Passing configuration using the initAll function
7978

storybook/stories/get-started/get-started.mdx

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Canvas, Meta } from '@storybook/blocks';
2-
import { Link } from '../components/Link.jsx';
32

43
<Meta title="Docs/Get started" />
54

@@ -17,13 +16,13 @@ You will need to do all the following steps to get your component working.
1716

1817
## 1. Install Gov IE Frontend package
1918

20-
- You can <Link href="?path=/docs/docs-install-with-npm--docs">install Gov IE Frontend using npm</Link>.
19+
- You can [install Gov IE Frontend using npm](?path=/docs/docs-install-and-update-with-npm--docs).
2120

22-
- If you've <Link href='?path=/story/docs-install-using-precompiled-files--docs'>installed using precompiled files</Link>, get started with a <Link href='?path=/story/docs-install-using-precompiled-files--docs#basic-example-page'>a basic page instead</Link>.
21+
- If you've [installed using precompiled files](?path=/story/docs-install-using-precompiled-files--docs), get started with [a basic page instead](?path=/story/docs-install-using-precompiled-files--docs#basic-example-page).
2322

2423
## 2. Add the HTML for a component to your application
2524

26-
- Go to the <Link href='?path=/docs/typography-accordion--default'>example accordion component</Link>.
25+
- Go to the [example accordion component](?path=/docs/typography-accordion--default).
2726

2827
- Paste the HTML into a page or template in your application.
2928

@@ -48,7 +47,7 @@ Run your application and check that the accordion displays correctly.
4847

4948
The accordion will use a generic font until you get the font and images working, and will not be interactive until you get the JavaScript working.
5049

51-
There are also different ways you can <Link href='?path=/docs/docs-import-css-assets-and-javascript--docs'>import Gov IE Frontend CSS</Link>.
50+
There are also different ways you can [import Gov IE Frontend CSS](?path=/docs/docs-import-css-assets-and-javascript--docs).
5251

5352
## 4. Get the font and images working
5453

@@ -61,7 +60,7 @@ Your component will not use the right font or images until you've added Gov IE F
6160

6261
Run your application, then use [the Fonts tab in Firefox Page Inspector](https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Edit_fonts#The_Fonts_tab) to check the accordion is using the Lato font.
6362

64-
In your live application, we recommend <Link href='?path=/docs/docs-import-css-assets-and-javascript--docs#fonts-and-images-assets'>using an automated task or your build pipeline</Link> instead of copying the files manually.
63+
In your live application, we recommend [using an automated task or your build pipeline](?path=/docs/docs-import-css-assets-and-javascript--docs#fonts-and-images-assets) instead of copying the files manually.
6564

6665
## 5. Get the JavaScript working
6766

@@ -94,6 +93,6 @@ In your live application:
9493

9594
- You must use `initAll` to initialise all components that use Gov IE Frontend JavaScript, or some components will not work correctly for disabled users who use assistive technologies
9695

97-
We recommend <Link href='?path=/docs/docs-import-css-assets-and-javascript--docs#import-javascript'>using an automated task or your build pipeline</Link> instead of copying the files manually
96+
We recommend [using an automated task or your build pipeline](?path=/docs/docs-import-css-assets-and-javascript--docs#import-javascript) instead of copying the files manually
9897

9998
You can now get the full code for page layouts and other components from this website.

storybook/stories/get-started/install-with-files.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You can install Gov IE Frontend by copying our CSS, JavaScript and asset files i
1313

1414
You'll not be able to:
1515

16-
- Change <Link href='?path=/story/docs-sass-api-reference--docs'>Sass settings</Link>, for example override colours or set your own font
16+
- Change [Sass settings](?path=/story/docs-sass-api-reference--docs), for example override colours or set your own font
1717
- Import an individual component's CSS or JavaScript
1818
- Use Gov IE Frontend colours or mixins in your custom code
1919

@@ -26,7 +26,7 @@ You'll not be able to:
2626

2727
## Check an example page
2828

29-
1. Create a page in your project using the following HTML (in your live application, you should use the <Link href='?path=/docs/templates-basic-page--default'>Design System basic page template</Link> instead):
29+
1. Create a page in your project using the following HTML (in your live application, you should use the [Design System basic page template](?path=/docs/templates-basic-page--default) instead):
3030

3131
```html
3232
<!doctype html>
@@ -58,6 +58,6 @@ You'll not be able to:
5858
```
5959

6060
2. Replace `<VERSION-NUMBER>` so the 3 filenames match the files you copied from Gov IE Frontend GitHub repo.
61-
3. Go to the <Link href='?path=/docs/typography-accordion--default'>example accordion component</Link> on the Design System website and copy the HTML from the first example.
61+
3. Go to the [example accordion component](?path=/docs/typography-accordion--default) on the Design System website and copy the HTML from the first example.
6262
4. Replace `<!-- component HTML -->` with the accordion HTML you copied.
63-
5. Run your application - you can check it works the same way as the <Link href="iframe.html?id=typography-accordion--default&viewMode=story">Design System accordion example</Link> by selecting the buttons and checking the accordion 'shows' and 'hides' sections.
63+
5. Run your application - you can check it works the same way as the [Design System accordion example](iframe.html?id=typography-accordion--default&viewMode=story) by selecting the buttons and checking the accordion 'shows' and 'hides' sections.

storybook/stories/get-started/install-with-npm.mdx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Canvas, Meta } from '@storybook/blocks';
2-
import { Link } from '../components/Link.jsx';
32

43
<Meta title="Docs/Install and update with npm" />
54

@@ -22,7 +21,7 @@ npm install @ogcio/ogcio-ds --save
2221

2322
When the installation finishes, the `@ogcio/ogcio-ds` package will be in your `node_modules` folder.
2423

25-
You should now get started by <Link href='?path=/docs/docs-get-started--docs'>getting the CSS, assets and JavaScript working</Link> with one gov.ie Frontend component.
24+
You should now get started by [getting the CSS, assets and JavaScript working](?path=/docs/docs-get-started--docs) with one gov.ie Frontend component.
2625

2726
## Update using Node.js package manager (npm)
2827

storybook/stories/get-started/localisation.mdx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Canvas, Meta } from '@storybook/blocks';
2-
import { Link } from '../components/Link.jsx';
32

43
<Meta title="Docs/Localise Gov IE Frontend" />
54

@@ -27,7 +26,7 @@ If you're using the Nunjucks macro, look at the Nunjucks macro options table in
2726

2827
If you're using the HTML directly, you can customise the text used in the JavaScript by passing configuration using data attributes.
2928

30-
Alternatively, you can <Link href='?path=/docs/docs-configure-components-with-javascript--docs'>configure the component with JavaScript</Link> at the point you initialise it or when using `initAll`.
29+
Alternatively, you can [configure the component with JavaScript](?path=/docs/docs-configure-components-with-javascript--docs) at the point you initialise it or when using `initAll`.
3130

3231
The naming conventions for:
3332

@@ -82,7 +81,7 @@ If you're looking to keep English messages and override only one of the plural f
8281

8382
Our components will replace the `{'%{count}'}` placeholder with the number used for picking the plural category.
8483

85-
The following example shows how to provide pluralisation options using the different ways you can <Link href='?path=/docs/docs-configure-components-with-javascript--docs'>configure components with JavaScript</Link>:
84+
The following example shows how to provide pluralisation options using the different ways you can [configure components with JavaScript](?path=/docs/docs-configure-components-with-javascript--docs):
8685

8786
With data attributes
8887

0 commit comments

Comments
 (0)