@domicile-desktop/component-library 1.0.0 → 2.1.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/package.json +7 -6
- package/src/AnimatedBellIcon/AnimatedBellIcon.tsx +1 -1
- package/src/AnimatedSparkleIcon/AnimatedSparkleIcon.tsx +64 -0
- package/src/ContextMenu/ContextMenu.tsx +1 -34
- package/src/ContextMenu/menu-popup.ts +37 -0
- package/src/FluidItem/FluidItem.tsx +15 -2
- package/src/ListRow/ListRow.tsx +88 -41
- package/src/Menu/Menu.tsx +44 -0
- package/src/PanelHeader/PanelHeader.tsx +29 -6
- package/src/Popover/Popover.tsx +4 -1
- package/src/_icon/icon-keyframes.ts +13 -0
- package/src/_icon/phosphor-parts.ts +11 -1
- package/styled-system/patterns/aspect-ratio.mjs +2 -2
- package/styled-system/patterns/bleed.mjs +1 -2
- package/styled-system/patterns/float.mjs +5 -11
- package/styled-system/patterns/grid-item.mjs +1 -2
- package/styled-system/patterns/grid.mjs +1 -2
- package/styled-system/patterns/link-overlay.mjs +1 -1
- package/styled-system/patterns/spacer.mjs +3 -3
- package/styled-system/patterns/visually-hidden.mjs +1 -1
- package/styled-system/styles.css +2021 -1939
- package/styled-system/types/prop-type.d.ts +1 -1
package/package.json
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
"dependencies": {
|
|
3
3
|
"@base-ui/react": "^1.8.0",
|
|
4
4
|
"@cprussin/option-result": "^2.0.1",
|
|
5
|
-
"@domicile-desktop/sdk": "
|
|
6
|
-
"@domicile-desktop/system-apps": "1.
|
|
5
|
+
"@domicile-desktop/sdk": "2.2.0",
|
|
6
|
+
"@domicile-desktop/system-apps": "1.2.0",
|
|
7
7
|
"@pandacss/dev": "^1.12.1",
|
|
8
8
|
"@phosphor-icons/react": "^2.1.10"
|
|
9
9
|
},
|
|
10
10
|
"description": "React components and the Panda CSS design system that Domicile's shells are built from.",
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@cprussin/tsconfig": "^5.0.0",
|
|
13
|
-
"@domicile-desktop/test-support": "0.0.
|
|
13
|
+
"@domicile-desktop/test-support": "0.0.2",
|
|
14
14
|
"@pandacss/preset-panda": "^1.12.1",
|
|
15
15
|
"@storybook/addon-docs": "^10.6.0",
|
|
16
16
|
"@storybook/addon-themes": "^10.6.0",
|
|
@@ -29,8 +29,7 @@
|
|
|
29
29
|
"vite": "^8.2.2"
|
|
30
30
|
},
|
|
31
31
|
"engines": {
|
|
32
|
-
"bun": ">=1.4.2"
|
|
33
|
-
"node": ">=24"
|
|
32
|
+
"bun": ">=1.4.2"
|
|
34
33
|
},
|
|
35
34
|
"exports": {
|
|
36
35
|
"./Accordion": "./src/Accordion/Accordion.tsx",
|
|
@@ -54,6 +53,7 @@
|
|
|
54
53
|
"./AnimatedPlusIcon": "./src/AnimatedPlusIcon/AnimatedPlusIcon.tsx",
|
|
55
54
|
"./AnimatedReloadIcon": "./src/AnimatedReloadIcon/AnimatedReloadIcon.tsx",
|
|
56
55
|
"./AnimatedSlidersIcon": "./src/AnimatedSlidersIcon/AnimatedSlidersIcon.tsx",
|
|
56
|
+
"./AnimatedSparkleIcon": "./src/AnimatedSparkleIcon/AnimatedSparkleIcon.tsx",
|
|
57
57
|
"./AnimatedSpeakerIcon": "./src/AnimatedSpeakerIcon/AnimatedSpeakerIcon.tsx",
|
|
58
58
|
"./AnimatedSquaresIcon": "./src/AnimatedSquaresIcon/AnimatedSquaresIcon.tsx",
|
|
59
59
|
"./AnimatedThemeIcon": "./src/AnimatedThemeIcon/AnimatedThemeIcon.tsx",
|
|
@@ -91,6 +91,7 @@
|
|
|
91
91
|
"./leaving-rows": "./src/LeavingRows/leaving-rows.ts",
|
|
92
92
|
"./list-walk": "./src/list-walk.ts",
|
|
93
93
|
"./Marked": "./src/ResultList/Marked.tsx",
|
|
94
|
+
"./Menu": "./src/Menu/Menu.tsx",
|
|
94
95
|
"./ModalDialog": "./src/ModalDialog/ModalDialog.tsx",
|
|
95
96
|
"./media-theme-source": "./src/ThemeSwitch/media-theme-source.ts",
|
|
96
97
|
"./Notice": "./src/Notice/Notice.tsx",
|
|
@@ -165,5 +166,5 @@
|
|
|
165
166
|
"test:unit": "bun test"
|
|
166
167
|
},
|
|
167
168
|
"type": "module",
|
|
168
|
-
"version": "1.0
|
|
169
|
+
"version": "2.1.0"
|
|
169
170
|
}
|
|
@@ -13,7 +13,7 @@ type Props = {
|
|
|
13
13
|
cue?: unknown;
|
|
14
14
|
/** Names the icon; without one it is decorative. */
|
|
15
15
|
label?: string | undefined;
|
|
16
|
-
/** Strikes the bell through, such as while
|
|
16
|
+
/** Strikes the bell through, such as while notifications are paused. */
|
|
17
17
|
off?: boolean | undefined;
|
|
18
18
|
size: number;
|
|
19
19
|
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { css } from "../../styled-system/css";
|
|
2
|
+
import { IconFrame } from "../_icon/IconFrame";
|
|
3
|
+
import { IconPart } from "../_icon/IconPart";
|
|
4
|
+
import { SPARKLE_REGULAR } from "../_icon/phosphor-parts";
|
|
5
|
+
import "../stylesheet";
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
/** Names the icon; without one it is decorative. */
|
|
9
|
+
label?: string | undefined;
|
|
10
|
+
size: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Phosphor's regular `Sparkle`. While the control it is in is pointed at, its
|
|
15
|
+
* star twists a quarter turn and its glints wink out and back one after the
|
|
16
|
+
* other; pressed, the star shrinks a little.
|
|
17
|
+
*/
|
|
18
|
+
export const AnimatedSparkleIcon = ({ label, size }: Props) => (
|
|
19
|
+
<IconFrame label={label} size={size}>
|
|
20
|
+
<IconPart
|
|
21
|
+
d={SPARKLE_REGULAR.star}
|
|
22
|
+
hoverStyles={twinkleStyles}
|
|
23
|
+
name="star"
|
|
24
|
+
origin={STAR}
|
|
25
|
+
stateStyles={pressStyles}
|
|
26
|
+
/>
|
|
27
|
+
{SPARKLE_REGULAR.glints.map((d, index) => (
|
|
28
|
+
<IconPart
|
|
29
|
+
d={d}
|
|
30
|
+
hoverStyles={winkStyles}
|
|
31
|
+
key={d}
|
|
32
|
+
name="glint"
|
|
33
|
+
order={index}
|
|
34
|
+
origin={GLINTS[index]}
|
|
35
|
+
/>
|
|
36
|
+
))}
|
|
37
|
+
</IconFrame>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
/** The middle of each part, on the 256-unit grid. */
|
|
41
|
+
const STAR = [112, 144] as const;
|
|
42
|
+
const GLINTS = [
|
|
43
|
+
[176, 40],
|
|
44
|
+
[224, 88],
|
|
45
|
+
] as const;
|
|
46
|
+
|
|
47
|
+
const twinkleStyles = css({
|
|
48
|
+
_controlHover: {
|
|
49
|
+
animation: "iconSparkleTwinkle {durations.slowest} {easings.in-out}",
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// After the star starts, one glint after the other.
|
|
54
|
+
const winkStyles = css({
|
|
55
|
+
_controlHover: {
|
|
56
|
+
animation:
|
|
57
|
+
"iconSparkleWink {durations.slow} {easings.out} calc((var(--part-order) + 1) * {durations.fast})",
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
const pressStyles = css({
|
|
62
|
+
_controlActive: { transform: "scale(0.85)" },
|
|
63
|
+
transition: "transform {durations.fast} {easings.out}",
|
|
64
|
+
});
|
|
@@ -9,6 +9,7 @@ import { useMemo } from "react";
|
|
|
9
9
|
import { css } from "../../styled-system/css";
|
|
10
10
|
import type { ExtendProps } from "../extend-props";
|
|
11
11
|
import { usePopupBoundary } from "../PopupBoundary/PopupBoundary";
|
|
12
|
+
import { popupStyles, positionerStyles } from "./menu-popup";
|
|
12
13
|
import "../stylesheet";
|
|
13
14
|
|
|
14
15
|
/** A point in the viewport, in CSS pixels. */
|
|
@@ -248,40 +249,6 @@ export const ContextMenu = Object.assign(ContextMenuComponent, {
|
|
|
248
249
|
Submenu,
|
|
249
250
|
});
|
|
250
251
|
|
|
251
|
-
const positionerStyles = css({
|
|
252
|
-
outlineStyle: "none",
|
|
253
|
-
zIndex: "modal",
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
// `&[data-starting-style]` rather than Panda's `_starting`: `@starting-style`
|
|
257
|
-
// does not reliably fire for a portaled popup. See `Popover`.
|
|
258
|
-
const popupStyles = css({
|
|
259
|
-
"&:has([data-item-icon]:not(:empty)) [data-item-icon]": {
|
|
260
|
-
display: "inline-flex",
|
|
261
|
-
},
|
|
262
|
-
"&[data-ending-style]": {
|
|
263
|
-
opacity: 0,
|
|
264
|
-
transition: "opacity {durations.fast} {easings.in}",
|
|
265
|
-
},
|
|
266
|
-
"&[data-starting-style]": {
|
|
267
|
-
opacity: 0,
|
|
268
|
-
},
|
|
269
|
-
backgroundColor: "card",
|
|
270
|
-
border: "1px solid {colors.border}",
|
|
271
|
-
borderRadius: "md",
|
|
272
|
-
boxShadow: "lifted",
|
|
273
|
-
color: "foreground",
|
|
274
|
-
display: "flex",
|
|
275
|
-
flexDirection: "column",
|
|
276
|
-
maxBlockSize: "var(--available-height)",
|
|
277
|
-
minInlineSize: "{spacing.56}",
|
|
278
|
-
opacity: 1,
|
|
279
|
-
outlineStyle: "none",
|
|
280
|
-
overflowY: "auto",
|
|
281
|
-
paddingBlock: 1,
|
|
282
|
-
transition: "opacity {durations.fast} {easings.out}",
|
|
283
|
-
});
|
|
284
|
-
|
|
285
252
|
// `Select`'s item. Its end holds a shortcut, check, dot or caret.
|
|
286
253
|
const itemStyles = css({
|
|
287
254
|
"&[data-disabled]": {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// The popup shared by `ContextMenu` and `Menu`.
|
|
2
|
+
|
|
3
|
+
import { css } from "../../styled-system/css";
|
|
4
|
+
|
|
5
|
+
export const positionerStyles = css({
|
|
6
|
+
outlineStyle: "none",
|
|
7
|
+
zIndex: "modal",
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// `&[data-starting-style]` rather than Panda's `_starting`: `@starting-style`
|
|
11
|
+
// does not reliably fire for a portaled popup. See `Popover`.
|
|
12
|
+
export const popupStyles = css({
|
|
13
|
+
"&:has([data-item-icon]:not(:empty)) [data-item-icon]": {
|
|
14
|
+
display: "inline-flex",
|
|
15
|
+
},
|
|
16
|
+
"&[data-ending-style]": {
|
|
17
|
+
opacity: 0,
|
|
18
|
+
transition: "opacity {durations.fast} {easings.in}",
|
|
19
|
+
},
|
|
20
|
+
"&[data-starting-style]": {
|
|
21
|
+
opacity: 0,
|
|
22
|
+
},
|
|
23
|
+
backgroundColor: "card",
|
|
24
|
+
border: "1px solid {colors.border}",
|
|
25
|
+
borderRadius: "md",
|
|
26
|
+
boxShadow: "lifted",
|
|
27
|
+
color: "foreground",
|
|
28
|
+
display: "flex",
|
|
29
|
+
flexDirection: "column",
|
|
30
|
+
maxBlockSize: "var(--available-height)",
|
|
31
|
+
minInlineSize: "{spacing.56}",
|
|
32
|
+
opacity: 1,
|
|
33
|
+
outlineStyle: "none",
|
|
34
|
+
overflowY: "auto",
|
|
35
|
+
paddingBlock: 1,
|
|
36
|
+
transition: "opacity {durations.fast} {easings.out}",
|
|
37
|
+
});
|
|
@@ -30,11 +30,20 @@ type Props = {
|
|
|
30
30
|
gap?: Gap | undefined;
|
|
31
31
|
/** Injectable for tests; defaults to a `ResizeObserver`. */
|
|
32
32
|
observeWidth?: ObserveWidth | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Whether its content shows past the eased width: `visible` for an item
|
|
35
|
+
* with open space beside it, whose own motion would otherwise be cut off
|
|
36
|
+
* while it resizes.
|
|
37
|
+
*/
|
|
38
|
+
overflow?: Overflow | undefined;
|
|
33
39
|
};
|
|
34
40
|
|
|
35
41
|
/** The edges a `FluidItem` can keep still. */
|
|
36
42
|
export type Anchor = "start" | "end";
|
|
37
43
|
|
|
44
|
+
/** What a `FluidItem` does with content past its eased width. */
|
|
45
|
+
export type Overflow = "clip" | "visible";
|
|
46
|
+
|
|
38
47
|
/** The gaps a row of `FluidItem`s can have. */
|
|
39
48
|
export type Gap = "none" | "narrow" | "wide";
|
|
40
49
|
|
|
@@ -52,6 +61,7 @@ export const FluidItem = ({
|
|
|
52
61
|
children,
|
|
53
62
|
gap = "none",
|
|
54
63
|
observeWidth = resizeObserverWidth,
|
|
64
|
+
overflow = "clip",
|
|
55
65
|
}: Props) => {
|
|
56
66
|
const slot = useRef<HTMLSpanElement>(null);
|
|
57
67
|
const content = useRef<HTMLSpanElement>(null);
|
|
@@ -108,7 +118,7 @@ export const FluidItem = ({
|
|
|
108
118
|
|
|
109
119
|
return (
|
|
110
120
|
<span
|
|
111
|
-
className={slotStyles({ anchor })}
|
|
121
|
+
className={slotStyles({ anchor, overflow })}
|
|
112
122
|
onTransitionEnd={(event) => {
|
|
113
123
|
// It has faded out, so what left can go.
|
|
114
124
|
if (
|
|
@@ -141,7 +151,6 @@ const slotStyles = cva({
|
|
|
141
151
|
flexShrink: 0,
|
|
142
152
|
inlineSize: "var(--fluid-width, auto)",
|
|
143
153
|
opacity: 1,
|
|
144
|
-
overflowX: "clip",
|
|
145
154
|
transition:
|
|
146
155
|
"inline-size {durations.normal} {easings.in-out}, opacity {durations.normal} {easings.default}",
|
|
147
156
|
},
|
|
@@ -150,6 +159,10 @@ const slotStyles = cva({
|
|
|
150
159
|
end: { justifyContent: "flex-end" },
|
|
151
160
|
start: {},
|
|
152
161
|
},
|
|
162
|
+
overflow: {
|
|
163
|
+
clip: { overflowX: "clip" },
|
|
164
|
+
visible: { overflowX: "visible" },
|
|
165
|
+
},
|
|
153
166
|
},
|
|
154
167
|
});
|
|
155
168
|
|
package/src/ListRow/ListRow.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Collapsible } from "@base-ui/react/collapsible";
|
|
1
2
|
import { CaretDownIcon } from "@phosphor-icons/react/dist/ssr/CaretDown";
|
|
2
3
|
import type { ReactNode } from "react";
|
|
3
|
-
import { Children
|
|
4
|
+
import { Children } from "react";
|
|
4
5
|
|
|
5
6
|
import { css, cva } from "../../styled-system/css";
|
|
6
7
|
import { flex } from "../../styled-system/patterns";
|
|
@@ -19,7 +20,7 @@ type Common = {
|
|
|
19
20
|
detail?: ReactNode | undefined;
|
|
20
21
|
/**
|
|
21
22
|
* Folds `children` behind a toggle at the row's end, named this, such as
|
|
22
|
-
* "Details" for a connection's addresses.
|
|
23
|
+
* "Details" for a connection's addresses. They slide open and shut.
|
|
23
24
|
*/
|
|
24
25
|
disclosure?: string | undefined;
|
|
25
26
|
/** At the row's end: a figure, a pill, or, on a row that isn't pressed, buttons. */
|
|
@@ -82,29 +83,34 @@ export const ListRow = ({
|
|
|
82
83
|
surface = "plain",
|
|
83
84
|
}: Props) => {
|
|
84
85
|
const below = Children.toArray(children).length > 0;
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
86
|
+
const folds = disclosure !== undefined && below;
|
|
87
|
+
const toggle = folds && (
|
|
88
|
+
<Collapsible.Trigger
|
|
89
|
+
render={
|
|
90
|
+
<Button
|
|
91
|
+
afterIcon={
|
|
92
|
+
<CaretDownIcon
|
|
93
|
+
aria-hidden
|
|
94
|
+
className={caretStyles}
|
|
95
|
+
size={12}
|
|
96
|
+
weight="bold"
|
|
97
|
+
/>
|
|
98
|
+
}
|
|
99
|
+
rounded
|
|
100
|
+
size="xs"
|
|
101
|
+
variant="ghost"
|
|
102
|
+
>
|
|
103
|
+
{disclosure}
|
|
104
|
+
</Button>
|
|
96
105
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}}
|
|
102
|
-
rounded
|
|
103
|
-
size="xs"
|
|
104
|
-
variant="ghost"
|
|
106
|
+
/>
|
|
107
|
+
);
|
|
108
|
+
const under = (
|
|
109
|
+
<div
|
|
110
|
+
className={belowStyles({ drawer: folds, indented: icon !== undefined })}
|
|
105
111
|
>
|
|
106
|
-
{
|
|
107
|
-
</
|
|
112
|
+
{children}
|
|
113
|
+
</div>
|
|
108
114
|
);
|
|
109
115
|
const face = (
|
|
110
116
|
<>
|
|
@@ -126,7 +132,7 @@ export const ListRow = ({
|
|
|
126
132
|
</>
|
|
127
133
|
);
|
|
128
134
|
const body = (
|
|
129
|
-
|
|
135
|
+
<Collapsible.Root className={rootStyles}>
|
|
130
136
|
{onPress === undefined ? (
|
|
131
137
|
<div className={rowStyles({ pressable: false })}>{face}</div>
|
|
132
138
|
) : (
|
|
@@ -140,18 +146,17 @@ export const ListRow = ({
|
|
|
140
146
|
{face}
|
|
141
147
|
</button>
|
|
142
148
|
)}
|
|
143
|
-
{
|
|
144
|
-
<
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
{folds ? (
|
|
150
|
+
<Collapsible.Panel className={drawerStyles}>{under}</Collapsible.Panel>
|
|
151
|
+
) : (
|
|
152
|
+
below && under
|
|
147
153
|
)}
|
|
148
|
-
|
|
154
|
+
</Collapsible.Root>
|
|
149
155
|
);
|
|
150
156
|
return motion === undefined ? (
|
|
151
157
|
<li
|
|
152
158
|
className={itemStyles({ surface })}
|
|
153
159
|
data-end-on-hover={endOnHover ? "" : undefined}
|
|
154
|
-
data-icon={icon === undefined ? undefined : ""}
|
|
155
160
|
data-surface={surface}
|
|
156
161
|
>
|
|
157
162
|
{body}
|
|
@@ -161,7 +166,6 @@ export const ListRow = ({
|
|
|
161
166
|
<div
|
|
162
167
|
className={itemStyles({ surface: "plain" })}
|
|
163
168
|
data-end-on-hover={endOnHover ? "" : undefined}
|
|
164
|
-
data-icon={icon === undefined ? undefined : ""}
|
|
165
169
|
>
|
|
166
170
|
{body}
|
|
167
171
|
</div>
|
|
@@ -242,11 +246,37 @@ const rowStyles = cva({
|
|
|
242
246
|
},
|
|
243
247
|
});
|
|
244
248
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
+
// Only there to hold the disclosure's state; the item lays out its parts.
|
|
250
|
+
const rootStyles = css({ display: "contents" });
|
|
251
|
+
|
|
252
|
+
// Flips while the drawer is open; base-ui sets `data-panel-open`.
|
|
253
|
+
const caretStyles = css({
|
|
254
|
+
"[data-panel-open] &": { transform: "rotate(180deg)" },
|
|
255
|
+
transition: "transform {durations.normal} {easings.out}",
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
// Opens to the height base-ui measures while what is in it slides down into
|
|
259
|
+
// place, and runs back, quicker, to close.
|
|
260
|
+
const drawerStyles = css({
|
|
261
|
+
"& > *": {
|
|
262
|
+
transition:
|
|
263
|
+
"opacity {durations.normal} {easings.out}, transform {durations.normal} {easings.out}",
|
|
264
|
+
},
|
|
265
|
+
"&[data-ending-style]": {
|
|
266
|
+
"& > *": {
|
|
267
|
+
transitionDuration: "{durations.fast}",
|
|
268
|
+
transitionTimingFunction: "{easings.in}",
|
|
269
|
+
},
|
|
270
|
+
transitionDuration: "{durations.fast}",
|
|
271
|
+
transitionTimingFunction: "{easings.in}",
|
|
249
272
|
},
|
|
273
|
+
"&[data-starting-style], &[data-ending-style]": {
|
|
274
|
+
"& > *": { opacity: 0, transform: "translateY(calc({spacing.1.5} * -1))" },
|
|
275
|
+
blockSize: 0,
|
|
276
|
+
},
|
|
277
|
+
blockSize: "var(--collapsible-panel-height)",
|
|
278
|
+
overflow: "hidden",
|
|
279
|
+
transition: "block-size {durations.normal} {easings.out}",
|
|
250
280
|
});
|
|
251
281
|
|
|
252
282
|
const iconStyles = css({ display: "inline-flex", flexShrink: 0 });
|
|
@@ -288,10 +318,27 @@ const endStyles = flex({
|
|
|
288
318
|
});
|
|
289
319
|
|
|
290
320
|
// Lined up under the label, past the icon and its gap.
|
|
291
|
-
const belowStyles =
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
321
|
+
const belowStyles = cva({
|
|
322
|
+
base: flex.raw({
|
|
323
|
+
direction: "column",
|
|
324
|
+
gap: 1.5,
|
|
325
|
+
paddingBlockEnd: 2,
|
|
326
|
+
paddingInline: 2,
|
|
327
|
+
}),
|
|
328
|
+
variants: {
|
|
329
|
+
// Room above and below the folded details. The gap and the bottom match
|
|
330
|
+
// a `PanelFooter`'s top, so its rule and button sit evenly spaced. A
|
|
331
|
+
// footer's action stays inside the drawer's padding rather than hanging
|
|
332
|
+
// past it, so it keeps a gap from the tile's edge.
|
|
333
|
+
drawer: {
|
|
334
|
+
false: {},
|
|
335
|
+
true: {
|
|
336
|
+
"& > footer > button:last-child": { marginInlineEnd: 0 },
|
|
337
|
+
gap: 3,
|
|
338
|
+
paddingBlockEnd: 3,
|
|
339
|
+
paddingBlockStart: 1.5,
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
indented: { false: {}, true: { paddingInlineStart: 8.5 } },
|
|
343
|
+
},
|
|
297
344
|
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Menu as BaseMenu } from "@base-ui/react/menu";
|
|
2
|
+
import type { ReactElement, ReactNode } from "react";
|
|
3
|
+
import { ContextMenu } from "../ContextMenu/ContextMenu";
|
|
4
|
+
import { popupStyles, positionerStyles } from "../ContextMenu/menu-popup";
|
|
5
|
+
import type { ExtendProps } from "../extend-props";
|
|
6
|
+
import { usePopupBoundary } from "../PopupBoundary/PopupBoundary";
|
|
7
|
+
import "../stylesheet";
|
|
8
|
+
|
|
9
|
+
type Props = ExtendProps<
|
|
10
|
+
typeof BaseMenu.Root,
|
|
11
|
+
{
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
/** The button that opens it, such as a `Button`. */
|
|
14
|
+
trigger: ReactElement;
|
|
15
|
+
}
|
|
16
|
+
>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A menu opened from a button, under its end, and named by it. Its items are
|
|
20
|
+
* `ContextMenu`'s. It stays inside its `PopupBoundary`, such as its window.
|
|
21
|
+
*/
|
|
22
|
+
const MenuComponent = ({ children, trigger, ...rootProps }: Props) => {
|
|
23
|
+
const { boundary } = usePopupBoundary(false);
|
|
24
|
+
return (
|
|
25
|
+
<BaseMenu.Root {...rootProps}>
|
|
26
|
+
<BaseMenu.Trigger render={trigger} />
|
|
27
|
+
<BaseMenu.Portal>
|
|
28
|
+
<BaseMenu.Positioner
|
|
29
|
+
align="end"
|
|
30
|
+
className={positionerStyles}
|
|
31
|
+
collisionBoundary={boundary}
|
|
32
|
+
sideOffset={4}
|
|
33
|
+
>
|
|
34
|
+
<BaseMenu.Popup className={popupStyles}>{children}</BaseMenu.Popup>
|
|
35
|
+
</BaseMenu.Positioner>
|
|
36
|
+
</BaseMenu.Portal>
|
|
37
|
+
</BaseMenu.Root>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const Menu = Object.assign(MenuComponent, {
|
|
42
|
+
Item: ContextMenu.Item,
|
|
43
|
+
Separator: ContextMenu.Separator,
|
|
44
|
+
});
|
|
@@ -13,32 +13,45 @@ type Props = {
|
|
|
13
13
|
titleId?: string | undefined;
|
|
14
14
|
/** Shows a back button that calls it. */
|
|
15
15
|
onBack?: (() => void) | undefined;
|
|
16
|
+
/** A state the panel is in, such as paused, on a line under the title. */
|
|
17
|
+
status?: ReactNode | undefined;
|
|
16
18
|
title: ReactNode;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* A panel's title, with a back button when it is one level in, and its
|
|
21
23
|
* controls at the end. The title is a level-2 heading; a `PanelSection`'s is
|
|
22
|
-
* level 3.
|
|
24
|
+
* level 3. A status sits under the title, outside the heading, so it does not
|
|
25
|
+
* rename the panel.
|
|
23
26
|
*/
|
|
24
|
-
export const PanelHeader = ({
|
|
27
|
+
export const PanelHeader = ({
|
|
28
|
+
action,
|
|
29
|
+
onBack,
|
|
30
|
+
status,
|
|
31
|
+
title,
|
|
32
|
+
titleId,
|
|
33
|
+
}: Props) => (
|
|
25
34
|
<div className={headerStyles}>
|
|
26
35
|
{onBack !== undefined && (
|
|
27
36
|
<IconButton label="Back" onClick={onBack}>
|
|
28
37
|
<CaretLeftIcon aria-hidden size={14} weight="bold" />
|
|
29
38
|
</IconButton>
|
|
30
39
|
)}
|
|
31
|
-
<
|
|
32
|
-
{
|
|
33
|
-
|
|
40
|
+
<div className={titlesStyles}>
|
|
41
|
+
<h2 className={titleStyles} id={titleId}>
|
|
42
|
+
{title}
|
|
43
|
+
</h2>
|
|
44
|
+
{status !== undefined && <p className={statusStyles}>{status}</p>}
|
|
45
|
+
</div>
|
|
34
46
|
{action !== undefined && <span className={actionStyles}>{action}</span>}
|
|
35
47
|
</div>
|
|
36
48
|
);
|
|
37
49
|
|
|
38
50
|
const headerStyles = hstack({ gap: 1, minBlockSize: 7 });
|
|
39
51
|
|
|
52
|
+
const titlesStyles = css({ flex: 1, minInlineSize: 0 });
|
|
53
|
+
|
|
40
54
|
const titleStyles = css({
|
|
41
|
-
flex: 1,
|
|
42
55
|
margin: 0,
|
|
43
56
|
minInlineSize: 0,
|
|
44
57
|
overflow: "hidden",
|
|
@@ -47,4 +60,14 @@ const titleStyles = css({
|
|
|
47
60
|
whiteSpace: "nowrap",
|
|
48
61
|
});
|
|
49
62
|
|
|
63
|
+
// In the accent, as a lit tile is: a state the user put the panel in.
|
|
64
|
+
const statusStyles = css({
|
|
65
|
+
color: "accent",
|
|
66
|
+
margin: 0,
|
|
67
|
+
overflow: "hidden",
|
|
68
|
+
textOverflow: "ellipsis",
|
|
69
|
+
textStyle: "panelDetail",
|
|
70
|
+
whiteSpace: "nowrap",
|
|
71
|
+
});
|
|
72
|
+
|
|
50
73
|
const actionStyles = hstack({ flexShrink: 0, gap: 1 });
|
package/src/Popover/Popover.tsx
CHANGED
|
@@ -331,7 +331,9 @@ const bodyStyles = cva({
|
|
|
331
331
|
|
|
332
332
|
/**
|
|
333
333
|
* Closes the panel when focus leaves it, its trigger and the trigger that
|
|
334
|
-
* opened it
|
|
334
|
+
* opened it, while open. The popup also lingers closed (kept mounted, or
|
|
335
|
+
* playing its closing transition), and base-ui reports every close, so a close
|
|
336
|
+
* then would close a popover its owner opened in its place.
|
|
335
337
|
*
|
|
336
338
|
* Portaled content counts as inside: React focus events follow the component
|
|
337
339
|
* tree and reach `within` before the document sees them.
|
|
@@ -355,6 +357,7 @@ const CloseOnFocusOut = ({
|
|
|
355
357
|
if (
|
|
356
358
|
target instanceof Node &&
|
|
357
359
|
event !== within.current &&
|
|
360
|
+
popup.current?.hasAttribute("data-open") === true &&
|
|
358
361
|
popup.current?.contains(target) !== true &&
|
|
359
362
|
trigger.current?.contains(target) !== true &&
|
|
360
363
|
opener.current?.contains(target) !== true
|
|
@@ -173,6 +173,19 @@ export const iconKeyframes = {
|
|
|
173
173
|
"70%": { transform: "translateY(4px)" },
|
|
174
174
|
"100%": { transform: "none" },
|
|
175
175
|
},
|
|
176
|
+
// A sparkle's star turns a quarter, which lands where it began, dipping
|
|
177
|
+
// as it goes, so it glints in place.
|
|
178
|
+
iconSparkleTwinkle: {
|
|
179
|
+
"0%": { transform: "none" },
|
|
180
|
+
"50%": { transform: "rotate(45deg) scale(0.8)" },
|
|
181
|
+
"100%": { transform: "rotate(90deg)" },
|
|
182
|
+
},
|
|
183
|
+
// Its glints wink out and pop back a little past full size.
|
|
184
|
+
iconSparkleWink: {
|
|
185
|
+
"0%, 100%": { transform: "none" },
|
|
186
|
+
"35%": { transform: "scale(0)" },
|
|
187
|
+
"70%": { transform: "scale(1.3)" },
|
|
188
|
+
},
|
|
176
189
|
// A download's tray gives under the arrow landing in it.
|
|
177
190
|
iconTrayGive: {
|
|
178
191
|
"0%, 100%": { transform: "none" },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Phosphor's icon paths, split into the parts that move.
|
|
3
|
-
* `phosphor-parts.test.
|
|
3
|
+
* `phosphor-parts.test.tsx` checks that each set joins back into Phosphor's
|
|
4
4
|
* icon.
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -214,3 +214,13 @@ export const DOWNLOAD_REGULAR = {
|
|
|
214
214
|
"M122.34 149.66A8 8 0 0 0 133.66 149.66L173.66 109.66A8 8 0 0 0 162.34 98.34L136 124.69V32A8 8 0 0 0 120 32V124.69L93.66 98.34A8 8 0 0 0 82.34 109.66Z",
|
|
215
215
|
tray: "M224 144V208A8 8 0 0 1 216 216H40A8 8 0 0 1 32 208V144A8 8 0 0 1 48 144V200H208V144A8 8 0 0 1 224 144Z",
|
|
216
216
|
} as const;
|
|
217
|
+
|
|
218
|
+
/** Sparkle regular. */
|
|
219
|
+
export const SPARKLE_REGULAR = {
|
|
220
|
+
// The two small crosses: the larger, up and to the left, then the smaller.
|
|
221
|
+
glints: [
|
|
222
|
+
"M144,40a8,8,0,0,1,8-8h16V16a8,8,0,0,1,16,0V32h16a8,8,0,0,1,0,16H184V64a8,8,0,0,1-16,0V48H152A8,8,0,0,1,144,40Z",
|
|
223
|
+
"M248,88a8,8,0,0,1-8,8h-8v8a8,8,0,0,1-16,0V96h-8a8,8,0,0,1,0-16h8V72a8,8,0,0,1,16,0v8h8A8,8,0,0,1,248,88Z",
|
|
224
|
+
],
|
|
225
|
+
star: "M197.58,129.06,146,110l-19-51.62a15.92,15.92,0,0,0-29.88,0L78,110l-51.62,19a15.92,15.92,0,0,0,0,29.88L78,178l19,51.62a15.92,15.92,0,0,0,29.88,0L146,178l51.62-19a15.92,15.92,0,0,0,0-29.88ZM137,164.22a8,8,0,0,0-4.74,4.74L112,223.85,91.78,169A8,8,0,0,0,87,164.22L32.15,144,87,123.78A8,8,0,0,0,91.78,119L112,64.15,132.22,119a8,8,0,0,0,4.74,4.74L191.85,144Z",
|
|
226
|
+
} as const;
|
|
@@ -3,11 +3,11 @@ import { css } from '../css/index.mjs';
|
|
|
3
3
|
|
|
4
4
|
const aspectRatioConfig = {
|
|
5
5
|
transform(props, { map }) {
|
|
6
|
-
const { ratio =
|
|
6
|
+
const { ratio = 1.3333333333333333, ...rest } = props;
|
|
7
7
|
return {
|
|
8
8
|
position: "relative",
|
|
9
9
|
_before: {
|
|
10
|
-
content:
|
|
10
|
+
content: '""',
|
|
11
11
|
display: "block",
|
|
12
12
|
height: "0",
|
|
13
13
|
paddingBottom: map(ratio, (r) => `${1 / r * 100}%`)
|
|
@@ -3,8 +3,7 @@ import { css } from '../css/index.mjs';
|
|
|
3
3
|
|
|
4
4
|
const bleedConfig = {
|
|
5
5
|
transform(props, { map, isCssUnit, isCssVar }) {
|
|
6
|
-
const { inline, block, ...rest } = props
|
|
7
|
-
const valueFn = (v) => isCssUnit(v) || isCssVar(v) ? v : `token(spacing.${v}, ${v})`;
|
|
6
|
+
const { inline, block, ...rest } = props, valueFn = (v) => isCssUnit(v) || isCssVar(v) ? v : `token(spacing.${v}, ${v})`;
|
|
8
7
|
return {
|
|
9
8
|
"--bleed-x": map(inline, valueFn),
|
|
10
9
|
"--bleed-y": map(block, valueFn),
|