Skip to content

Commit 7b491f0

Browse files
author
Fergus Bisset
committed
fix(ProductCard): remove useRef for SSR compatibility
- Remove unused useRef from ProductCard component - Change image seed default from Date.now() to 0 for SSR consistency - Export ProductCard from /ssr barrel for Next.js usage - Add SSR validation test to prevent client hooks in SSR exports - Add test:ssr-components to preversion scripts for quality gate - Add comprehensive ProductCard documentation for SSR usage Breaking change: ProductCard image seed now defaults to 0 instead of Date.now() Users must provide explicit seed values for unique patterns in SSR contexts
1 parent 50d5339 commit 7b491f0

File tree

42 files changed

+2366
-1371
lines changed

Some content is hidden

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

42 files changed

+2366
-1371
lines changed

config/vitest.ssr.config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import tsconfigPaths from 'vite-tsconfig-paths'
66
export default defineConfig({
77
plugins: [tsconfigPaths(), react()],
88
test: {
9-
include: ['src/**/*.ssr.test.{ts,tsx}', 'src/**/*.env-safe.test.{ts,tsx}'],
9+
include: [
10+
'src/**/*.ssr.test.{ts,tsx}',
11+
'src/**/*.env-safe.test.{ts,tsx}',
12+
'tests/ssr-validation/**/*.test.{ts,tsx}'
13+
],
1014
environment: 'jsdom',
1115
setupFiles: ['src/test-setup.ts', 'src/ssr-test-setup.ts'],
1216
globals: true,

dist/components/_internal/Mermaid.css

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,93 @@
1+
.nhsuk-u-visually-hidden {
2+
position: absolute !important;
3+
width: 1px !important;
4+
height: 1px !important;
5+
padding: 0 !important;
6+
margin: -1px !important;
7+
overflow: hidden !important;
8+
clip: rect(0, 0, 0, 0) !important;
9+
white-space: nowrap !important;
10+
border: 0 !important;
11+
}
12+
.nhsuk-u-hidden {
13+
display: none !important;
14+
}
15+
.nhsuk-u-show {
16+
display: block !important;
17+
}
18+
.nhsuk-u-text-left {
19+
text-align: left !important;
20+
}
21+
.nhsuk-u-text-center {
22+
text-align: center !important;
23+
}
24+
.nhsuk-u-text-right {
25+
text-align: right !important;
26+
}
27+
.nhsuk-u-margin-0 {
28+
margin: 0 !important;
29+
}
30+
.nhsuk-u-margin-bottom-0 {
31+
margin-bottom: 0 !important;
32+
}
33+
.nhsuk-u-margin-top-0 {
34+
margin-top: 0 !important;
35+
}
36+
.nhsuk-u-padding-0 {
37+
padding: 0 !important;
38+
}
39+
.nhsuk-u-padding-bottom-0 {
40+
padding-bottom: 0 !important;
41+
}
42+
.nhsuk-u-padding-top-0 {
43+
padding-top: 0 !important;
44+
}
45+
.nhsuk-u-clearfix::after {
46+
content: "";
47+
display: table;
48+
clear: both;
49+
}
50+
51+
.nhsuk-header .nhsuk-u-visually-hidden,
52+
.nhsuk-header__search .nhsuk-u-visually-hidden,
53+
label .nhsuk-u-visually-hidden,
54+
span .nhsuk-u-visually-hidden {
55+
position: absolute !important;
56+
width: 1px !important;
57+
height: 1px !important;
58+
padding: 0 !important;
59+
margin: -1px !important;
60+
overflow: hidden !important;
61+
clip: rect(0, 0, 0, 0) !important;
62+
-webkit-clip-path: inset(50%) !important;
63+
clip-path: inset(50%) !important;
64+
white-space: nowrap !important;
65+
border: 0 !important;
66+
}
67+
68+
.nhsuk-width-container {
69+
margin: 0 auto;
70+
padding: 0 24px;
71+
max-width: 1200px;
72+
}
73+
@media (min-width: 768px) {
74+
.nhsuk-width-container {
75+
padding: 0 32px;
76+
}
77+
}
78+
@media (min-width: 1020px) {
79+
.nhsuk-width-container {
80+
padding: 0 40px;
81+
}
82+
}
83+
84+
.nhsuk-icon {
85+
width: auto !important;
86+
height: 2em;
87+
vertical-align: text-bottom;
88+
flex-shrink: 0;
89+
}
90+
191
.mermaid-diagram {
292
--_mm-bg: var(--nhs-fdp-color-grey-6, nhs.$nhs-fdp-color-grey-6);
393
--_mm-border: var(--nhs-fdp-color-grey-4, nhs.$nhs-fdp-color-grey-4);

dist/index.esm.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,9 +1781,22 @@ function Bd(e) {
17811781
].filter(Boolean).join(" "), o = e.marginBottom ? { marginBottom: e.marginBottom } : void 0;
17821782
return { tag: `h${t}`, classes: r, style: o };
17831783
}
1784-
const Bt = ({ level: e, className: t, text: r, html: o, children: s, size: a, marginBottom: i, ...l }) => {
1784+
const Bt = ({
1785+
level: e,
1786+
className: t,
1787+
text: r,
1788+
html: o,
1789+
children: s,
1790+
size: a,
1791+
marginBottom: i,
1792+
...l
1793+
}) => {
17851794
const c = Bd({ level: e, size: a, className: t, marginBottom: i }), d = s || (o ? /* @__PURE__ */ n.jsx("span", { dangerouslySetInnerHTML: { __html: o } }) : r);
1786-
return Pi(c.tag, { className: c.classes, style: c.style, ...l }, d);
1795+
return Pi(
1796+
c.tag,
1797+
{ className: c.classes, style: c.style, ...l },
1798+
d
1799+
);
17871800
};
17881801
function Hd(e) {
17891802
return {

dist/index.esm.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)