@defra/docusaurus-theme-govuk 0.0.4-alpha → 0.0.5-alpha
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
|
@@ -10,7 +10,7 @@ A Docusaurus 3 theme that applies the [GOV.UK Design System](https://design-syst
|
|
|
10
10
|
- Syntax-highlighted code blocks with copy button
|
|
11
11
|
- Admonition blocks (:::note, :::warning, etc.) rendered as GOV.UK InsetText / WarningText
|
|
12
12
|
- 404 page with GOV.UK styling
|
|
13
|
-
-
|
|
13
|
+
- GOV.UK static assets included (GDS Transport is **not** bundled — the theme uses Helvetica/Arial)
|
|
14
14
|
- Compatible with React 18 and React 19
|
|
15
15
|
|
|
16
16
|
|
|
@@ -63,6 +63,8 @@ module.exports = {
|
|
|
63
63
|
header: {
|
|
64
64
|
serviceName: 'My Service',
|
|
65
65
|
serviceHref: '/',
|
|
66
|
+
organisationText: 'My Organisation',
|
|
67
|
+
organisationHref: 'https://example.gov.uk',
|
|
66
68
|
},
|
|
67
69
|
|
|
68
70
|
navigation: [
|
|
@@ -108,6 +110,8 @@ module.exports = {
|
|
|
108
110
|
|----------|------|-------------|
|
|
109
111
|
| `serviceName` | `string` | Service name displayed in the GOV.UK header |
|
|
110
112
|
| `serviceHref` | `string` | Link for the service name (default: `/`) |
|
|
113
|
+
| `organisationText` | `string` | Organisation name displayed in the header crown block |
|
|
114
|
+
| `organisationHref` | `string` | URL the organisation name links to |
|
|
111
115
|
|
|
112
116
|
#### `themeConfig.govuk.navigation`
|
|
113
117
|
|
package/package.json
CHANGED
package/src/css/components.scss
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
border-bottom: 1px solid #b1b4b6;
|
|
30
30
|
font-size: 0.875rem;
|
|
31
31
|
font-weight: 700;
|
|
32
|
-
font-family:
|
|
32
|
+
font-family: Helvetica, Arial, sans-serif;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
.app-code-block__pre {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
overflow: auto;
|
|
39
39
|
font-size: 0.875rem;
|
|
40
40
|
line-height: 1.6;
|
|
41
|
-
font-family:
|
|
41
|
+
font-family: Menlo, Consolas, 'Courier New', monospace;
|
|
42
42
|
position: relative;
|
|
43
43
|
border: 1px solid #b1b4b6;
|
|
44
44
|
margin: 0;
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
border-radius: 0;
|
|
55
55
|
background: #f3f2f1;
|
|
56
56
|
cursor: pointer;
|
|
57
|
-
font-family:
|
|
57
|
+
font-family: Helvetica, Arial, sans-serif;
|
|
58
58
|
color: #0b0c0c;
|
|
59
59
|
|
|
60
60
|
&:hover {
|
package/src/css/theme.scss
CHANGED
|
@@ -9,10 +9,27 @@
|
|
|
9
9
|
|
|
10
10
|
/*
|
|
11
11
|
* Set the default font on the body so that ALL elements
|
|
12
|
-
* (header, footer, service-nav, etc.) inherit
|
|
12
|
+
* (header, footer, service-nav, etc.) inherit the same stack.
|
|
13
13
|
* The prose-scope only covers content inside .app-prose-scope;
|
|
14
14
|
* without this, outer chrome inherits the browser default serif.
|
|
15
|
+
* GDS Transport is not bundled — Helvetica/Arial is used instead.
|
|
15
16
|
*/
|
|
16
17
|
body {
|
|
17
|
-
font-family:
|
|
18
|
+
font-family: Helvetica, Arial, sans-serif;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
* Sticky footer: Docusaurus inserts a #__docusaurus wrapper between body
|
|
23
|
+
* and our layout, breaking GOV.UK Frontend's flex sticky-footer chain.
|
|
24
|
+
* Rather than patching the chain, own the full-height context here.
|
|
25
|
+
*/
|
|
26
|
+
.govuk-template--rebranded {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
min-height: 100vh;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.govuk-template--rebranded > .govuk-width-container {
|
|
33
|
+
flex: 1 0 auto;
|
|
34
|
+
width: 100%;
|
|
18
35
|
}
|
|
@@ -41,11 +41,28 @@ const includes = (haystack, needle) => {
|
|
|
41
41
|
export const useIsActive = () => {
|
|
42
42
|
const location = useLocation();
|
|
43
43
|
|
|
44
|
-
return (href, exact = true) => {
|
|
44
|
+
return (href, exact = true, options = {}) => {
|
|
45
45
|
const target = URI.parse(href, location.pathname);
|
|
46
46
|
const pathMatch = location.pathname === target.pathname;
|
|
47
47
|
const queryMatch = includes(location.query, target.query);
|
|
48
|
-
|
|
48
|
+
// Home link: exact match only (must match exactly, not as a prefix)
|
|
49
|
+
if (
|
|
50
|
+
target.pathname === '/' ||
|
|
51
|
+
/^\/[^/]+\/?$/.test(target.pathname) // e.g. /interactive-map or /interactive-map/
|
|
52
|
+
) {
|
|
53
|
+
// Only highlight if the current path matches the home link's pathname exactly
|
|
54
|
+
return location.pathname === target.pathname && queryMatch;
|
|
55
|
+
}
|
|
56
|
+
// Overview link: href is a prefix of current path, and next char is '/' or nothing
|
|
57
|
+
const isOverview = location.pathname.startsWith(target.pathname)
|
|
58
|
+
&& location.pathname.charAt(target.pathname.length) === '/';
|
|
59
|
+
if (isOverview) {
|
|
60
|
+
return pathMatch && queryMatch;
|
|
61
|
+
}
|
|
62
|
+
// All other links: startsWith logic
|
|
63
|
+
const dir = target.pathname.endsWith('/') ? target.pathname : target.pathname + '/';
|
|
64
|
+
const pathStart = location.pathname === target.pathname || location.pathname.startsWith(dir);
|
|
65
|
+
return pathStart && queryMatch;
|
|
49
66
|
};
|
|
50
67
|
};
|
|
51
68
|
|
|
@@ -15,15 +15,6 @@ export default function Heading({as: Tag = 'h2', id, children, ...props}) {
|
|
|
15
15
|
return (
|
|
16
16
|
<Tag id={id} className={className} {...props}>
|
|
17
17
|
{children}
|
|
18
|
-
{id && (
|
|
19
|
-
<a
|
|
20
|
-
href={`#${id}`}
|
|
21
|
-
className="govuk-link app-heading-anchor"
|
|
22
|
-
aria-label={`Direct link to ${typeof children === 'string' ? children : 'heading'}`}
|
|
23
|
-
>
|
|
24
|
-
#
|
|
25
|
-
</a>
|
|
26
|
-
)}
|
|
27
18
|
</Tag>
|
|
28
19
|
);
|
|
29
20
|
}
|
|
@@ -137,14 +137,17 @@ export default function Layout(props) {
|
|
|
137
137
|
<SkipLink for="main-content">Skip to main content</SkipLink>
|
|
138
138
|
|
|
139
139
|
<Header
|
|
140
|
-
govUK
|
|
141
140
|
rebrand
|
|
141
|
+
organisationText={header.organisationText}
|
|
142
|
+
organisationHref={header.organisationHref}
|
|
143
|
+
/>
|
|
144
|
+
|
|
145
|
+
<ServiceNavigation
|
|
146
|
+
items={serviceNavItems}
|
|
142
147
|
serviceName={header.serviceName}
|
|
143
148
|
serviceHref={withBase(header.serviceHref || '/')}
|
|
144
149
|
/>
|
|
145
150
|
|
|
146
|
-
<ServiceNavigation items={serviceNavItems} />
|
|
147
|
-
|
|
148
151
|
<div className="govuk-width-container">
|
|
149
152
|
{phaseBanner && (
|
|
150
153
|
<PhaseBanner phase={phaseBanner.phase}>
|
|
@@ -174,7 +177,7 @@ export default function Layout(props) {
|
|
|
174
177
|
</div>
|
|
175
178
|
|
|
176
179
|
{!noFooter && (
|
|
177
|
-
<Footer
|
|
180
|
+
<Footer rebrand meta={footer.meta} />
|
|
178
181
|
)}
|
|
179
182
|
</div>
|
|
180
183
|
</LayoutProvider>
|