@domicile-desktop/manganese-bar-module-workspace-switcher 1.0.0 → 1.2.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/README.md +2 -1
- package/package.json +6 -7
- package/src/OverviewButton.tsx +52 -0
- package/src/Workspaces.tsx +176 -50
- package/src/bar-item.tsx +20 -8
- 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/types/prop-type.d.ts +1 -1
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@domicile-desktop/component-library": "1.0
|
|
4
|
-
"@domicile-desktop/manganese-bar": "1.
|
|
5
|
-
"@domicile-desktop/manganese-window-management": "1.
|
|
3
|
+
"@domicile-desktop/component-library": "2.1.0",
|
|
4
|
+
"@domicile-desktop/manganese-bar": "1.1.2",
|
|
5
|
+
"@domicile-desktop/manganese-window-management": "1.3.0",
|
|
6
6
|
"@pandacss/dev": "^1.12.1",
|
|
7
7
|
"react": "^19.2.8"
|
|
8
8
|
},
|
|
9
9
|
"description": "A manganese bar item: the screen's workspaces.",
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@cprussin/tsconfig": "^5.0.0",
|
|
12
|
-
"@domicile-desktop/test-support": "0.0.
|
|
12
|
+
"@domicile-desktop/test-support": "0.0.2",
|
|
13
13
|
"@pandacss/preset-panda": "^1.12.1",
|
|
14
14
|
"@testing-library/react": "^16.3.3",
|
|
15
15
|
"@testing-library/user-event": "^14.6.7",
|
|
@@ -20,8 +20,7 @@
|
|
|
20
20
|
"typescript": "^7.0.2"
|
|
21
21
|
},
|
|
22
22
|
"engines": {
|
|
23
|
-
"bun": ">=1.4.2"
|
|
24
|
-
"node": ">=24"
|
|
23
|
+
"bun": ">=1.4.2"
|
|
25
24
|
},
|
|
26
25
|
"exports": {
|
|
27
26
|
".": "./src/bar-item.tsx"
|
|
@@ -49,5 +48,5 @@
|
|
|
49
48
|
"test:unit": "bun test"
|
|
50
49
|
},
|
|
51
50
|
"type": "module",
|
|
52
|
-
"version": "1.
|
|
51
|
+
"version": "1.2.0"
|
|
53
52
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { AnimatedSquaresIcon } from "@domicile-desktop/component-library/AnimatedSquaresIcon";
|
|
2
|
+
import { Tooltip } from "@domicile-desktop/component-library/Tooltip";
|
|
3
|
+
|
|
4
|
+
import { css } from "../styled-system/css";
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
/** Opens or closes the overview. */
|
|
8
|
+
onToggle: () => void;
|
|
9
|
+
/** Whether the overview is open, which keeps the button lit. */
|
|
10
|
+
open: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The switcher's overview button, the pointer equivalent of Meta+O: each
|
|
15
|
+
* screen's workspaces at once.
|
|
16
|
+
*/
|
|
17
|
+
export const OverviewButton = ({ onToggle, open }: Props) => (
|
|
18
|
+
<Tooltip
|
|
19
|
+
content="Overview"
|
|
20
|
+
tone="overPhoto"
|
|
21
|
+
trigger={
|
|
22
|
+
<button
|
|
23
|
+
aria-label="Overview"
|
|
24
|
+
aria-pressed={open}
|
|
25
|
+
className={buttonStyles}
|
|
26
|
+
onClick={onToggle}
|
|
27
|
+
type="button"
|
|
28
|
+
>
|
|
29
|
+
<AnimatedSquaresIcon size={15} />
|
|
30
|
+
</button>
|
|
31
|
+
}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// Styled like the launcher button, and lit like a bar button whose panel is
|
|
36
|
+
// open.
|
|
37
|
+
const buttonStyles = css({
|
|
38
|
+
_hover: { backgroundColor: "fillOverPhoto" },
|
|
39
|
+
"&[aria-pressed=true]": { backgroundColor: "fillOverPhoto" },
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
backgroundColor: "transparent",
|
|
42
|
+
blockSize: 7,
|
|
43
|
+
borderRadius: "lg",
|
|
44
|
+
borderStyle: "none",
|
|
45
|
+
cursor: "pointer",
|
|
46
|
+
display: "inline-flex",
|
|
47
|
+
flexShrink: 0,
|
|
48
|
+
inlineSize: 7,
|
|
49
|
+
justifyContent: "center",
|
|
50
|
+
padding: 0,
|
|
51
|
+
transition: "background-color {durations.fast} {easings.default}",
|
|
52
|
+
});
|
package/src/Workspaces.tsx
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import { css, cva, cx } from "../styled-system/css";
|
|
2
5
|
import { hstack } from "../styled-system/patterns";
|
|
3
6
|
|
|
7
|
+
/** A chip's distance from the row's start and its width, in px. */
|
|
8
|
+
export type Place = { start: number; width: number };
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Calls `onPlace` with `chip`'s place in its row now and whenever the row's
|
|
12
|
+
* layout changes, until the returned function stops it.
|
|
13
|
+
*/
|
|
14
|
+
export type MeasureChip = (
|
|
15
|
+
chip: HTMLElement,
|
|
16
|
+
onPlace: (place: Place) => void,
|
|
17
|
+
) => () => void;
|
|
18
|
+
|
|
4
19
|
type Props = {
|
|
5
20
|
/** The workspace this screen shows. */
|
|
6
21
|
current: string;
|
|
7
22
|
/** Whether this screen has keyboard focus, which decides `current`'s fill. */
|
|
8
23
|
focused: boolean;
|
|
24
|
+
/** Injectable for tests; defaults to a `ResizeObserver` on the row. */
|
|
25
|
+
measureChip?: MeasureChip | undefined;
|
|
9
26
|
onSelect: (name: string) => void;
|
|
10
27
|
/** This screen's workspaces, in order. */
|
|
11
28
|
workspaces: readonly string[];
|
|
@@ -15,9 +32,13 @@ type Props = {
|
|
|
15
32
|
* The workspace switcher at the bar's start. Like sway's bar, it shows this
|
|
16
33
|
* screen's workspaces that have windows, plus the one on screen.
|
|
17
34
|
*
|
|
18
|
-
* Each is a number. The focused workspace
|
|
19
|
-
* out over a bright wallpaper; one visible on another screen gets a
|
|
20
|
-
* outline; the rest are slightly dimmed and light up under the pointer.
|
|
35
|
+
* Each is a number. The focused workspace sits under a solid white chip, so it
|
|
36
|
+
* stands out over a bright wallpaper; one visible on another screen gets a
|
|
37
|
+
* white outline; the rest are slightly dimmed and light up under the pointer.
|
|
38
|
+
*
|
|
39
|
+
* The white chip slides between workspaces. It is a black copy of the row on
|
|
40
|
+
* white, clipped to the chip, so each number turns black as the chip passes
|
|
41
|
+
* under it.
|
|
21
42
|
*
|
|
22
43
|
* A plain `<button>` rather than the library's `Button`, which does not support
|
|
23
44
|
* `aria-current` styling or an external `className`. It inherits the bar's
|
|
@@ -26,60 +47,141 @@ type Props = {
|
|
|
26
47
|
export const Workspaces = ({
|
|
27
48
|
current,
|
|
28
49
|
focused,
|
|
50
|
+
measureChip = offsetPlace,
|
|
29
51
|
onSelect,
|
|
30
52
|
workspaces,
|
|
31
|
-
}: Props) =>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<button
|
|
35
|
-
// `aria-current` marks the visible workspace. `disabled` would be
|
|
36
|
-
// wrong: a press on it switches back via `workspaceAutoBackAndForth`.
|
|
37
|
-
aria-current={name === current ? "true" : undefined}
|
|
38
|
-
className={workspaceStyles({
|
|
39
|
-
shown: shownAs(name === current, focused),
|
|
40
|
-
})}
|
|
41
|
-
key={name}
|
|
42
|
-
onClick={() => {
|
|
43
|
-
onSelect(name);
|
|
44
|
-
}}
|
|
45
|
-
type="button"
|
|
46
|
-
>
|
|
47
|
-
{name}
|
|
48
|
-
</button>
|
|
49
|
-
))}
|
|
50
|
-
</nav>
|
|
51
|
-
);
|
|
53
|
+
}: Props) => {
|
|
54
|
+
const chips = useRef(new Map<string, HTMLButtonElement>());
|
|
55
|
+
const [place, setPlace] = useState<Place>();
|
|
52
56
|
|
|
53
|
-
|
|
57
|
+
useLayoutEffect(() => {
|
|
58
|
+
const chip = chips.current.get(current);
|
|
59
|
+
if (chip === undefined) {
|
|
60
|
+
throw new Error(`manganese: workspace ${current} is not in the bar`);
|
|
61
|
+
}
|
|
62
|
+
return measureChip(chip, setPlace);
|
|
63
|
+
}, [current, measureChip]);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<nav aria-label="Workspaces" className={listStyles}>
|
|
67
|
+
{workspaces.map((name) => (
|
|
68
|
+
<button
|
|
69
|
+
// `aria-current` marks the visible workspace. `disabled` would be
|
|
70
|
+
// wrong: a press on it switches back via `workspaceAutoBackAndForth`.
|
|
71
|
+
aria-current={name === current ? "true" : undefined}
|
|
72
|
+
className={cx(
|
|
73
|
+
chipStyles,
|
|
74
|
+
workspaceStyles({ shown: shownAs(name === current, focused) }),
|
|
75
|
+
)}
|
|
76
|
+
data-label={name}
|
|
77
|
+
key={name}
|
|
78
|
+
onClick={() => {
|
|
79
|
+
onSelect(name);
|
|
80
|
+
}}
|
|
81
|
+
ref={(chip) => {
|
|
82
|
+
if (chip === null) {
|
|
83
|
+
chips.current.delete(name);
|
|
84
|
+
} else {
|
|
85
|
+
chips.current.set(name, chip);
|
|
86
|
+
}
|
|
87
|
+
}}
|
|
88
|
+
type="button"
|
|
89
|
+
>
|
|
90
|
+
<span className={labelStyles}>{name}</span>
|
|
91
|
+
</button>
|
|
92
|
+
))}
|
|
93
|
+
{place !== undefined && (
|
|
94
|
+
<div
|
|
95
|
+
aria-hidden="true"
|
|
96
|
+
className={highlightStyles}
|
|
97
|
+
data-shown={focused}
|
|
98
|
+
data-testid="highlight"
|
|
99
|
+
style={
|
|
100
|
+
{
|
|
101
|
+
"--highlight-start": `${place.start}px`,
|
|
102
|
+
"--highlight-width": `${place.width}px`,
|
|
103
|
+
} as CSSProperties
|
|
104
|
+
}
|
|
105
|
+
>
|
|
106
|
+
{workspaces.map((name) => (
|
|
107
|
+
<span className={chipStyles} data-label={name} key={name}>
|
|
108
|
+
<span className={labelStyles}>{name}</span>
|
|
109
|
+
</span>
|
|
110
|
+
))}
|
|
111
|
+
</div>
|
|
112
|
+
)}
|
|
113
|
+
</nav>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/** `MeasureChip` from offsets, again whenever the row resizes. */
|
|
118
|
+
const offsetPlace: MeasureChip = (chip, onPlace) => {
|
|
119
|
+
const row = chip.parentElement;
|
|
120
|
+
if (row === null) {
|
|
121
|
+
throw new Error("manganese: workspace chip has no row");
|
|
122
|
+
}
|
|
123
|
+
const measure = () => {
|
|
124
|
+
onPlace({
|
|
125
|
+
start: chip.offsetLeft,
|
|
126
|
+
width: chip.offsetWidth,
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
const observer = new ResizeObserver(measure);
|
|
130
|
+
observer.observe(row);
|
|
131
|
+
measure();
|
|
132
|
+
return () => {
|
|
133
|
+
observer.disconnect();
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Relative, so the chips' offsets and the highlight are from the row.
|
|
138
|
+
const listStyles = hstack({ gap: 0.5, position: "relative" });
|
|
139
|
+
|
|
140
|
+
// The number and a hidden bold copy share one cell, so every chip is as wide
|
|
141
|
+
// as its bold number and the highlight's bold copy lines up with the row.
|
|
142
|
+
const chipStyles = css({
|
|
143
|
+
_after: {
|
|
144
|
+
blockSize: 0,
|
|
145
|
+
content: "attr(data-label)",
|
|
146
|
+
fontWeight: "semibold",
|
|
147
|
+
gridArea: "1 / 1",
|
|
148
|
+
overflow: "hidden",
|
|
149
|
+
visibility: "hidden",
|
|
150
|
+
},
|
|
151
|
+
alignItems: "center",
|
|
152
|
+
blockSize: 6,
|
|
153
|
+
borderRadius: "lg",
|
|
154
|
+
display: "grid",
|
|
155
|
+
// 13px, matching the clock.
|
|
156
|
+
fontSize: "ui",
|
|
157
|
+
// Tabular figures keep every number the same width.
|
|
158
|
+
fontVariantNumeric: "tabular-nums",
|
|
159
|
+
// Only matters where `text-box` trim is unsupported.
|
|
160
|
+
lineHeight: "tight",
|
|
161
|
+
minInlineSize: 6,
|
|
162
|
+
paddingBlock: 0,
|
|
163
|
+
paddingInline: 2,
|
|
164
|
+
textAlign: "center",
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
const labelStyles = css({
|
|
168
|
+
gridArea: "1 / 1",
|
|
169
|
+
// Center vertically. Trimming the line box to cap height and baseline
|
|
170
|
+
// leaves only the glyph, so the digit sits centered rather than high.
|
|
171
|
+
textBox: "trim-both cap alphabetic",
|
|
172
|
+
});
|
|
54
173
|
|
|
55
174
|
const workspaceStyles = cva({
|
|
56
175
|
base: {
|
|
57
176
|
// Skips `aria-current`, so the chip keeps its fill under the pointer.
|
|
58
177
|
_hoverEnabled: { backgroundColor: "fillOverPhoto", color: "onPhoto" },
|
|
59
178
|
backgroundColor: "transparent",
|
|
60
|
-
blockSize: 6,
|
|
61
|
-
borderRadius: "lg",
|
|
62
179
|
borderStyle: "none",
|
|
63
180
|
color: "color-mix(in oklab, {colors.onPhoto} 85%, transparent)",
|
|
64
181
|
cursor: "pointer",
|
|
65
|
-
// A block, not flex: `text-box` trim below works only on block containers.
|
|
66
|
-
display: "block",
|
|
67
|
-
// 13px, matching the clock.
|
|
68
|
-
fontSize: "ui",
|
|
69
|
-
// Tabular figures keep every number the same width.
|
|
70
|
-
fontVariantNumeric: "tabular-nums",
|
|
71
182
|
fontWeight: "medium",
|
|
72
|
-
// Only matters where `text-box` trim is unsupported.
|
|
73
|
-
lineHeight: "tight",
|
|
74
|
-
minInlineSize: 6,
|
|
75
|
-
paddingBlock: 0,
|
|
76
|
-
paddingInline: 2,
|
|
77
183
|
// Pressed feedback that is not just color.
|
|
78
184
|
scale: { _active: 0.92, base: 1 },
|
|
79
|
-
textAlign: "center",
|
|
80
|
-
// Center vertically. Trimming the line box to cap height and baseline
|
|
81
|
-
// leaves only the glyph, so the digit sits centered rather than high.
|
|
82
|
-
textBox: "trim-both cap alphabetic",
|
|
83
185
|
transition: `
|
|
84
186
|
background-color {durations.fast} {easings.out},
|
|
85
187
|
color {durations.fast} {easings.out},
|
|
@@ -88,13 +190,8 @@ const workspaceStyles = cva({
|
|
|
88
190
|
},
|
|
89
191
|
variants: {
|
|
90
192
|
shown: {
|
|
91
|
-
//
|
|
92
|
-
focused: {
|
|
93
|
-
backgroundColor: "onPhoto",
|
|
94
|
-
color: "black",
|
|
95
|
-
fontWeight: "semibold",
|
|
96
|
-
textShadow: "none",
|
|
97
|
-
},
|
|
193
|
+
// Under the highlight, which draws it.
|
|
194
|
+
focused: { color: "onPhoto", fontWeight: "semibold" },
|
|
98
195
|
hidden: {},
|
|
99
196
|
// Visible on another screen: an outline, 1.5px, between the spacing
|
|
100
197
|
// scale's 1px and 2px steps.
|
|
@@ -107,6 +204,35 @@ const workspaceStyles = cva({
|
|
|
107
204
|
},
|
|
108
205
|
});
|
|
109
206
|
|
|
207
|
+
// A copy of the row over it, clipped to the current chip. `outBack` overshoots
|
|
208
|
+
// the chip a little and settles back. Black needs no shadow, and one would
|
|
209
|
+
// smudge it.
|
|
210
|
+
const highlightStyles = css({
|
|
211
|
+
"&[data-shown=false]": { opacity: 0 },
|
|
212
|
+
alignItems: "center",
|
|
213
|
+
backgroundColor: "onPhoto",
|
|
214
|
+
// From the start edge only, so the chip slides smoothly while a workspace
|
|
215
|
+
// comes or goes at the row's end and the row's width jumps.
|
|
216
|
+
clipPath:
|
|
217
|
+
"xywh(calc(var(--highlight-start) + {spacing.10}) 0 var(--highlight-width) 100% round {radii.lg})",
|
|
218
|
+
color: "black",
|
|
219
|
+
display: "flex",
|
|
220
|
+
fontWeight: "semibold",
|
|
221
|
+
gap: 0.5,
|
|
222
|
+
insetBlock: 0,
|
|
223
|
+
// Past both ends of the row, so a bounce past the first or last chip is
|
|
224
|
+
// not cut flat.
|
|
225
|
+
insetInline: -10,
|
|
226
|
+
paddingInline: 10,
|
|
227
|
+
pointerEvents: "none",
|
|
228
|
+
position: "absolute",
|
|
229
|
+
textShadow: "none",
|
|
230
|
+
transition: `
|
|
231
|
+
clip-path {durations.slower} {easings.outBack},
|
|
232
|
+
opacity {durations.fast} {easings.out}
|
|
233
|
+
`,
|
|
234
|
+
});
|
|
235
|
+
|
|
110
236
|
const shownAs = (
|
|
111
237
|
current: boolean,
|
|
112
238
|
focused: boolean,
|
package/src/bar-item.tsx
CHANGED
|
@@ -2,23 +2,33 @@ import { useBar } from "@domicile-desktop/manganese-bar/bar-context";
|
|
|
2
2
|
import { workspacesOn } from "@domicile-desktop/manganese-window-management/window-state";
|
|
3
3
|
import { useWorkspaces } from "@domicile-desktop/manganese-window-management/workspaces-context";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
+
|
|
6
|
+
import { hstack } from "../styled-system/patterns";
|
|
7
|
+
import { OverviewButton } from "./OverviewButton";
|
|
5
8
|
import { Workspaces } from "./Workspaces";
|
|
6
9
|
|
|
7
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* The overview button, then this screen's workspaces, with the visible one
|
|
12
|
+
* marked.
|
|
13
|
+
*/
|
|
8
14
|
export const WorkspaceSwitcher = () => {
|
|
9
15
|
const { screen } = useBar();
|
|
10
|
-
const { current, focused, homes, select } =
|
|
16
|
+
const { current, focused, homes, overviewOpen, select, toggleOverview } =
|
|
17
|
+
useWorkspaces();
|
|
11
18
|
const workspaces = useMemo(
|
|
12
19
|
() => workspacesOn({ homes }, screen),
|
|
13
20
|
[homes, screen],
|
|
14
21
|
);
|
|
15
22
|
return (
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
<div className={rowStyles}>
|
|
24
|
+
<OverviewButton onToggle={toggleOverview} open={overviewOpen} />
|
|
25
|
+
<Workspaces
|
|
26
|
+
current={shownOn(current, screen)}
|
|
27
|
+
focused={focused === screen}
|
|
28
|
+
onSelect={select}
|
|
29
|
+
workspaces={workspaces}
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
22
32
|
);
|
|
23
33
|
};
|
|
24
34
|
|
|
@@ -34,3 +44,5 @@ const shownOn = (
|
|
|
34
44
|
return workspace;
|
|
35
45
|
}
|
|
36
46
|
};
|
|
47
|
+
|
|
48
|
+
const rowStyles = hstack({ gap: 1 });
|
|
@@ -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),
|
|
@@ -11,28 +11,22 @@ transform(props, { map }) {
|
|
|
11
11
|
position: "absolute",
|
|
12
12
|
insetBlockStart: map(placement, (v) => {
|
|
13
13
|
const [side] = v.split("-");
|
|
14
|
-
|
|
15
|
-
return map2[side];
|
|
14
|
+
return { top: offsetY, middle: "50%", bottom: "auto" }[side];
|
|
16
15
|
}),
|
|
17
16
|
insetBlockEnd: map(placement, (v) => {
|
|
18
17
|
const [side] = v.split("-");
|
|
19
|
-
|
|
20
|
-
return map2[side];
|
|
18
|
+
return { top: "auto", middle: "50%", bottom: offsetY }[side];
|
|
21
19
|
}),
|
|
22
20
|
insetInlineStart: map(placement, (v) => {
|
|
23
21
|
const [, align] = v.split("-");
|
|
24
|
-
|
|
25
|
-
return map2[align];
|
|
22
|
+
return { start: offsetX, center: "50%", end: "auto" }[align];
|
|
26
23
|
}),
|
|
27
24
|
insetInlineEnd: map(placement, (v) => {
|
|
28
25
|
const [, align] = v.split("-");
|
|
29
|
-
|
|
30
|
-
return map2[align];
|
|
26
|
+
return { start: "auto", center: "50%", end: offsetX }[align];
|
|
31
27
|
}),
|
|
32
28
|
translate: map(placement, (v) => {
|
|
33
|
-
const [side, align] = v.split("-");
|
|
34
|
-
const mapX = { start: "-50%", center: "-50%", end: "50%" };
|
|
35
|
-
const mapY = { top: "-50%", middle: "-50%", bottom: "50%" };
|
|
29
|
+
const [side, align] = v.split("-"), mapX = { start: "-50%", center: "-50%", end: "50%" }, mapY = { top: "-50%", middle: "-50%", bottom: "50%" };
|
|
36
30
|
return `${mapX[align]} ${mapY[side]}`;
|
|
37
31
|
}),
|
|
38
32
|
...rest
|
|
@@ -3,8 +3,7 @@ import { css } from '../css/index.mjs';
|
|
|
3
3
|
|
|
4
4
|
const gridItemConfig = {
|
|
5
5
|
transform(props, { map }) {
|
|
6
|
-
const { colSpan, rowSpan, colStart, rowStart, colEnd, rowEnd, ...rest } = props
|
|
7
|
-
const spanFn = (v) => v === "auto" ? v : `span ${v}`;
|
|
6
|
+
const { colSpan, rowSpan, colStart, rowStart, colEnd, rowEnd, ...rest } = props, spanFn = (v) => v === "auto" ? v : `span ${v}`;
|
|
8
7
|
return {
|
|
9
8
|
gridColumn: colSpan != null ? map(colSpan, spanFn) : void 0,
|
|
10
9
|
gridRow: rowSpan != null ? map(rowSpan, spanFn) : void 0,
|
|
@@ -3,8 +3,7 @@ import { css } from '../css/index.mjs';
|
|
|
3
3
|
|
|
4
4
|
const gridConfig = {
|
|
5
5
|
transform(props, { map, isCssUnit }) {
|
|
6
|
-
const { columnGap, rowGap, gap, columns, minChildWidth, ...rest } = props
|
|
7
|
-
const getValue = (v) => isCssUnit(v) ? v : `token(sizes.${v}, ${v})`;
|
|
6
|
+
const { columnGap, rowGap, gap, columns, minChildWidth, ...rest } = props, getValue = (v) => isCssUnit(v) ? v : `token(sizes.${v}, ${v})`;
|
|
8
7
|
return {
|
|
9
8
|
display: "grid",
|
|
10
9
|
gridTemplateColumns: columns != null ? map(columns, (v) => `repeat(${v}, minmax(0, 1fr))`) : minChildWidth != null ? map(minChildWidth, (v) => `repeat(auto-fit, minmax(${getValue(v)}, 1fr))`) : void 0,
|
|
@@ -8,9 +8,9 @@ transform(props, { map, isCssUnit, isCssVar }) {
|
|
|
8
8
|
alignSelf: "stretch",
|
|
9
9
|
justifySelf: "stretch",
|
|
10
10
|
flex: map(size, (v) => {
|
|
11
|
-
if (v == null)
|
|
12
|
-
|
|
13
|
-
return `0 0 ${
|
|
11
|
+
if (v == null)
|
|
12
|
+
return "1";
|
|
13
|
+
return `0 0 ${isCssUnit(v) || isCssVar(v) ? v : `token(spacing.${v}, ${v})`}`;
|
|
14
14
|
}),
|
|
15
15
|
...rest
|
|
16
16
|
};
|
|
@@ -169,7 +169,7 @@ export interface UtilityValues {
|
|
|
169
169
|
transitionProperty: "common" | "colors" | "size" | "position" | "background";
|
|
170
170
|
transition: "all" | "common" | "size" | "position" | "background" | "colors" | "opacity" | "shadow" | "transform";
|
|
171
171
|
animation: Tokens["animations"];
|
|
172
|
-
animationName: "bounce" | "iconArcRipple" | "iconArcSearch" | "iconArmReach" | "iconArmSwing" | "iconArrowWind" | "iconBellClapper" | "iconBellNudge" | "iconBellSwing" | "iconBoltStrike" | "iconBubbleTip" | "iconCapsuleBob" | "iconCheckDraw" | "iconCoreIn" | "iconCoreOut" | "iconDotBlink" | "iconDownloadDrop" | "iconGearTurn" | "iconKeyholePulse" | "iconKeyPress" | "iconLineWrite" | "iconMoonIn" | "iconMoonOut" | "iconMoonRock" | "iconPartSpread" | "iconPupilGlance" | "iconRayIn" | "iconRayOut" | "iconRayPulse" | "iconShackleLift" | "iconShackleShut" | "iconTrayGive" | "iconWavePull" | "iconWavePush" | "levelToastEnter" | "levelToastHold" | "levelToastHoldAgain" | "noticeShown" | "ping" | "pulse" | "spin" | "themeSwipeFromBottom" | "themeSwipeFromTop" | "toastCountdown";
|
|
172
|
+
animationName: "bounce" | "iconArcRipple" | "iconArcSearch" | "iconArmReach" | "iconArmSwing" | "iconArrowWind" | "iconBellClapper" | "iconBellNudge" | "iconBellSwing" | "iconBoltStrike" | "iconBubbleTip" | "iconCapsuleBob" | "iconCheckDraw" | "iconCoreIn" | "iconCoreOut" | "iconDotBlink" | "iconDownloadDrop" | "iconGearTurn" | "iconKeyholePulse" | "iconKeyPress" | "iconLineWrite" | "iconMoonIn" | "iconMoonOut" | "iconMoonRock" | "iconPartSpread" | "iconPupilGlance" | "iconRayIn" | "iconRayOut" | "iconRayPulse" | "iconShackleLift" | "iconShackleShut" | "iconSparkleTwinkle" | "iconSparkleWink" | "iconTrayGive" | "iconWavePull" | "iconWavePush" | "levelToastEnter" | "levelToastHold" | "levelToastHoldAgain" | "noticeShown" | "ping" | "pulse" | "spin" | "themeSwipeFromBottom" | "themeSwipeFromTop" | "toastCountdown";
|
|
173
173
|
animationTimingFunction: Tokens["easings"];
|
|
174
174
|
animationDuration: Tokens["durations"];
|
|
175
175
|
animationDelay: Tokens["durations"];
|