@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.
- package/ai/component-registry.json +152 -9
- package/ai/component-registry.md +1 -1
- package/ai/components/avatar.md +3 -0
- package/ai/components/data-grid.md +1 -1
- package/ai/components/list-toolbar.md +3 -1
- package/ai/components/page-header.md +13 -11
- package/ai/components/payment-logos.md +5 -4
- package/ai/components/segmented-control.md +14 -1
- package/ai/components/sidebar.md +13 -2
- package/ai/components/spinner.md +2 -0
- package/ai/skills/dodo-design/SKILL.md +11 -6
- package/dist/components/app-top-bar/app-top-bar.d.ts.map +1 -1
- package/dist/components/app-top-bar/app-top-bar.js +12 -7
- package/dist/components/app-top-bar/app-top-bar.js.map +1 -1
- package/dist/components/avatar/avatar.d.ts +22 -1
- package/dist/components/avatar/avatar.d.ts.map +1 -1
- package/dist/components/avatar/avatar.js +13 -3
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/data-grid/data-grid.d.ts +1 -1
- package/dist/components/data-grid/data-grid.js +2 -2
- package/dist/components/data-grid/data-grid.js.map +1 -1
- package/dist/components/list-toolbar/list-toolbar.d.ts +3 -1
- package/dist/components/list-toolbar/list-toolbar.d.ts.map +1 -1
- package/dist/components/list-toolbar/list-toolbar.js +13 -2
- package/dist/components/list-toolbar/list-toolbar.js.map +1 -1
- package/dist/components/page-header/page-header.d.ts +11 -7
- package/dist/components/page-header/page-header.d.ts.map +1 -1
- package/dist/components/page-header/page-header.js +34 -11
- package/dist/components/page-header/page-header.js.map +1 -1
- package/dist/components/payment-logos/payment-logos.d.ts +8 -3
- package/dist/components/payment-logos/payment-logos.d.ts.map +1 -1
- package/dist/components/payment-logos/payment-logos.js +5 -5
- package/dist/components/payment-logos/payment-logos.js.map +1 -1
- package/dist/components/radio-group/radio-group.d.ts +2 -2
- package/dist/components/radio-group/radio-group.js +5 -5
- package/dist/components/radio-group/radio-group.js.map +1 -1
- package/dist/components/segmented-control/index.d.ts +1 -1
- package/dist/components/segmented-control/index.d.ts.map +1 -1
- package/dist/components/segmented-control/index.js +1 -1
- package/dist/components/segmented-control/index.js.map +1 -1
- package/dist/components/segmented-control/segmented-control.d.ts +19 -0
- package/dist/components/segmented-control/segmented-control.d.ts.map +1 -1
- package/dist/components/segmented-control/segmented-control.js +28 -7
- package/dist/components/segmented-control/segmented-control.js.map +1 -1
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/select/select.js +8 -2
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/sidebar/index.d.ts +1 -1
- package/dist/components/sidebar/index.d.ts.map +1 -1
- package/dist/components/sidebar/index.js +1 -1
- package/dist/components/sidebar/index.js.map +1 -1
- package/dist/components/sidebar/sidebar.d.ts +22 -3
- package/dist/components/sidebar/sidebar.d.ts.map +1 -1
- package/dist/components/sidebar/sidebar.js +28 -12
- package/dist/components/sidebar/sidebar.js.map +1 -1
- package/dist/components/spinner/spinner.d.ts +12 -1
- package/dist/components/spinner/spinner.d.ts.map +1 -1
- package/dist/components/spinner/spinner.js +2 -2
- package/dist/components/spinner/spinner.js.map +1 -1
- package/dist/lib/cn-tables.js +5 -5
- package/dist/lib/cn-tables.js.map +1 -1
- package/dist/primitives/lib/segmented-control.js +2 -2
- package/dist/primitives/lib/segmented-control.js.map +1 -1
- package/dist/primitives/ui/dialog.d.ts.map +1 -1
- package/dist/primitives/ui/dialog.js +4 -2
- package/dist/primitives/ui/dialog.js.map +1 -1
- package/dist/primitives/ui/sheet.js +4 -4
- package/dist/primitives/ui/sheet.js.map +1 -1
- package/dist/primitives/ui/sidebar.js +2 -2
- package/dist/primitives/ui/sidebar.js.map +1 -1
- package/dist/primitives/ui/switch.d.ts +2 -2
- package/dist/primitives/ui/switch.d.ts.map +1 -1
- package/dist/primitives/ui/switch.js +2 -2
- package/dist/primitives/ui/switch.js.map +1 -1
- package/dist/primitives/ui/table.js +4 -4
- package/dist/primitives/ui/table.js.map +1 -1
- package/dist/styles/theme.css +67 -0
- package/dist/styles/tokens.css +97 -67
- package/dist/styles/tokens.test.tsx +147 -0
- 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