@nswds/app 1.122.0 → 1.124.0

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/dist/index.cjs CHANGED
@@ -15147,7 +15147,7 @@ function resolveBackgroundToken(themeCategory, primaryKey, accentKey, preferredT
15147
15147
  function getContrastRatio(backgroundHex, foregroundHex) {
15148
15148
  return culori__namespace.wcagContrast(backgroundHex, foregroundHex) ?? 0;
15149
15149
  }
15150
- function getContrastLevel(contrastRatio) {
15150
+ function getContrastComplianceSummary(contrastRatio) {
15151
15151
  if (contrastRatio >= AAA_NORMAL_CONTRAST_RATIO) {
15152
15152
  return "Passes AA large, AA normal, AAA large, and AAA normal";
15153
15153
  }
@@ -15164,6 +15164,12 @@ function getContrastTone(contrastRatio) {
15164
15164
  if (contrastRatio >= AA_LARGE_CONTRAST_RATIO) return "warning";
15165
15165
  return "danger";
15166
15166
  }
15167
+ function supportsNormalTextPreview(contrastRatio) {
15168
+ return contrastRatio >= AA_NORMAL_CONTRAST_RATIO;
15169
+ }
15170
+ function supportsLargeTextPreview(contrastRatio) {
15171
+ return contrastRatio >= AA_LARGE_CONTRAST_RATIO;
15172
+ }
15167
15173
  function getPreviewHeroRatingLabel(contrastRatio) {
15168
15174
  if (contrastRatio >= AAA_NORMAL_CONTRAST_RATIO) return "AAA normal";
15169
15175
  if (contrastRatio >= AA_NORMAL_CONTRAST_RATIO) return "AA normal";
@@ -15287,12 +15293,12 @@ function getRecommendedCandidate(themeCategory, background, primaryFamily, accen
15287
15293
  }
15288
15294
  return null;
15289
15295
  }
15290
- function getAccessibleForegroundOptions(themeCategory, background, primaryFamily, accentFamily) {
15296
+ function getForegroundOptionsMeetingAaLarge(themeCategory, background, primaryFamily, accentFamily) {
15291
15297
  return scoreForegroundCandidates(themeCategory, background, primaryFamily, accentFamily).filter((candidate) => candidate.contrastRatio >= AA_LARGE_CONTRAST_RATIO).sort((left, right) => right.contrastRatio - left.contrastRatio);
15292
15298
  }
15293
15299
  function getPreviewAnnouncement(background, foreground) {
15294
15300
  if (!foreground) {
15295
- return `${background.token} selected. No accessible foreground options meeting 3 to 1 are available.`;
15301
+ return `${background.token} selected. No foreground options meeting AA large (3 to 1) are available.`;
15296
15302
  }
15297
15303
  return `${background.token} paired with ${foreground.token}. Contrast ratio ${foreground.contrastRatio.toFixed(2)} to 1.`;
15298
15304
  }
@@ -15350,7 +15356,7 @@ function getInitialPairingState(searchParams) {
15350
15356
  const backgroundShade = [...primaryFamily.shades, ...accentFamily.shades, ...greyFamily.shades].find(
15351
15357
  (shade) => shade.token === selectedBackgroundToken
15352
15358
  ) ?? getShadeForTone(primaryFamily, DEFAULT_BACKGROUND_TONE);
15353
- const selectedForegroundId = getAccessibleForegroundOptions(
15359
+ const selectedForegroundId = getForegroundOptionsMeetingAaLarge(
15354
15360
  themeCategory,
15355
15361
  backgroundShade,
15356
15362
  primaryFamily,
@@ -15567,7 +15573,7 @@ function ForegroundOption({
15567
15573
  " ",
15568
15574
  candidate.contrastRatio.toFixed(2),
15569
15575
  " to 1, ",
15570
- getForegroundOptionBadge(candidate).label
15576
+ badge.label
15571
15577
  ] })
15572
15578
  ]
15573
15579
  }
@@ -15610,7 +15616,12 @@ function ColorPairingToolContent({ visibleFormats }) {
15610
15616
  [backgroundShadeOptions, selectedBackgroundToken]
15611
15617
  );
15612
15618
  const accessibleForegroundOptions = React5.useMemo(
15613
- () => getAccessibleForegroundOptions(themeCategory, backgroundShade, primaryFamily, accentFamily),
15619
+ () => getForegroundOptionsMeetingAaLarge(
15620
+ themeCategory,
15621
+ backgroundShade,
15622
+ primaryFamily,
15623
+ accentFamily
15624
+ ),
15614
15625
  [accentFamily, backgroundShade, primaryFamily, themeCategory]
15615
15626
  );
15616
15627
  const recommendedForeground = React5.useMemo(
@@ -15747,7 +15758,7 @@ function ColorPairingToolContent({ visibleFormats }) {
15747
15758
  `format: ${getColorFormatLabel(resolvedCopyFormat)}`,
15748
15759
  `foreground: ${previewForeground.token} (${getColorValue(previewForeground, resolvedCopyFormat)})`,
15749
15760
  `background: ${backgroundShade.token} (${getColorValue(backgroundShade, resolvedCopyFormat)})`,
15750
- `contrast: ${previewForeground.contrastRatio.toFixed(2)}:1 ${getContrastLevel(previewForeground.contrastRatio)}`
15761
+ `contrast: ${previewForeground.contrastRatio.toFixed(2)}:1 ${getContrastComplianceSummary(previewForeground.contrastRatio)}`
15751
15762
  ].join("\n")
15752
15763
  );
15753
15764
  setCopiedKey("pairing");
@@ -15779,6 +15790,8 @@ function ColorPairingToolContent({ visibleFormats }) {
15779
15790
  const previewHeroRatingLabel = getPreviewHeroRatingLabel(contrastRatio);
15780
15791
  const previewHeroStatusLabel = getPreviewHeroStatusLabel(contrastRatio);
15781
15792
  const contrastTone = getContrastTone(contrastRatio);
15793
+ const showNormalTextPreview = supportsNormalTextPreview(contrastRatio);
15794
+ const showLargeTextPreview = supportsLargeTextPreview(contrastRatio);
15782
15795
  const resolvedCopyFormat = visibleFormats.includes(copyFormat) ? copyFormat : visibleFormats[0] ?? DEFAULT_VISIBLE_FORMATS[0];
15783
15796
  return /* @__PURE__ */ jsxRuntime.jsx("section", { className: "min-w-0 overflow-hidden rounded-sm bg-white text-grey-800", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid min-w-0 xl:min-h-[46rem] xl:grid-cols-[260px_minmax(0,1fr)] xl:gap-x-6", children: [
15784
15797
  /* @__PURE__ */ jsxRuntime.jsx("aside", { className: "border-b border-grey-200 px-4 py-5 sm:px-6 xl:border-b-0 xl:px-0", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
@@ -15904,38 +15917,49 @@ function ColorPairingToolContent({ visibleFormats }) {
15904
15917
  }
15905
15918
  )
15906
15919
  ] }),
15907
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 items-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "max-w-[42rem] space-y-5 pb-12 sm:pb-8", children: [
15908
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[0.82rem] font-semibold tracking-[0.12em] uppercase", children: "NSW Government Digital" }),
15909
- /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-4xl leading-none font-bold sm:text-5xl", children: "Connecting communities to services that matter" }),
15910
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "max-w-[38rem] text-base leading-7 sm:text-lg sm:leading-8", children: "Review how each pairing performs against AA and AAA requirements for normal and large text across your selected primary, accent, and grey families." }),
15911
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3 pt-1", children: [
15912
- /* @__PURE__ */ jsxRuntime.jsx(
15913
- "span",
15914
- {
15915
- "aria-hidden": "true",
15916
- "data-variant": "solid",
15917
- className: cn(
15918
- buttonVariants({ variant: "solid", size: "default" }),
15919
- "pointer-events-none cursor-default px-6 text-[16px] font-[700] select-none sm:px-6 sm:text-[16px] sm:font-[700]"
15920
- ),
15921
- style: fauxButtonStyle,
15922
- children: "Get started"
15923
- }
15920
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 items-center", children: /* @__PURE__ */ jsxRuntime.jsxs(
15921
+ "div",
15922
+ {
15923
+ className: cn(
15924
+ "max-w-[42rem] space-y-5",
15925
+ showNormalTextPreview && "pb-12 sm:pb-8"
15924
15926
  ),
15925
- /* @__PURE__ */ jsxRuntime.jsx(
15926
- "span",
15927
- {
15928
- "data-variant": "outline",
15929
- className: cn(
15930
- buttonVariants({ variant: "outline", size: "default" }),
15931
- "pointer-events-none cursor-default px-6 text-[16px] font-[700] select-none sm:px-6 sm:text-[16px] sm:font-[700]"
15932
- ),
15933
- style: fauxButtonStyle,
15934
- children: "Learn more"
15935
- }
15936
- )
15937
- ] })
15938
- ] }) }),
15927
+ children: [
15928
+ showNormalTextPreview ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[0.82rem] font-semibold tracking-[0.12em] uppercase", children: "NSW Government Digital" }) : null,
15929
+ showLargeTextPreview ? /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-4xl leading-none font-bold sm:text-5xl", children: "Connecting communities to services that matter" }) : null,
15930
+ showNormalTextPreview ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
15931
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "max-w-[38rem] text-base leading-7 sm:text-lg sm:leading-8", children: "Review how each pairing performs against AA and AAA requirements for normal and large text across your selected primary, accent, and grey families." }),
15932
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3 pt-1", children: [
15933
+ /* @__PURE__ */ jsxRuntime.jsx(
15934
+ "span",
15935
+ {
15936
+ "aria-hidden": "true",
15937
+ "data-variant": "solid",
15938
+ className: cn(
15939
+ buttonVariants({ variant: "solid", size: "default" }),
15940
+ "pointer-events-none cursor-default px-6 text-[16px] font-[700] select-none sm:px-6 sm:text-[16px] sm:font-[700]"
15941
+ ),
15942
+ style: fauxButtonStyle,
15943
+ children: "Get started"
15944
+ }
15945
+ ),
15946
+ /* @__PURE__ */ jsxRuntime.jsx(
15947
+ "span",
15948
+ {
15949
+ "data-variant": "outline",
15950
+ className: cn(
15951
+ buttonVariants({ variant: "outline", size: "default" }),
15952
+ "pointer-events-none cursor-default px-6 text-[16px] font-[700] select-none sm:px-6 sm:text-[16px] sm:font-[700]"
15953
+ ),
15954
+ style: fauxButtonStyle,
15955
+ children: "Learn more"
15956
+ }
15957
+ )
15958
+ ] })
15959
+ ] }) : null
15960
+ ]
15961
+ }
15962
+ ) }),
15939
15963
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
15940
15964
  /* @__PURE__ */ jsxRuntime.jsxs(
15941
15965
  "span",
@@ -16124,7 +16148,7 @@ function ColorPairingToolContent({ visibleFormats }) {
16124
16148
  onClick: () => handleForegroundChange(candidate.id)
16125
16149
  },
16126
16150
  candidate.id
16127
- )) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "py-3 text-sm text-grey-600", children: "No accessible foreground options meeting 3:1 are available for this background." }) })
16151
+ )) : /* @__PURE__ */ jsxRuntime.jsx("p", { className: "py-3 text-sm text-grey-600", children: "No foreground options meeting AA large (3:1) are available for this background." }) })
16128
16152
  ] })
16129
16153
  ] })
16130
16154
  ] }) });
@@ -19025,7 +19049,7 @@ function FormatToggle({ format, setFormat }) {
19025
19049
 
19026
19050
  // package.json
19027
19051
  var package_default = {
19028
- version: "1.121.2"};
19052
+ version: "1.123.0"};
19029
19053
  var SluggerContext = React5__namespace.default.createContext(null);
19030
19054
  function flattenText(nodes) {
19031
19055
  if (nodes == null || typeof nodes === "boolean") return "";