@datalayer/primer-addons 1.0.41 → 1.0.43

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 (43) hide show
  1. package/README.md +6 -2
  2. package/lib/components/appearance/AppearanceControls.stories.d.ts +45 -0
  3. package/lib/components/appearance/AppearanceControls.stories.js +91 -0
  4. package/lib/components/appearance/AppearanceMenu.stories.d.ts +49 -0
  5. package/lib/components/appearance/AppearanceMenu.stories.js +80 -0
  6. package/lib/components/appearance/CollaboratorPalette.stories.d.ts +34 -0
  7. package/lib/components/appearance/CollaboratorPalette.stories.js +59 -0
  8. package/lib/components/appearance/ColorModeCircle.stories.d.ts +47 -0
  9. package/lib/components/appearance/ColorModeCircle.stories.js +80 -0
  10. package/lib/components/appearance/ThemeCircle.stories.d.ts +31 -0
  11. package/lib/components/appearance/ThemeCircle.stories.js +54 -0
  12. package/lib/components/appearance/ThemePreviewCard.stories.d.ts +38 -0
  13. package/lib/components/appearance/ThemePreviewCard.stories.js +72 -0
  14. package/lib/components/box/Box.stories.d.ts +61 -0
  15. package/lib/components/box/Box.stories.js +103 -0
  16. package/lib/components/calendar-picker/CalendarPicker.stories.d.ts +53 -0
  17. package/lib/components/calendar-picker/CalendarPicker.stories.js +89 -0
  18. package/lib/components/card/Card.d.ts +40 -0
  19. package/lib/components/card/Card.js +59 -3
  20. package/lib/components/card/Card.stories.d.ts +8 -0
  21. package/lib/components/card/Card.stories.js +17 -1
  22. package/lib/components/color/ColorSwatch.stories.d.ts +26 -0
  23. package/lib/components/color/ColorSwatch.stories.js +54 -0
  24. package/lib/components/color-picker/ColorPicker.stories.d.ts +36 -0
  25. package/lib/components/color-picker/ColorPicker.stories.js +85 -0
  26. package/lib/components/date-picker/DatePicker.stories.d.ts +65 -0
  27. package/lib/components/date-picker/DatePicker.stories.js +110 -0
  28. package/lib/components/entity-avatar/EntityAvatar.stories.d.ts +47 -0
  29. package/lib/components/entity-avatar/EntityAvatar.stories.js +81 -0
  30. package/lib/components/hover-card/HoverCard.js +4 -1
  31. package/lib/components/hover-card/HoverCard.stories.d.ts +48 -0
  32. package/lib/components/hover-card/HoverCard.stories.js +98 -0
  33. package/lib/components/logo/DatalayerLogo.stories.d.ts +37 -0
  34. package/lib/components/logo/DatalayerLogo.stories.js +58 -0
  35. package/lib/components/sheet/Sheet.stories.d.ts +25 -0
  36. package/lib/components/sheet/Sheet.stories.js +32 -0
  37. package/lib/components/toolbar/Toolbar.stories.d.ts +36 -0
  38. package/lib/components/toolbar/Toolbar.stories.js +209 -0
  39. package/lib/story-helpers.d.ts +11 -0
  40. package/lib/story-helpers.js +19 -1
  41. package/lib/utils/Portals.d.ts +0 -13
  42. package/lib/utils/Portals.js +22 -0
  43. package/package.json +1 -1
@@ -0,0 +1,72 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2021-2026 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ import { useState } from "react";
7
+ import { Box } from "@primer/react";
8
+ import { ThemePreviewCard, themeVariants, } from "../..";
9
+ const meta = {
10
+ title: "Components/Appearance/ThemePreviewCard",
11
+ component: ThemePreviewCard,
12
+ tags: ["autodocs"],
13
+ parameters: {
14
+ layout: "fullscreen",
15
+ },
16
+ argTypes: {
17
+ variant: {
18
+ options: themeVariants,
19
+ control: "select",
20
+ },
21
+ colorMode: {
22
+ options: ["light", "dark", "auto"],
23
+ control: "radio",
24
+ },
25
+ },
26
+ args: {
27
+ variant: "loop",
28
+ colorMode: "light",
29
+ selected: false,
30
+ compact: false,
31
+ showDescription: true,
32
+ onSelect: (variant) => console.log("Selected:", variant),
33
+ },
34
+ };
35
+ export default meta;
36
+ const ThemedThemePreviewCard = (props) => (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(Box, { maxWidth: 320, children: _jsx(ThemePreviewCard, { ...props }) }) }));
37
+ /** One theme's miniature: its name, description and a sketch of a page in it. */
38
+ export const Default = {
39
+ render: (args) => _jsx(ThemedThemePreviewCard, { ...args }),
40
+ };
41
+ /** The chosen card, in the dark. */
42
+ export const SelectedDark = {
43
+ args: {
44
+ variant: "earth",
45
+ colorMode: "dark",
46
+ selected: true,
47
+ },
48
+ render: (args) => _jsx(ThemedThemePreviewCard, { ...args }),
49
+ };
50
+ /** Compact, without its description. */
51
+ export const Compact = {
52
+ args: {
53
+ variant: "sand",
54
+ compact: true,
55
+ showDescription: false,
56
+ },
57
+ render: (args) => _jsx(ThemedThemePreviewCard, { ...args }),
58
+ };
59
+ /** Every theme as a chooser: click one to select it. */
60
+ export const AllThemes = {
61
+ args: {
62
+ compact: true,
63
+ },
64
+ render: function AllThemesStory(args) {
65
+ const [chosen, setChosen] = useState("datalayer");
66
+ return (_jsx(Box, { p: 3, bg: "canvas.default", sx: {
67
+ display: "grid",
68
+ gridTemplateColumns: "repeat(auto-fill, minmax(200px, 1fr))",
69
+ gap: 3,
70
+ }, children: themeVariants.map((variant) => (_jsx(ThemePreviewCard, { variant: variant, colorMode: args.colorMode, compact: args.compact, showDescription: args.showDescription, selected: variant === chosen, onSelect: setChosen }, variant))) }));
71
+ },
72
+ };
@@ -0,0 +1,61 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ declare const meta: {
3
+ title: string;
4
+ component: import("react").ForwardRefExoticComponent<import("./boxCss").BoxStyleProps & {
5
+ hover?: import("./boxCss").BoxStyleProps | undefined;
6
+ focus?: import("./boxCss").BoxStyleProps | undefined;
7
+ focusVisible?: import("./boxCss").BoxStyleProps | undefined;
8
+ focusWithin?: import("./boxCss").BoxStyleProps | undefined;
9
+ active?: import("./boxCss").BoxStyleProps | undefined;
10
+ } & {
11
+ reducedMotion?: import("./boxCss").BoxStyleProps;
12
+ } & Omit<import("react").HTMLAttributes<HTMLElement>, "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "animationDelay" | "appearance" | "aspectRatio" | "backdropFilter" | "backgroundColor" | "backgroundImage" | "backgroundRepeat" | "backgroundSize" | "borderBottomColor" | "borderBottomLeftRadius" | "borderBottomRightRadius" | "borderBottomStyle" | "borderBottomWidth" | "borderCollapse" | "borderLeftColor" | "borderLeftStyle" | "borderLeftWidth" | "borderRightColor" | "borderRightStyle" | "borderRightWidth" | "borderSpacing" | "borderTopColor" | "borderTopLeftRadius" | "borderTopRightRadius" | "borderTopStyle" | "borderTopWidth" | "bottom" | "boxSizing" | "clipPath" | "color" | "columnGap" | "cursor" | "display" | "fill" | "filter" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "float" | "fontFamily" | "fontSize" | "fontStyle" | "fontVariantNumeric" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridColumnEnd" | "gridColumnStart" | "gridRowEnd" | "gridRowStart" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "isolation" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "listStylePosition" | "listStyleType" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "mixBlendMode" | "objectFit" | "objectPosition" | "opacity" | "order" | "outlineColor" | "outlineOffset" | "overflowWrap" | "overflowX" | "overflowY" | "overscrollBehaviorY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "pointerEvents" | "position" | "resize" | "right" | "rowGap" | "scrollMarginTop" | "scrollbarGutter" | "scrollbarWidth" | "stroke" | "tableLayout" | "textAlign" | "textOverflow" | "textShadow" | "textTransform" | "textUnderlineOffset" | "top" | "touchAction" | "transform" | "transformOrigin" | "userSelect" | "verticalAlign" | "visibility" | "whiteSpace" | "width" | "willChange" | "wordBreak" | "wordWrap" | "all" | "animation" | "background" | "backgroundPosition" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderStyle" | "borderTop" | "borderWidth" | "flex" | "flexFlow" | "font" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "gridTemplate" | "inset" | "listStyle" | "margin" | "outline" | "overflow" | "overscrollBehavior" | "padding" | "paddingBlock" | "paddingInline" | "placeContent" | "placeItems" | "placeSelf" | "textDecoration" | "textWrap" | "transition" | "clip" | "WebkitLineClamp" | "bg" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "p" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "size" | "gridColumnGap" | "gridGap" | "gridRowGap" | "WebkitBoxOrient" | "borderX" | "borderY" | "as"> & {
13
+ [prop: string]: unknown;
14
+ as?: import("react").ElementType;
15
+ sx?: import("./sx").BetterSystemStyleObject;
16
+ className?: string;
17
+ style?: import("react").CSSProperties;
18
+ children?: import("react").ReactNode;
19
+ } & import("react").RefAttributes<any>>;
20
+ tags: string[];
21
+ parameters: {
22
+ layout: string;
23
+ };
24
+ argTypes: {
25
+ p: {
26
+ options: number[];
27
+ control: "select";
28
+ };
29
+ bg: {
30
+ options: string[];
31
+ control: "select";
32
+ };
33
+ borderRadius: {
34
+ options: string[];
35
+ control: "select";
36
+ };
37
+ };
38
+ args: {
39
+ p: number;
40
+ bg: "accent.subtle";
41
+ color: "fg.default";
42
+ border: string;
43
+ borderColor: "border.default";
44
+ borderRadius: "card";
45
+ maxWidth: number;
46
+ };
47
+ };
48
+ export default meta;
49
+ type Story = StoryObj<typeof meta>;
50
+ /** Every value a prop on the theme's tokens: switch the theme and it redraws. */
51
+ export declare const Default: Story;
52
+ /** The Studio Home's card: the theme's hairline and large corner. */
53
+ export declare const ACard: Story;
54
+ /** Colour names are the theme's: `bg="canvas.subtle"` is `var(--bgColor-muted)`, `color="fg.muted"` is `var(--fgColor-muted)`. */
55
+ export declare const Colours: Story;
56
+ /** Corners by name: Primer's four, then the theme's shapes (rounder in `loop`). */
57
+ export declare const Corners: Story;
58
+ /** One value per breakpoint: one column on a phone, three on a desktop. */
59
+ export declare const Responsive: Story;
60
+ /** States are props too: `hover`, `focusVisible` and `reducedMotion`. */
61
+ export declare const HoverAndFocus: Story;
@@ -0,0 +1,103 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button } from "@primer/react";
3
+ import { Box } from "../..";
4
+ const meta = {
5
+ title: "Components/Box",
6
+ component: Box,
7
+ tags: ["autodocs"],
8
+ parameters: {
9
+ layout: "fullscreen",
10
+ },
11
+ argTypes: {
12
+ p: {
13
+ options: [0, 1, 2, 3, 4, 5],
14
+ control: "select",
15
+ },
16
+ bg: {
17
+ options: [
18
+ "canvas.default",
19
+ "canvas.subtle",
20
+ "accent.subtle",
21
+ "success.subtle",
22
+ "attention.subtle",
23
+ "danger.subtle",
24
+ ],
25
+ control: "select",
26
+ },
27
+ borderRadius: {
28
+ options: [
29
+ "small",
30
+ "medium",
31
+ "large",
32
+ "full",
33
+ "card",
34
+ "control",
35
+ "bubble",
36
+ "frame",
37
+ ],
38
+ control: "select",
39
+ },
40
+ },
41
+ args: {
42
+ p: 3,
43
+ bg: "accent.subtle",
44
+ color: "fg.default",
45
+ border: "1px solid",
46
+ borderColor: "border.default",
47
+ borderRadius: "card",
48
+ maxWidth: 360,
49
+ },
50
+ };
51
+ export default meta;
52
+ /** Every value a prop on the theme's tokens: switch the theme and it redraws. */
53
+ export const Default = {
54
+ render: (args) => (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(Box, { ...args, children: "A box on the theme's tokens: padding, ground, hairline, corner." }) })),
55
+ };
56
+ /** The Studio Home's card: the theme's hairline and large corner. */
57
+ export const ACard = {
58
+ args: {
59
+ as: "section",
60
+ display: "flex",
61
+ flexDirection: "column",
62
+ gap: 2,
63
+ p: 3,
64
+ bg: "canvas.default",
65
+ borderRadius: "large",
66
+ },
67
+ render: (args) => (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsxs(Box, { ...args, children: [_jsx(Box, { as: "h3", m: 0, fontSize: 3, children: "Build" }), _jsx(Box, { as: "p", m: 0, color: "fg.muted", fontSize: 1, children: "Make an agent, try it, keep it." }), _jsx(Box, { display: "flex", gap: 2, pt: 1, children: _jsx(Button, { size: "small", variant: "primary", children: "Create agent" }) })] }) })),
68
+ };
69
+ /** Colour names are the theme's: `bg="canvas.subtle"` is `var(--bgColor-muted)`, `color="fg.muted"` is `var(--fgColor-muted)`. */
70
+ export const Colours = {
71
+ render: () => (_jsx(Box, { p: 3, bg: "canvas.default", display: "flex", flexWrap: "wrap", gap: 2, children: [
72
+ ["canvas.subtle", "fg.default"],
73
+ ["accent.subtle", "accent.fg"],
74
+ ["success.subtle", "success.fg"],
75
+ ["attention.subtle", "attention.fg"],
76
+ ["danger.subtle", "danger.fg"],
77
+ ["neutral.emphasis", "fg.onEmphasis"],
78
+ ].map(([bg, color]) => (_jsx(Box, { p: 2, bg: bg, color: color, borderRadius: "medium", fontSize: 0, children: bg }, bg))) })),
79
+ };
80
+ /** Corners by name: Primer's four, then the theme's shapes (rounder in `loop`). */
81
+ export const Corners = {
82
+ render: () => (_jsx(Box, { p: 3, bg: "canvas.default", display: "flex", flexWrap: "wrap", gap: 3, children: [
83
+ "small",
84
+ "medium",
85
+ "large",
86
+ "full",
87
+ "card",
88
+ "control",
89
+ "bubble",
90
+ "frame",
91
+ ].map((radius) => (_jsx(Box, { width: 96, height: 64, display: "flex", alignItems: "center", justifyContent: "center", border: "1px solid", borderColor: "border.default", bg: "canvas.subtle", borderRadius: radius, fontSize: 0, children: radius }, radius))) })),
92
+ };
93
+ /** One value per breakpoint: one column on a phone, three on a desktop. */
94
+ export const Responsive = {
95
+ render: () => (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(Box, { display: "grid", gridTemplateColumns: ["1fr", null, "repeat(3, 1fr)"], gap: [1, null, 3], p: [2, null, 4], bg: "canvas.subtle", borderRadius: "medium", children: ["phone: one column", "tablet: still one", "desktop: three"].map((cell) => (_jsx(Box, { p: 2, bg: "canvas.default", border: "1px solid", borderColor: "border.default", borderRadius: "medium", fontSize: 0, children: cell }, cell))) }) })),
96
+ };
97
+ /** States are props too: `hover`, `focusVisible` and `reducedMotion`. */
98
+ export const HoverAndFocus = {
99
+ render: () => (_jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(Box, { as: "button", type: "button", p: 3, bg: "canvas.default", color: "fg.default", border: "1px solid", borderColor: "border.default", borderRadius: "large", cursor: "pointer", transition: "background-color 120ms ease", hover: { bg: "canvas.subtle" }, focusVisible: {
100
+ outline: "2px solid var(--focus-outlineColor)",
101
+ outlineOffset: "2px",
102
+ }, reducedMotion: { transition: "none" }, children: "Hover or focus me" }) })),
103
+ };
@@ -0,0 +1,53 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { CalendarPicker } from "../..";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof CalendarPicker;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ };
10
+ argTypes: {
11
+ value: {
12
+ control: false;
13
+ };
14
+ defaultMonth: {
15
+ control: false;
16
+ };
17
+ min: {
18
+ control: false;
19
+ };
20
+ max: {
21
+ control: false;
22
+ };
23
+ isDisabled: {
24
+ control: false;
25
+ };
26
+ weekStartsOn: {
27
+ options: number[];
28
+ control: "radio";
29
+ };
30
+ locale: {
31
+ options: string[];
32
+ control: "select";
33
+ };
34
+ };
35
+ args: {
36
+ value: Date;
37
+ weekStartsOn: 0;
38
+ locale: string;
39
+ "aria-label": string;
40
+ };
41
+ };
42
+ export default meta;
43
+ type Story = StoryObj<typeof meta>;
44
+ /** The grid alone, with no field and no popover; a week opens on Sunday. */
45
+ export declare const Default: Story;
46
+ /** A week that opens on Monday, written in French. */
47
+ export declare const MondayFirstFrench: Story;
48
+ /** From today to three months out: the days past either end cannot be picked. */
49
+ export declare const Bounded: Story;
50
+ /** Weekends are out, through `isDisabled`. */
51
+ export declare const WeekdaysOnly: Story;
52
+ /** Nothing chosen yet, opening on a given month. */
53
+ export declare const Empty: Story;
@@ -0,0 +1,89 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2021-2026 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ import { useEffect, useState } from "react";
7
+ import { Box, Text } from "@primer/react";
8
+ import { CalendarPicker } from "../..";
9
+ const today = new Date();
10
+ const meta = {
11
+ title: "Components/CalendarPicker",
12
+ component: CalendarPicker,
13
+ tags: ["autodocs"],
14
+ parameters: {
15
+ layout: "fullscreen",
16
+ },
17
+ argTypes: {
18
+ value: { control: false },
19
+ defaultMonth: { control: false },
20
+ min: { control: false },
21
+ max: { control: false },
22
+ isDisabled: { control: false },
23
+ weekStartsOn: {
24
+ options: [0, 1],
25
+ control: "radio",
26
+ },
27
+ locale: {
28
+ options: ["en-US", "en-GB", "fr-FR", "de-DE", "ja-JP"],
29
+ control: "select",
30
+ },
31
+ },
32
+ args: {
33
+ value: today,
34
+ weekStartsOn: 0,
35
+ locale: "en-US",
36
+ "aria-label": "Pick a day",
37
+ },
38
+ };
39
+ export default meta;
40
+ /** Holds the chosen day and says it under the grid. */
41
+ const ThemedCalendarPicker = (props) => {
42
+ const [date, setDate] = useState(props.value ?? null);
43
+ useEffect(() => setDate(props.value ?? null), [props.value]);
44
+ return (_jsxs(Box, { p: 3, bg: "canvas.default", children: [_jsx(Box, { sx: {
45
+ display: "inline-block",
46
+ p: 3,
47
+ border: "1px solid",
48
+ borderColor: "border.default",
49
+ borderRadius: "var(--theme-radius-card)",
50
+ }, children: _jsx(CalendarPicker, { ...props, value: date, onChange: (day) => {
51
+ setDate(day);
52
+ props.onChange?.(day);
53
+ } }) }), _jsx(Text, { as: "p", sx: { mt: 2, fontSize: 1 }, children: date ? date.toDateString() : "Nothing chosen" })] }));
54
+ };
55
+ /** The grid alone, with no field and no popover; a week opens on Sunday. */
56
+ export const Default = {
57
+ render: (args) => _jsx(ThemedCalendarPicker, { ...args }),
58
+ };
59
+ /** A week that opens on Monday, written in French. */
60
+ export const MondayFirstFrench = {
61
+ args: {
62
+ weekStartsOn: 1,
63
+ locale: "fr-FR",
64
+ },
65
+ render: (args) => _jsx(ThemedCalendarPicker, { ...args }),
66
+ };
67
+ /** From today to three months out: the days past either end cannot be picked. */
68
+ export const Bounded = {
69
+ args: {
70
+ min: today,
71
+ max: new Date(today.getFullYear(), today.getMonth() + 3, 0),
72
+ },
73
+ render: (args) => _jsx(ThemedCalendarPicker, { ...args }),
74
+ };
75
+ /** Weekends are out, through `isDisabled`. */
76
+ export const WeekdaysOnly = {
77
+ args: {
78
+ isDisabled: (date) => date.getDay() === 0 || date.getDay() === 6,
79
+ },
80
+ render: (args) => _jsx(ThemedCalendarPicker, { ...args }),
81
+ };
82
+ /** Nothing chosen yet, opening on a given month. */
83
+ export const Empty = {
84
+ args: {
85
+ value: null,
86
+ defaultMonth: new Date(today.getFullYear(), 11, 1),
87
+ },
88
+ render: (args) => _jsx(ThemedCalendarPicker, { ...args }),
89
+ };
@@ -29,6 +29,16 @@
29
29
  * - `selected` — the card that is chosen among others: an accent border on
30
30
  * an accent wash. It says nothing to assistive technology by itself: the
31
31
  * caller sets `aria-pressed` or `aria-selected`, as its role requires.
32
+ * - `hoverEffect="lift"` — the landing pages' card (Earth Observation,
33
+ * Integrations): on hover, or when it or something in it has the
34
+ * keyboard's focus, it rises 3px onto `shadow.large`, its hairline turns
35
+ * `border.muted`, a light of `accent.fg` is drawn along its top edge, and
36
+ * its `Card.Icon` (or any element marked `data-card-icon`) grows 6% and
37
+ * tilts 3°. 260ms on {@link CARD_EASE}, the icon 320ms. For the reader
38
+ * who asked for less motion nothing moves: the shadow, the hairline and
39
+ * the light still change.
40
+ * - `Card.Icon` — a glyph in a tinted, rounded square: the icon the lift
41
+ * moves.
32
42
  */
33
43
  import React from "react";
34
44
  import { type BoxColorToken, type BoxProps, type BoxPseudoProps, type BoxRadiusToken, type BoxStyleProps } from "../box/Box";
@@ -88,6 +98,28 @@ export type CardProps = CardBoxProps & {
88
98
  * such as an item's own colour.
89
99
  */
90
100
  accent?: BoxColorToken | (string & {});
101
+ /**
102
+ * What the card does when the pointer is over it or the keyboard is in
103
+ * it: nothing by default (or `none`); `lift` rises onto a larger shadow,
104
+ * draws a light along the top edge and moves its `Card.Icon`. The card
105
+ * keeps its hairline, and is `position: relative` and `overflow: hidden`
106
+ * (the light follows the corner); props win over both. Off while
107
+ * `disabled`. `sx` merges over the effect's keys, one key at a time.
108
+ */
109
+ hoverEffect?: CardHoverEffect;
110
+ };
111
+ /** What a card does under the pointer and the keyboard; see {@link CardProps.hoverEffect}. */
112
+ export type CardHoverEffect = 'none' | 'lift';
113
+ /** The glyph a card wears, in a tinted rounded square; `lift` moves it. */
114
+ export type CardIconProps = CardBoxProps & {
115
+ /** An octicon, or any component that takes `size`. */
116
+ icon: React.ElementType;
117
+ /** The glyph's colour, a theme token. `accent.fg` by default. */
118
+ color?: BoxColorToken | (string & {});
119
+ /** The square's ground, a theme token. `accent.subtle` by default. */
120
+ bg?: BoxColorToken | (string & {});
121
+ /** The square's side, in pixels; 46 by default. The glyph is about half of it. */
122
+ size?: number;
91
123
  };
92
124
  export type CardHeaderProps = {
93
125
  /**
@@ -139,6 +171,13 @@ export type CardCoverProps = CardBoxProps & {
139
171
  export type CardActionsProps = {
140
172
  children: React.ReactNode;
141
173
  };
174
+ /**
175
+ * The easing of the `lift` effect, the landing pages' own: quick out, a
176
+ * long settle, so the card arrives rather than bounces.
177
+ */
178
+ export declare const CARD_EASE = "cubic-bezier(0.22, 1, 0.36, 1)";
179
+ /** The attribute the `lift` effect moves: `Card.Icon` wears it. */
180
+ export declare const CARD_ICON_ATTRIBUTE = "data-card-icon";
142
181
  export declare const Card: React.FC<CardProps> & {
143
182
  Header: React.FC<CardHeaderProps>;
144
183
  Cover: React.FC<CardCoverProps>;
@@ -146,5 +185,6 @@ export declare const Card: React.FC<CardProps> & {
146
185
  Content: React.FC<CardContentProps>;
147
186
  Footer: React.FC<CardFooterProps>;
148
187
  Actions: React.FC<CardActionsProps>;
188
+ Icon: React.FC<CardIconProps>;
149
189
  };
150
190
  export {};
@@ -32,6 +32,55 @@ const INTERACTIVE = {
32
32
  focusVisible: { outline: '2px solid', outlineColor: 'accent.emphasis', outlineOffset: '2px' },
33
33
  reducedMotion: { transition: 'none' },
34
34
  };
35
+ /**
36
+ * The easing of the `lift` effect, the landing pages' own: quick out, a
37
+ * long settle, so the card arrives rather than bounces.
38
+ */
39
+ export const CARD_EASE = 'cubic-bezier(0.22, 1, 0.36, 1)';
40
+ /** The attribute the `lift` effect moves: `Card.Icon` wears it. */
41
+ export const CARD_ICON_ATTRIBUTE = 'data-card-icon';
42
+ const ICON = `[${CARD_ICON_ATTRIBUTE}]`;
43
+ /**
44
+ * The states that lift a card: the pointer over it, the keyboard on it, the
45
+ * keyboard on something in it. Each its own rule, so a browser that cannot
46
+ * read `:has()` drops that one and keeps the others.
47
+ */
48
+ const LIFT_STATES = ['&:hover', '&:focus-visible', '&:has(:focus-visible)'];
49
+ /** The `lift` effect, as `sx`: the card, its top-edge light, its icon. */
50
+ function liftSx(hoverBorderColor) {
51
+ const lifted = { boxShadow: 'shadow.large', transform: 'translateY(-3px)', borderColor: hoverBorderColor };
52
+ const sx = {
53
+ transition: `box-shadow 260ms ${CARD_EASE}, transform 260ms ${CARD_EASE}, border-color 260ms ${CARD_EASE}`,
54
+ // The light along the top edge: the card acknowledges the pointer
55
+ // without moving anything the eye is trying to read.
56
+ '&::after': {
57
+ content: '""',
58
+ position: 'absolute',
59
+ top: 0,
60
+ left: 0,
61
+ right: 0,
62
+ height: '2px',
63
+ background: 'linear-gradient(90deg, transparent, var(--fgColor-accent), transparent)',
64
+ opacity: 0,
65
+ pointerEvents: 'none',
66
+ transition: `opacity 260ms ${CARD_EASE}`,
67
+ },
68
+ };
69
+ const still = {
70
+ // The shadow, the hairline and the light still change; nothing moves.
71
+ transition: `box-shadow 260ms ${CARD_EASE}, border-color 260ms ${CARD_EASE}`,
72
+ [`& ${ICON}`]: { transition: 'none' },
73
+ };
74
+ for (const state of LIFT_STATES) {
75
+ sx[state] = lifted;
76
+ sx[`${state}::after`] = { opacity: 1 };
77
+ sx[`${state} ${ICON}`] = { transform: 'scale(1.06) rotate(-3deg)' };
78
+ still[state] = { transform: 'none' };
79
+ still[`${state} ${ICON}`] = { transform: 'none' };
80
+ }
81
+ sx['@media (prefers-reduced-motion: reduce)'] = still;
82
+ return sx;
83
+ }
35
84
  /** What `disabled` takes away: the pointer and the hover, at a lower voice. */
36
85
  const DISABLED = {
37
86
  cursor: 'not-allowed',
@@ -39,9 +88,13 @@ const DISABLED = {
39
88
  hover: {},
40
89
  };
41
90
  export const Card = (props) => {
42
- const { rounded, border, shadow = 'small', variant = 'default', interactive, selected, dashed, disabled, accent, children, ...otherProps } = props;
43
- const outlined = border || interactive || selected || dashed;
91
+ const { rounded, border, shadow = 'small', variant = 'default', interactive, selected, dashed, disabled, accent, hoverEffect, sx, children, ...otherProps } = props;
92
+ const lift = hoverEffect === 'lift' && !disabled;
93
+ const outlined = border || interactive || selected || dashed || lift;
44
94
  const flavour = VARIANTS[variant];
95
+ // An interactive card's hover hairline is the accent, lifted or not.
96
+ const effectSx = lift ? liftSx(interactive ? 'accent.emphasis' : 'border.muted') : undefined;
97
+ const mergedSx = effectSx ? { ...effectSx, ...sx } : sx;
45
98
  return (_jsx(Box
46
99
  // A column, so the actions stand at the bottom however long the text
47
100
  // above them: cards side by side end on one line.
@@ -51,7 +104,7 @@ export const Card = (props) => {
51
104
  display: "flex", flexDirection: "column", bg: selected ? 'accent.subtle' : flavour.bg, color: "fg.default", borderRadius: rounded ?? CARD_RADIUS, boxShadow: SHADOWS[shadow], ...(outlined ? {
52
105
  border: '1px solid',
53
106
  borderColor: selected ? 'accent.emphasis' : flavour.borderColor,
54
- } : undefined), ...(dashed ? { borderStyle: 'dashed' } : undefined), ...(accent ? { borderTop: '3px solid', borderTopColor: accent } : undefined), ...(interactive ? INTERACTIVE : undefined), ...(disabled ? DISABLED : undefined), ...(interactive && disabled ? { 'aria-disabled': true } : undefined), ...otherProps, children: children }));
107
+ } : undefined), ...(dashed ? { borderStyle: 'dashed' } : undefined), ...(accent ? { borderTop: '3px solid', borderTopColor: accent } : undefined), ...(interactive ? INTERACTIVE : undefined), ...(disabled ? DISABLED : undefined), ...(interactive && disabled ? { 'aria-disabled': true } : undefined), ...(lift ? { position: 'relative', overflow: 'hidden' } : undefined), ...otherProps, sx: mergedSx, children: children }));
55
108
  };
56
109
  Card.Header = (props) => {
57
110
  const { title, description, leadingVisual, action } = props;
@@ -71,6 +124,9 @@ Card.Content = ({ children, ...rest }) => {
71
124
  Card.Footer = ({ children, ...rest }) => {
72
125
  return (_jsx(Box, { display: "flex", alignItems: "center", gap: 2, flexWrap: "wrap", mt: "auto", px: 3, py: 2, borderTop: "1px solid", borderColor: "border.muted", ...rest, children: children }));
73
126
  };
127
+ Card.Icon = ({ icon: Icon, color = 'accent.fg', bg = 'accent.subtle', size = 46, ...rest }) => {
128
+ return (_jsx(Box, { [CARD_ICON_ATTRIBUTE]: '', display: "inline-flex", alignItems: "center", justifyContent: "center", flexShrink: 0, width: size, height: size, borderRadius: `${Math.round(size * 13 / 46)}px`, color: color, bg: bg, mb: 3, boxShadow: "inset 0 0 0 1px currentColor", transition: `transform 320ms ${CARD_EASE}`, ...rest, children: _jsx(Icon, { size: Math.round(size * 22 / 46), fill: "currentColor" }) }));
129
+ };
74
130
  Card.Actions = ({ children }) => {
75
131
  return _jsx(Box, { display: "block", p: 3, mt: "auto", children: children });
76
132
  };
@@ -9,6 +9,7 @@ declare const meta: {
9
9
  Content: React.FC<import("./Card").CardContentProps>;
10
10
  Footer: React.FC<import("./Card").CardFooterProps>;
11
11
  Actions: React.FC<import("./Card").CardActionsProps>;
12
+ Icon: React.FC<import("./Card").CardIconProps>;
12
13
  };
13
14
  tags: string[];
14
15
  parameters: {
@@ -24,3 +25,10 @@ export declare const CardNight: Story;
24
25
  export declare const CardInteractive: Story;
25
26
  /** The chosen card among others: an accent border on an accent wash. */
26
27
  export declare const CardSelected: Story;
28
+ /**
29
+ * The landing pages' card (Earth Observation, Integrations): it rises, its
30
+ * hairline and shadow change, a light runs along its top edge and its icon
31
+ * tilts — on hover and on keyboard focus. Nothing moves under
32
+ * `prefers-reduced-motion: reduce`.
33
+ */
34
+ export declare const CardLift: Story;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Button, IconButton, Text, ButtonGroup } from "@primer/react";
3
- import { ProjectIcon, ThreeBarsIcon } from '@primer/octicons-react';
3
+ import { GlobeIcon, ProjectIcon, ThreeBarsIcon } from '@primer/octicons-react';
4
4
  import { Card } from '../..';
5
5
  const meta = {
6
6
  title: 'Components/Card',
@@ -75,3 +75,19 @@ export const CardSelected = {
75
75
  },
76
76
  render: (args) => _jsxs(ThemedCard, { ...args, children: [_jsx(Text, { display: "block", fontWeight: "bold", children: "Selected example" }), _jsx(Text, { color: "fg.muted", children: "The one picked among its siblings." })] })
77
77
  };
78
+ /**
79
+ * The landing pages' card (Earth Observation, Integrations): it rises, its
80
+ * hairline and shadow change, a light runs along its top edge and its icon
81
+ * tilts — on hover and on keyboard focus. Nothing moves under
82
+ * `prefers-reduced-motion: reduce`.
83
+ */
84
+ export const CardLift = {
85
+ args: {
86
+ hoverEffect: "lift",
87
+ shadow: "none",
88
+ tabIndex: 0,
89
+ p: 4,
90
+ sx: { maxWidth: 360 },
91
+ },
92
+ render: (args) => _jsxs(ThemedCard, { ...args, children: [_jsx(Card.Icon, { icon: GlobeIcon, color: "done.fg", bg: "done.subtle" }), _jsx(Text, { display: "block", fontWeight: "bold", children: "Satellite sources" }), _jsx(Text, { color: "fg.muted", children: "Sentinel, Landsat and commercial constellations, read where they are." })] })
93
+ };
@@ -0,0 +1,26 @@
1
+ import type { StoryObj } from "@storybook/react";
2
+ import { ColorSwatch } from "../..";
3
+ declare const meta: {
4
+ title: string;
5
+ component: typeof ColorSwatch;
6
+ tags: string[];
7
+ parameters: {
8
+ layout: string;
9
+ };
10
+ args: {
11
+ color: string;
12
+ label: string;
13
+ showValue: true;
14
+ height: number;
15
+ };
16
+ };
17
+ export default meta;
18
+ type Story = StoryObj<typeof meta>;
19
+ /** A theme variable: the value under it is read from the page, so it follows the theme. */
20
+ export declare const ThemeToken: Story;
21
+ /** A fixed colour, shorter. */
22
+ export declare const FixedColour: Story;
23
+ /** Without its value. */
24
+ export declare const WithoutValue: Story;
25
+ /** The theme's emphasis colours in a row. */
26
+ export declare const Palette: Story;