@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.js CHANGED
@@ -15091,7 +15091,7 @@ function resolveBackgroundToken(themeCategory, primaryKey, accentKey, preferredT
15091
15091
  function getContrastRatio(backgroundHex, foregroundHex) {
15092
15092
  return culori.wcagContrast(backgroundHex, foregroundHex) ?? 0;
15093
15093
  }
15094
- function getContrastLevel(contrastRatio) {
15094
+ function getContrastComplianceSummary(contrastRatio) {
15095
15095
  if (contrastRatio >= AAA_NORMAL_CONTRAST_RATIO) {
15096
15096
  return "Passes AA large, AA normal, AAA large, and AAA normal";
15097
15097
  }
@@ -15108,6 +15108,12 @@ function getContrastTone(contrastRatio) {
15108
15108
  if (contrastRatio >= AA_LARGE_CONTRAST_RATIO) return "warning";
15109
15109
  return "danger";
15110
15110
  }
15111
+ function supportsNormalTextPreview(contrastRatio) {
15112
+ return contrastRatio >= AA_NORMAL_CONTRAST_RATIO;
15113
+ }
15114
+ function supportsLargeTextPreview(contrastRatio) {
15115
+ return contrastRatio >= AA_LARGE_CONTRAST_RATIO;
15116
+ }
15111
15117
  function getPreviewHeroRatingLabel(contrastRatio) {
15112
15118
  if (contrastRatio >= AAA_NORMAL_CONTRAST_RATIO) return "AAA normal";
15113
15119
  if (contrastRatio >= AA_NORMAL_CONTRAST_RATIO) return "AA normal";
@@ -15231,12 +15237,12 @@ function getRecommendedCandidate(themeCategory, background, primaryFamily, accen
15231
15237
  }
15232
15238
  return null;
15233
15239
  }
15234
- function getAccessibleForegroundOptions(themeCategory, background, primaryFamily, accentFamily) {
15240
+ function getForegroundOptionsMeetingAaLarge(themeCategory, background, primaryFamily, accentFamily) {
15235
15241
  return scoreForegroundCandidates(themeCategory, background, primaryFamily, accentFamily).filter((candidate) => candidate.contrastRatio >= AA_LARGE_CONTRAST_RATIO).sort((left, right) => right.contrastRatio - left.contrastRatio);
15236
15242
  }
15237
15243
  function getPreviewAnnouncement(background, foreground) {
15238
15244
  if (!foreground) {
15239
- return `${background.token} selected. No accessible foreground options meeting 3 to 1 are available.`;
15245
+ return `${background.token} selected. No foreground options meeting AA large (3 to 1) are available.`;
15240
15246
  }
15241
15247
  return `${background.token} paired with ${foreground.token}. Contrast ratio ${foreground.contrastRatio.toFixed(2)} to 1.`;
15242
15248
  }
@@ -15294,7 +15300,7 @@ function getInitialPairingState(searchParams) {
15294
15300
  const backgroundShade = [...primaryFamily.shades, ...accentFamily.shades, ...greyFamily.shades].find(
15295
15301
  (shade) => shade.token === selectedBackgroundToken
15296
15302
  ) ?? getShadeForTone(primaryFamily, DEFAULT_BACKGROUND_TONE);
15297
- const selectedForegroundId = getAccessibleForegroundOptions(
15303
+ const selectedForegroundId = getForegroundOptionsMeetingAaLarge(
15298
15304
  themeCategory,
15299
15305
  backgroundShade,
15300
15306
  primaryFamily,
@@ -15511,7 +15517,7 @@ function ForegroundOption({
15511
15517
  " ",
15512
15518
  candidate.contrastRatio.toFixed(2),
15513
15519
  " to 1, ",
15514
- getForegroundOptionBadge(candidate).label
15520
+ badge.label
15515
15521
  ] })
15516
15522
  ]
15517
15523
  }
@@ -15554,7 +15560,12 @@ function ColorPairingToolContent({ visibleFormats }) {
15554
15560
  [backgroundShadeOptions, selectedBackgroundToken]
15555
15561
  );
15556
15562
  const accessibleForegroundOptions = useMemo(
15557
- () => getAccessibleForegroundOptions(themeCategory, backgroundShade, primaryFamily, accentFamily),
15563
+ () => getForegroundOptionsMeetingAaLarge(
15564
+ themeCategory,
15565
+ backgroundShade,
15566
+ primaryFamily,
15567
+ accentFamily
15568
+ ),
15558
15569
  [accentFamily, backgroundShade, primaryFamily, themeCategory]
15559
15570
  );
15560
15571
  const recommendedForeground = useMemo(
@@ -15691,7 +15702,7 @@ function ColorPairingToolContent({ visibleFormats }) {
15691
15702
  `format: ${getColorFormatLabel(resolvedCopyFormat)}`,
15692
15703
  `foreground: ${previewForeground.token} (${getColorValue(previewForeground, resolvedCopyFormat)})`,
15693
15704
  `background: ${backgroundShade.token} (${getColorValue(backgroundShade, resolvedCopyFormat)})`,
15694
- `contrast: ${previewForeground.contrastRatio.toFixed(2)}:1 ${getContrastLevel(previewForeground.contrastRatio)}`
15705
+ `contrast: ${previewForeground.contrastRatio.toFixed(2)}:1 ${getContrastComplianceSummary(previewForeground.contrastRatio)}`
15695
15706
  ].join("\n")
15696
15707
  );
15697
15708
  setCopiedKey("pairing");
@@ -15723,6 +15734,8 @@ function ColorPairingToolContent({ visibleFormats }) {
15723
15734
  const previewHeroRatingLabel = getPreviewHeroRatingLabel(contrastRatio);
15724
15735
  const previewHeroStatusLabel = getPreviewHeroStatusLabel(contrastRatio);
15725
15736
  const contrastTone = getContrastTone(contrastRatio);
15737
+ const showNormalTextPreview = supportsNormalTextPreview(contrastRatio);
15738
+ const showLargeTextPreview = supportsLargeTextPreview(contrastRatio);
15726
15739
  const resolvedCopyFormat = visibleFormats.includes(copyFormat) ? copyFormat : visibleFormats[0] ?? DEFAULT_VISIBLE_FORMATS[0];
15727
15740
  return /* @__PURE__ */ jsx("section", { className: "min-w-0 overflow-hidden rounded-sm bg-white text-grey-800", children: /* @__PURE__ */ jsxs("div", { className: "grid min-w-0 xl:min-h-[46rem] xl:grid-cols-[260px_minmax(0,1fr)] xl:gap-x-6", children: [
15728
15741
  /* @__PURE__ */ jsx("aside", { className: "border-b border-grey-200 px-4 py-5 sm:px-6 xl:border-b-0 xl:px-0", children: /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
@@ -15848,38 +15861,49 @@ function ColorPairingToolContent({ visibleFormats }) {
15848
15861
  }
15849
15862
  )
15850
15863
  ] }),
15851
- /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center", children: /* @__PURE__ */ jsxs("div", { className: "max-w-[42rem] space-y-5 pb-12 sm:pb-8", children: [
15852
- /* @__PURE__ */ jsx("p", { className: "text-[0.82rem] font-semibold tracking-[0.12em] uppercase", children: "NSW Government Digital" }),
15853
- /* @__PURE__ */ jsx("h3", { className: "text-4xl leading-none font-bold sm:text-5xl", children: "Connecting communities to services that matter" }),
15854
- /* @__PURE__ */ 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." }),
15855
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3 pt-1", children: [
15856
- /* @__PURE__ */ jsx(
15857
- "span",
15858
- {
15859
- "aria-hidden": "true",
15860
- "data-variant": "solid",
15861
- className: cn(
15862
- buttonVariants({ variant: "solid", size: "default" }),
15863
- "pointer-events-none cursor-default px-6 text-[16px] font-[700] select-none sm:px-6 sm:text-[16px] sm:font-[700]"
15864
- ),
15865
- style: fauxButtonStyle,
15866
- children: "Get started"
15867
- }
15864
+ /* @__PURE__ */ jsx("div", { className: "flex flex-1 items-center", children: /* @__PURE__ */ jsxs(
15865
+ "div",
15866
+ {
15867
+ className: cn(
15868
+ "max-w-[42rem] space-y-5",
15869
+ showNormalTextPreview && "pb-12 sm:pb-8"
15868
15870
  ),
15869
- /* @__PURE__ */ jsx(
15870
- "span",
15871
- {
15872
- "data-variant": "outline",
15873
- className: cn(
15874
- buttonVariants({ variant: "outline", size: "default" }),
15875
- "pointer-events-none cursor-default px-6 text-[16px] font-[700] select-none sm:px-6 sm:text-[16px] sm:font-[700]"
15876
- ),
15877
- style: fauxButtonStyle,
15878
- children: "Learn more"
15879
- }
15880
- )
15881
- ] })
15882
- ] }) }),
15871
+ children: [
15872
+ showNormalTextPreview ? /* @__PURE__ */ jsx("p", { className: "text-[0.82rem] font-semibold tracking-[0.12em] uppercase", children: "NSW Government Digital" }) : null,
15873
+ showLargeTextPreview ? /* @__PURE__ */ jsx("h3", { className: "text-4xl leading-none font-bold sm:text-5xl", children: "Connecting communities to services that matter" }) : null,
15874
+ showNormalTextPreview ? /* @__PURE__ */ jsxs(Fragment, { children: [
15875
+ /* @__PURE__ */ 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." }),
15876
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3 pt-1", children: [
15877
+ /* @__PURE__ */ jsx(
15878
+ "span",
15879
+ {
15880
+ "aria-hidden": "true",
15881
+ "data-variant": "solid",
15882
+ className: cn(
15883
+ buttonVariants({ variant: "solid", size: "default" }),
15884
+ "pointer-events-none cursor-default px-6 text-[16px] font-[700] select-none sm:px-6 sm:text-[16px] sm:font-[700]"
15885
+ ),
15886
+ style: fauxButtonStyle,
15887
+ children: "Get started"
15888
+ }
15889
+ ),
15890
+ /* @__PURE__ */ jsx(
15891
+ "span",
15892
+ {
15893
+ "data-variant": "outline",
15894
+ className: cn(
15895
+ buttonVariants({ variant: "outline", size: "default" }),
15896
+ "pointer-events-none cursor-default px-6 text-[16px] font-[700] select-none sm:px-6 sm:text-[16px] sm:font-[700]"
15897
+ ),
15898
+ style: fauxButtonStyle,
15899
+ children: "Learn more"
15900
+ }
15901
+ )
15902
+ ] })
15903
+ ] }) : null
15904
+ ]
15905
+ }
15906
+ ) }),
15883
15907
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
15884
15908
  /* @__PURE__ */ jsxs(
15885
15909
  "span",
@@ -16068,7 +16092,7 @@ function ColorPairingToolContent({ visibleFormats }) {
16068
16092
  onClick: () => handleForegroundChange(candidate.id)
16069
16093
  },
16070
16094
  candidate.id
16071
- )) : /* @__PURE__ */ jsx("p", { className: "py-3 text-sm text-grey-600", children: "No accessible foreground options meeting 3:1 are available for this background." }) })
16095
+ )) : /* @__PURE__ */ jsx("p", { className: "py-3 text-sm text-grey-600", children: "No foreground options meeting AA large (3:1) are available for this background." }) })
16072
16096
  ] })
16073
16097
  ] })
16074
16098
  ] }) });
@@ -18969,7 +18993,7 @@ function FormatToggle({ format, setFormat }) {
18969
18993
 
18970
18994
  // package.json
18971
18995
  var package_default = {
18972
- version: "1.121.2"};
18996
+ version: "1.123.0"};
18973
18997
  var SluggerContext = React5__default.createContext(null);
18974
18998
  function flattenText(nodes) {
18975
18999
  if (nodes == null || typeof nodes === "boolean") return "";