@tokenoftrust/cli 2.5.3 → 2.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/cli",
3
- "version": "2.5.3",
3
+ "version": "2.5.4",
4
4
  "description": "Token of Trust developer CLI — clone a tenant store, run it locally with save→reload, and submit it for preview. Installs the `tot` command.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Token of Trust",
@@ -712,6 +712,15 @@ export function describeNicotineWarningPresentation(p) {
712
712
  * of every page; "block" is the reinforced box on the product page. Every interpolated value
713
713
  * is a validated hex colour, enum or number. Styling is inline (no utility classes), so the
714
714
  * markup renders the same wherever it is served, whatever stylesheet the page carries.
715
+ *
716
+ * Every presentation and visibility declaration is inline `!important`, which no tenant
717
+ * stylesheet rule can override: tenant CSS cannot hide, move, clip, fade or restyle the warning,
718
+ * and the text element re-asserts the warning's own presentation so a tenant `p { … }` rule does
719
+ * not reach it. What inline styles cannot stop is another element painting over the warning (a
720
+ * fixed or sticky header pinned to the top of the viewport). Raising the warning above page
721
+ * chrome would paint it over the tenant's own open menus and drawers, so occlusion is measured
722
+ * instead: the page browser gate (`validate-page-browser.mjs`, `nicotineWarning`) fails a page
723
+ * whose warning is covered at a phone, tablet or desktop width and names the covering element.
715
724
  * @param {unknown} declaration the tenant's `compliance.nicotineWarning`
716
725
  * @param {"bar" | "block"} variant
717
726
  */
@@ -719,11 +728,40 @@ export function nicotineWarningHtml(declaration, variant) {
719
728
  const { presentation, preset } = resolveNicotineWarning(declaration);
720
729
  const attrs = `style="${nicotineWarningStyle(presentation, variant)}" role="note" aria-label="Health warning" ` +
721
730
  `data-compliance="nicotine-warning" data-nicotine-warning-preset="${preset ?? "custom"}"`;
731
+ const text = NICOTINE_WARNING_TEXT_LOCK;
722
732
  return variant === "bar"
723
- ? `<div ${attrs}><p class="container-prose" style="margin-block:0;padding-block:0.5rem;text-align:center">${NICOTINE_WARNING_TEXT}</p></div>`
724
- : `<div ${attrs}><p style="margin:0">${NICOTINE_WARNING_TEXT}</p></div>`;
733
+ ? `<div ${attrs}><p class="container-prose" style="margin-block:0;padding-block:0.5rem;text-align:center;${text}">${NICOTINE_WARNING_TEXT}</p></div>`
734
+ : `<div ${attrs}><p style="margin:0;${text}">${NICOTINE_WARNING_TEXT}</p></div>`;
725
735
  }
726
736
 
737
+ /** Declarations that keep the warning on screen, at full opacity, in its own place. */
738
+ const NICOTINE_WARNING_VISIBILITY_LOCK = [
739
+ "display:block",
740
+ "visibility:visible",
741
+ "opacity:1",
742
+ "position:relative",
743
+ "inset:auto",
744
+ "transform:none",
745
+ "clip-path:none",
746
+ "filter:none",
747
+ "height:auto",
748
+ "max-height:none",
749
+ "overflow:visible",
750
+ ];
751
+
752
+ /** The text element inherits the warning's presentation, whatever a tenant `p` rule says. */
753
+ const NICOTINE_WARNING_TEXT_LOCK = [
754
+ "display:block",
755
+ "visibility:visible",
756
+ "opacity:1",
757
+ "color:inherit",
758
+ "font-size:inherit",
759
+ "font-weight:inherit",
760
+ "text-transform:inherit",
761
+ "letter-spacing:inherit",
762
+ "line-height:inherit",
763
+ ].map((d) => `${d}!important`).join(";");
764
+
727
765
  /**
728
766
  * Inline CSS for a presentation. `variant` "block" (the product page) never renders smaller
729
767
  * than 14px.
@@ -744,5 +782,6 @@ export function nicotineWarningStyle(p, variant) {
744
782
  `font-weight:${p.fontWeight}`,
745
783
  `font-size:${size}px`,
746
784
  "line-height:1.4",
747
- ].join(";");
785
+ ...NICOTINE_WARNING_VISIBILITY_LOCK,
786
+ ].map((d) => `${d}!important`).join(";");
748
787
  }