@dodopayments/ui 1.7.1 → 1.7.2

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.
Files changed (80) hide show
  1. package/ai/component-registry.json +152 -9
  2. package/ai/component-registry.md +1 -1
  3. package/ai/components/avatar.md +3 -0
  4. package/ai/components/data-grid.md +1 -1
  5. package/ai/components/list-toolbar.md +3 -1
  6. package/ai/components/page-header.md +13 -11
  7. package/ai/components/payment-logos.md +5 -4
  8. package/ai/components/segmented-control.md +14 -1
  9. package/ai/components/sidebar.md +13 -2
  10. package/ai/components/spinner.md +2 -0
  11. package/ai/skills/dodo-design/SKILL.md +11 -6
  12. package/dist/components/app-top-bar/app-top-bar.d.ts.map +1 -1
  13. package/dist/components/app-top-bar/app-top-bar.js +12 -7
  14. package/dist/components/app-top-bar/app-top-bar.js.map +1 -1
  15. package/dist/components/avatar/avatar.d.ts +22 -1
  16. package/dist/components/avatar/avatar.d.ts.map +1 -1
  17. package/dist/components/avatar/avatar.js +13 -3
  18. package/dist/components/avatar/avatar.js.map +1 -1
  19. package/dist/components/data-grid/data-grid.d.ts +1 -1
  20. package/dist/components/data-grid/data-grid.js +2 -2
  21. package/dist/components/data-grid/data-grid.js.map +1 -1
  22. package/dist/components/list-toolbar/list-toolbar.d.ts +3 -1
  23. package/dist/components/list-toolbar/list-toolbar.d.ts.map +1 -1
  24. package/dist/components/list-toolbar/list-toolbar.js +13 -2
  25. package/dist/components/list-toolbar/list-toolbar.js.map +1 -1
  26. package/dist/components/page-header/page-header.d.ts +11 -7
  27. package/dist/components/page-header/page-header.d.ts.map +1 -1
  28. package/dist/components/page-header/page-header.js +34 -11
  29. package/dist/components/page-header/page-header.js.map +1 -1
  30. package/dist/components/payment-logos/payment-logos.d.ts +8 -3
  31. package/dist/components/payment-logos/payment-logos.d.ts.map +1 -1
  32. package/dist/components/payment-logos/payment-logos.js +5 -5
  33. package/dist/components/payment-logos/payment-logos.js.map +1 -1
  34. package/dist/components/radio-group/radio-group.d.ts +2 -2
  35. package/dist/components/radio-group/radio-group.js +5 -5
  36. package/dist/components/radio-group/radio-group.js.map +1 -1
  37. package/dist/components/segmented-control/index.d.ts +1 -1
  38. package/dist/components/segmented-control/index.d.ts.map +1 -1
  39. package/dist/components/segmented-control/index.js +1 -1
  40. package/dist/components/segmented-control/index.js.map +1 -1
  41. package/dist/components/segmented-control/segmented-control.d.ts +19 -0
  42. package/dist/components/segmented-control/segmented-control.d.ts.map +1 -1
  43. package/dist/components/segmented-control/segmented-control.js +28 -7
  44. package/dist/components/segmented-control/segmented-control.js.map +1 -1
  45. package/dist/components/select/select.d.ts.map +1 -1
  46. package/dist/components/select/select.js +8 -2
  47. package/dist/components/select/select.js.map +1 -1
  48. package/dist/components/sidebar/index.d.ts +1 -1
  49. package/dist/components/sidebar/index.d.ts.map +1 -1
  50. package/dist/components/sidebar/index.js +1 -1
  51. package/dist/components/sidebar/index.js.map +1 -1
  52. package/dist/components/sidebar/sidebar.d.ts +22 -3
  53. package/dist/components/sidebar/sidebar.d.ts.map +1 -1
  54. package/dist/components/sidebar/sidebar.js +28 -12
  55. package/dist/components/sidebar/sidebar.js.map +1 -1
  56. package/dist/components/spinner/spinner.d.ts +12 -1
  57. package/dist/components/spinner/spinner.d.ts.map +1 -1
  58. package/dist/components/spinner/spinner.js +2 -2
  59. package/dist/components/spinner/spinner.js.map +1 -1
  60. package/dist/lib/cn-tables.js +5 -5
  61. package/dist/lib/cn-tables.js.map +1 -1
  62. package/dist/primitives/lib/segmented-control.js +2 -2
  63. package/dist/primitives/lib/segmented-control.js.map +1 -1
  64. package/dist/primitives/ui/dialog.d.ts.map +1 -1
  65. package/dist/primitives/ui/dialog.js +4 -2
  66. package/dist/primitives/ui/dialog.js.map +1 -1
  67. package/dist/primitives/ui/sheet.js +4 -4
  68. package/dist/primitives/ui/sheet.js.map +1 -1
  69. package/dist/primitives/ui/sidebar.js +2 -2
  70. package/dist/primitives/ui/sidebar.js.map +1 -1
  71. package/dist/primitives/ui/switch.d.ts +2 -2
  72. package/dist/primitives/ui/switch.d.ts.map +1 -1
  73. package/dist/primitives/ui/switch.js +2 -2
  74. package/dist/primitives/ui/switch.js.map +1 -1
  75. package/dist/primitives/ui/table.js +4 -4
  76. package/dist/primitives/ui/table.js.map +1 -1
  77. package/dist/styles/theme.css +67 -0
  78. package/dist/styles/tokens.css +97 -67
  79. package/dist/styles/tokens.test.tsx +147 -0
  80. package/package.json +1 -1
@@ -3,6 +3,7 @@ import { cdp, userEvent } from "vitest/browser";
3
3
  import { render } from "vitest-browser-react";
4
4
  import { contrastRatio, parseShadows, toRgba } from "../../test/color.ts";
5
5
  import { resolveToken } from "../../test/layout.ts";
6
+ import { durationMs, enableTransitions } from "../../test/motion.ts";
6
7
  import { Button } from "../components/button/button.tsx";
7
8
  import { Card, CardContent } from "../components/card/card.tsx";
8
9
  import { Command, CommandInput, CommandItem, CommandList } from "../components/command/command.tsx";
@@ -743,3 +744,149 @@ describe("chart palette", () => {
743
744
  },
744
745
  );
745
746
  });
747
+
748
+ describe("use-case colour names", () => {
749
+ // Each pair is written out in full: Tailwind only emits a class it can read in the source.
750
+ const pairs = [
751
+ ["bg-surface-secondary", "bg-muted"],
752
+ ["bg-surface-tertiary", "bg-tertiary"],
753
+ ["bg-surface-hover", "bg-accent"],
754
+ ["bg-surface-inverted", "bg-primary"],
755
+ ["bg-surface-scrim", "bg-scrim"],
756
+ ["bg-surface-brand", "bg-brand"],
757
+ ["bg-surface-brand-subtle", "bg-brand-subtle"],
758
+ ["bg-surface-success", "bg-success"],
759
+ ["bg-surface-success-subtle", "bg-success-subtle"],
760
+ ["bg-surface-warning", "bg-warning"],
761
+ ["bg-surface-warning-subtle", "bg-warning-subtle"],
762
+ ["bg-surface-error", "bg-destructive"],
763
+ ["bg-surface-error-subtle", "bg-destructive-subtle"],
764
+ ["bg-surface-info", "bg-info"],
765
+ ["bg-surface-info-subtle", "bg-info-subtle"],
766
+ ["text-content-primary", "text-foreground"],
767
+ ["text-content-secondary", "text-muted-foreground"],
768
+ ["text-content-tertiary", "text-tertiary-foreground"],
769
+ ["text-content-placeholder", "text-placeholder"],
770
+ ["text-content-inverted", "text-primary-foreground"],
771
+ ["text-content-link", "text-link"],
772
+ ["text-content-brand", "text-brand-content"],
773
+ ["text-content-on-brand", "text-brand-foreground"],
774
+ ["text-content-success", "text-success-foreground"],
775
+ ["text-content-warning", "text-warning-foreground"],
776
+ ["text-content-error", "text-destructive-foreground"],
777
+ ["text-content-info", "text-info-foreground"],
778
+ ["border-border-primary", "border-border"],
779
+ ["border-border-secondary", "border-border-subtle"],
780
+ ["border-border-overlay", "border-popover-border"],
781
+ ["border-border-focus", "border-ring"],
782
+ ["border-border-brand", "border-brand-border"],
783
+ ["border-border-success", "border-success-border"],
784
+ ["border-border-warning", "border-warning-border"],
785
+ ["border-border-error", "border-destructive-border"],
786
+ ["border-border-info", "border-info-border"],
787
+ ] as const;
788
+
789
+ test("each use-case class paints the same colour as the coss class it stands for, in light and dark", async () => {
790
+ const screen = await render(
791
+ <div>
792
+ {(["light", "dark"] as const).map((mode) => (
793
+ <div key={mode} className={mode}>
794
+ {pairs.map(([next, previous]) => (
795
+ <div key={next}>
796
+ <span data-testid={`${mode}-${next}`} className={cn("border", next)} />
797
+ <span data-testid={`${mode}-${previous}-old`} className={cn("border", previous)} />
798
+ </div>
799
+ ))}
800
+ </div>
801
+ ))}
802
+ </div>,
803
+ );
804
+ for (const mode of ["light", "dark"]) {
805
+ for (const [next, previous] of pairs) {
806
+ const property = next.startsWith("bg-")
807
+ ? "backgroundColor"
808
+ : next.startsWith("text-")
809
+ ? "color"
810
+ : "borderTopColor";
811
+ const read = (testId: string) =>
812
+ getComputedStyle(screen.getByTestId(testId).element())[property];
813
+ expect(read(`${mode}-${next}`), `${mode} ${next}`).toBe(read(`${mode}-${previous}-old`));
814
+ }
815
+ }
816
+ // The classes really paint: two different roles give two different colours.
817
+ const paint = (testId: string, property: "backgroundColor" | "color") =>
818
+ getComputedStyle(screen.getByTestId(testId).element())[property];
819
+ expect(paint("light-bg-surface-secondary", "backgroundColor")).not.toBe(
820
+ paint("light-bg-surface-hover", "backgroundColor"),
821
+ );
822
+ expect(paint("dark-text-content-secondary", "color")).not.toBe(
823
+ paint("dark-text-content-primary", "color"),
824
+ );
825
+ });
826
+
827
+ test("cn() puts a use-case class and a coss class in the same group: the last one wins", () => {
828
+ expect(cn("bg-muted", "bg-surface-secondary")).toBe("bg-surface-secondary");
829
+ expect(cn("text-content-secondary", "text-foreground")).toBe("text-foreground");
830
+ expect(cn("border-border", "border-border-primary")).toBe("border-border-primary");
831
+ });
832
+ });
833
+
834
+ describe("use-case radius and duration names", () => {
835
+ test("each use-case radius is the corner of the size it stands for", async () => {
836
+ const pairs = [
837
+ ["rounded-chip", "rounded-sm"],
838
+ ["rounded-control", "rounded-lg"],
839
+ ["rounded-panel", "rounded-xl"],
840
+ ["rounded-tray", "rounded-2xl"],
841
+ ["rounded-pill", "rounded-full"],
842
+ ] as const;
843
+ const screen = await render(
844
+ <div>
845
+ {pairs.map(([next, previous]) => (
846
+ <div key={next}>
847
+ <span data-testid={next} className={cn("block size-10", next)} />
848
+ <span data-testid={previous} className={cn("block size-10", previous)} />
849
+ </div>
850
+ ))}
851
+ </div>,
852
+ );
853
+ const radius = (testId: string) =>
854
+ getComputedStyle(screen.getByTestId(testId).element()).borderTopLeftRadius;
855
+ for (const [next, previous] of pairs) expect(radius(next), next).toBe(radius(previous));
856
+ expect(radius("rounded-control")).toBe("8px");
857
+ expect(radius("rounded-panel")).toBe("12px");
858
+ expect(radius("rounded-tray")).toBe("16px");
859
+ expect(cn("rounded-lg", "rounded-control")).toBe("rounded-control");
860
+ });
861
+
862
+ test("each use-case duration is the speed it stands for, and a close is faster than an open", async () => {
863
+ const pairs = [
864
+ ["duration-open", "duration-fast"],
865
+ ["duration-close", "duration-quick"],
866
+ ["duration-panel-open", "duration-slow"],
867
+ ["duration-panel-close", "duration-medium"],
868
+ ] as const;
869
+ const screen = await render(
870
+ <div>
871
+ {pairs.map(([next, previous]) => (
872
+ <div key={next}>
873
+ <span data-testid={next} className={cn("transition-opacity", next)} />
874
+ <span data-testid={previous} className={cn("transition-opacity", previous)} />
875
+ </div>
876
+ ))}
877
+ </div>,
878
+ );
879
+ // The test page switches transitions off; read the real durations with them on.
880
+ const restore = enableTransitions();
881
+ try {
882
+ const ms = (testId: string) => durationMs(screen.getByTestId(testId).element());
883
+ for (const [next, previous] of pairs) expect(ms(next), next).toBe(ms(previous));
884
+ expect(ms("duration-open")).toBeGreaterThan(0);
885
+ expect(ms("duration-close")).toBeLessThan(ms("duration-open"));
886
+ expect(ms("duration-panel-close")).toBeLessThan(ms("duration-panel-open"));
887
+ } finally {
888
+ restore();
889
+ }
890
+ expect(cn("duration-fast", "duration-open")).toBe("duration-open");
891
+ });
892
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dodopayments/ui",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "description": "Dodo Payments design system: accessible React components built on Base UI and Tailwind CSS v4.",
5
5
  "license": "GPL-3.0-only",
6
6
  "publishConfig": {