@sigmela/router 0.9.1 → 0.10.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/CHANGELOG.md CHANGED
@@ -4,6 +4,18 @@ All notable changes to this package are documented here. The format follows
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
5
5
  [semantic versioning](https://semver.org/).
6
6
 
7
+ ## 0.10.0
8
+
9
+ ### Added
10
+
11
+ - `background` on `Modal` and `Sheet`: the window's own surface colour (any CSS
12
+ colour or `var(...)`). It is declared from content like `width`/`height`,
13
+ lands before the first painted frame, and re-points `--router-bg` and the
14
+ modal footer fade inside the surface, so dark windows no longer flash as a
15
+ light card. In a modal flow the surface keeps the last declared background
16
+ while the next step mounts, so a push never flashes back to the default.
17
+ The backdrop is unchanged.
18
+
7
19
  ## 0.9.1
8
20
 
9
21
  ### Fixed
package/README.md CHANGED
@@ -128,6 +128,21 @@ content overflow a fixed 600px or 860px frame:
128
128
  </Modal>
129
129
  ```
130
130
 
131
+ ### Window background
132
+
133
+ `background` gives a modal or sheet its own surface colour — any CSS colour or
134
+ `var(...)` — so a dark window never opens as a light card first. It is applied
135
+ before the first painted frame, holds through the enter animation, and the
136
+ surface keeps it across step pushes in a modal flow (give every step the same
137
+ value). It replaces `--router-bg` and the footer fade inside the surface only;
138
+ the backdrop and text colour are unchanged.
139
+
140
+ ```tsx
141
+ <Modal background="var(--background-page)" ariaLabel="Plans">
142
+ {/* … */}
143
+ </Modal>
144
+ ```
145
+
131
146
  ### Right-side panel
132
147
 
133
148
  `presentation="right"` turns the modal into a side panel at 640px and wider:
@@ -282,7 +297,7 @@ the whole look.
282
297
  ```bash
283
298
  npm install
284
299
  npm run typecheck
285
- npm test # 78 tests
300
+ npm test # 81 tests
286
301
  npm run lint
287
302
  npm run build # dist/index.js + dist/router.css + type declarations
288
303
  npm run example # Vite sandbox on the source
@@ -16,6 +16,11 @@ interface ModalProps {
16
16
  * is the regular fullscreen modal.
17
17
  */
18
18
  presentation?: ModalPresentation;
19
+ /**
20
+ * The window's own background (any CSS colour or var()). Applied before the
21
+ * first painted frame; the backdrop is unaffected.
22
+ */
23
+ background?: string;
19
24
  }
20
25
  interface ModalFrameProps {
21
26
  children: ReactNode;
@@ -28,7 +33,7 @@ interface ModalFrameProps {
28
33
  activeContentKey?: string;
29
34
  }
30
35
  export declare function ModalFrame({ children, open, onRequestClose, onExitComplete, zIndex, shell, contentSized, activeContentKey, }: ModalFrameProps): import("react/jsx-runtime").JSX.Element;
31
- declare function ModalRoot({ children, swipeToClose, ariaLabel, size, width, height, presentation, }: ModalProps): import("react/jsx-runtime").JSX.Element;
36
+ declare function ModalRoot({ children, swipeToClose, ariaLabel, size, width, height, presentation, background, }: ModalProps): import("react/jsx-runtime").JSX.Element;
32
37
  interface ModalHeaderProps {
33
38
  title?: string;
34
39
  leftAction?: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../src/components/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAQf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAqBhD,wBAAgB,mBAAmB,IAAI,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,KAAK,IAAI,CAOtE;AAED,KAAK,iBAAiB,GAAG,YAAY,GAAG,SAAS,GAAG,OAAO,CAAC;AAE5D,UAAU,UAAU;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC1B,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,YAAY,CAAC,EAAE,iBAAiB,CAAC;C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7D;AAED,eAAO,MAAM,KAAK;;;;;CAKhB,CAAC"}
@@ -9,6 +9,11 @@ interface SheetProps {
9
9
  variant?: SheetVariant;
10
10
  /** 'fullscreen' turns the sheet into a full-height surface. */
11
11
  presentation?: SheetPresentation;
12
+ /**
13
+ * The sheet's own background (any CSS colour or var()). Applied before the
14
+ * first painted frame; the backdrop is unaffected.
15
+ */
16
+ background?: string;
12
17
  }
13
18
  interface SheetFrameProps {
14
19
  children: ReactNode;
@@ -20,7 +25,7 @@ interface SheetFrameProps {
20
25
  activeContentKey?: string;
21
26
  }
22
27
  export declare function SheetFrame({ children, open, onRequestClose, onExitComplete, zIndex, shell, activeContentKey, }: SheetFrameProps): import("react/jsx-runtime").JSX.Element;
23
- declare function SheetRoot({ children, disableDismiss, onRequestClose, variant, presentation, }: SheetProps): import("react/jsx-runtime").JSX.Element;
28
+ declare function SheetRoot({ children, disableDismiss, onRequestClose, variant, presentation, background, }: SheetProps): import("react/jsx-runtime").JSX.Element;
24
29
  interface SheetHeaderProps {
25
30
  title?: string;
26
31
  leftAction?: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"Sheet.d.ts","sourceRoot":"","sources":["../../src/components/Sheet.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,aAAa,EAClB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAOf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,KAAK,YAAY,GAAG,UAAU,GAAG,UAAU,CAAC;AAC5C,KAAK,iBAAiB,GAAG,SAAS,GAAG,YAAY,CAAC;AA4BlD,UAAU,UAAU;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,iBAAiB,CAAC;CAClC;AAOD,UAAU,eAAe;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AED,iBAAS,SAAS,CAAC,EACjB,QAAQ,EACR,cAAc,EACd,cAAc,EACd,OAAoB,EACpB,YAAwB,EACxB,UAAU,GACX,EAAE,UAAU,2CAwBZ;AAED,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC5B;AAED,iBAAS,WAAW,CAAC,EACnB,KAAK,EACL,UAAU,EACV,WAAW,EACX,eAAe,EACf,MAAa,EACb,KAAe,GAChB,EAAE,gBAAgB,2CA2BlB;AAED,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,iBAAS,YAAY,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,iBAAiB,2CAE/D;AAED,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,iBAAS,eAAe,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,oBAAoB,2CAgB5E;AAED,UAAU,gBAAgB;IACxB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,iBAAS,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,gBAAgB,2CAa7D;AAED,eAAO,MAAM,KAAK;;;;;CAKhB,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type CSSProperties } from 'react';
2
+ /**
3
+ * Re-points the router's background tokens at a window's own colour. The
4
+ * footer fade tokens are resolved at :root, so they are re-declared here too.
5
+ */
6
+ export declare function overlayBackgroundStyle(background: string | undefined): CSSProperties;
7
+ /**
8
+ * The background a frame paints. A step that has not registered its options
9
+ * yet (still mounting or suspended) keeps the last declared background, so a
10
+ * push inside a dark window never flashes back to the default.
11
+ */
12
+ export declare function useOverlayBackground(activeOptions: {
13
+ background?: string;
14
+ } | undefined): [string | undefined, (options: {
15
+ background?: string;
16
+ } | null) => void];
17
+ //# sourceMappingURL=overlayBackground.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlayBackground.d.ts","sourceRoot":"","sources":["../../src/components/overlayBackground.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAElE;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa,CAOpF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,aAAa,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GACjD,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC,OAAO,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,KAAK,IAAI,CAAC,CAMzE"}
package/dist/index.js CHANGED
@@ -521,6 +521,21 @@ function OverlayContentScope({
521
521
  function useOverlayContentKey() {
522
522
  return useContext(OverlayContentKeyContext);
523
523
  }
524
+ function overlayBackgroundStyle(background) {
525
+ if (!background) return {};
526
+ return {
527
+ "--router-bg": background,
528
+ "--router-footer-fade-bg": background,
529
+ "--router-footer-fade-transparent": `rgb(from ${background} r g b / 0)`
530
+ };
531
+ }
532
+ function useOverlayBackground(activeOptions) {
533
+ const [lastBackground, setLastBackground] = useState(void 0);
534
+ const remember = useCallback((options) => {
535
+ if (options) setLastBackground(options.background);
536
+ }, []);
537
+ return [activeOptions ? activeOptions.background : lastBackground, remember];
538
+ }
524
539
  var DESKTOP_MIN_WIDTH = 640;
525
540
  var ModalContext = createContext(null);
526
541
  function useModalContext() {
@@ -565,7 +580,10 @@ function ModalFrame({
565
580
  },
566
581
  []
567
582
  );
583
+ const activeOptions = registrations.get(activeContentKey)?.options;
584
+ const [background, rememberBackground] = useOverlayBackground(activeOptions);
568
585
  const setOptions = useCallback((contentKey, options2) => {
586
+ rememberBackground(options2);
569
587
  setRegistrations((current) => {
570
588
  const registration = current.get(contentKey);
571
589
  if (registration?.options === options2) return current;
@@ -580,7 +598,7 @@ function ModalFrame({
580
598
  }
581
599
  return next;
582
600
  });
583
- }, []);
601
+ }, [rememberBackground]);
584
602
  const activeRegistration = registrations.get(activeContentKey);
585
603
  const swipeTarget = activeRegistration?.swipeTarget ?? null;
586
604
  const options = activeRegistration?.options;
@@ -617,6 +635,7 @@ function ModalFrame({
617
635
  shellClassName: `router-modal-shell${isRightPanel ? " router-modal-shell--right" : ""}`,
618
636
  surfaceClassName,
619
637
  surfaceStyle: {
638
+ ...overlayBackgroundStyle(background),
620
639
  "--router-modal-width": options?.width ? `${options.width}px` : void 0,
621
640
  "--router-modal-height": options?.height ? `${options.height}px` : void 0
622
641
  },
@@ -635,14 +654,33 @@ function ModalRoot({
635
654
  size = "regular",
636
655
  width,
637
656
  height,
638
- presentation = "fullscreen"
657
+ presentation = "fullscreen",
658
+ background
639
659
  }) {
640
660
  const { setOptions } = useModalContext();
641
661
  const contentKey = useOverlayContentKey();
642
662
  useLayoutEffect(() => {
643
- setOptions(contentKey, { swipeToClose, ariaLabel, size, width, height, presentation });
663
+ setOptions(contentKey, {
664
+ swipeToClose,
665
+ ariaLabel,
666
+ size,
667
+ width,
668
+ height,
669
+ presentation,
670
+ background
671
+ });
644
672
  return () => setOptions(contentKey, null);
645
- }, [ariaLabel, contentKey, height, presentation, setOptions, size, swipeToClose, width]);
673
+ }, [
674
+ ariaLabel,
675
+ background,
676
+ contentKey,
677
+ height,
678
+ presentation,
679
+ setOptions,
680
+ size,
681
+ swipeToClose,
682
+ width
683
+ ]);
646
684
  return /* @__PURE__ */ jsx(Fragment, { children });
647
685
  }
648
686
  function ModalHeader({
@@ -725,7 +763,10 @@ function SheetFrame({
725
763
  },
726
764
  []
727
765
  );
766
+ const activeOptions = registrations.get(activeContentKey)?.options;
767
+ const [background, rememberBackground] = useOverlayBackground(activeOptions);
728
768
  const setOptions = useCallback((contentKey, options2) => {
769
+ rememberBackground(options2);
729
770
  setRegistrations((current) => {
730
771
  const registration = current.get(contentKey);
731
772
  if (registration?.options === options2) return current;
@@ -740,7 +781,7 @@ function SheetFrame({
740
781
  }
741
782
  return next;
742
783
  });
743
- }, []);
784
+ }, [rememberBackground]);
744
785
  const activeRegistration = registrations.get(activeContentKey);
745
786
  const scrollElement = activeRegistration?.scrollElement ?? frameScrollElement;
746
787
  const options = activeRegistration?.options;
@@ -775,7 +816,7 @@ function SheetFrame({
775
816
  variant
776
817
  ]
777
818
  );
778
- const surfaceStyle = useMemo(
819
+ const layoutStyle = useMemo(
779
820
  () => fullscreen ? {
780
821
  backgroundColor: "var(--router-bg)",
781
822
  borderRadius: "33px 33px 0 0",
@@ -820,6 +861,10 @@ function SheetFrame({
820
861
  },
821
862
  [fullscreen, variant]
822
863
  );
864
+ const surfaceStyle = useMemo(
865
+ () => ({ ...overlayBackgroundStyle(background), ...layoutStyle }),
866
+ [background, layoutStyle]
867
+ );
823
868
  const backdropStyle = useMemo(
824
869
  () => shell === "desktop-fullscreen" ? {
825
870
  background: "var(--router-scrim)",
@@ -866,7 +911,8 @@ function SheetRoot({
866
911
  disableDismiss,
867
912
  onRequestClose,
868
913
  variant = "detached",
869
- presentation = "content"
914
+ presentation = "content",
915
+ background
870
916
  }) {
871
917
  const { setOptions } = useSheetContext();
872
918
  const contentKey = useOverlayContentKey();
@@ -875,10 +921,12 @@ function SheetRoot({
875
921
  disableDismiss,
876
922
  onRequestClose,
877
923
  variant,
878
- presentation
924
+ presentation,
925
+ background
879
926
  });
880
927
  return () => setOptions(contentKey, null);
881
928
  }, [
929
+ background,
882
930
  contentKey,
883
931
  disableDismiss,
884
932
  onRequestClose,