@designa8/vibedesign-openai-internal-v1-2-176b 0.0.3 → 0.0.4
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 +1 -1
- package/dist/index.cjs +31 -9
- package/dist/index.js +31 -9
- package/dist/styles.css +9 -0
- package/package.json +1 -1
- package/src/atoms/Modal/Modal.tsx +70 -43
- package/src/atoms/Modal/preview.tsx +84 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @designa8/vibedesign-openai-internal-v1-2-176b
|
|
2
2
|
|
|
3
|
-
Complete design system generated by Atoms Design, version **0.0.
|
|
3
|
+
Complete design system generated by Atoms Design, version **0.0.4**.
|
|
4
4
|
Tokens, atoms, molecules, organisms, and templates — import from the package root;
|
|
5
5
|
never hardcode visual values in consumer code.
|
|
6
6
|
|
package/dist/index.cjs
CHANGED
|
@@ -5654,7 +5654,8 @@ var cn49 = (...parts) => parts.filter(Boolean).join(" ");
|
|
|
5654
5654
|
var widths = {
|
|
5655
5655
|
sm: "sm:w-[var(--container-modal-sm,400px)]",
|
|
5656
5656
|
md: "sm:w-[var(--container-modal,480px)]",
|
|
5657
|
-
lg: "sm:w-[var(--container-modal-lg,640px)]"
|
|
5657
|
+
lg: "sm:w-[var(--container-modal-lg,640px)]",
|
|
5658
|
+
xl: "sm:w-[var(--container-modal-xl,640px)]"
|
|
5658
5659
|
};
|
|
5659
5660
|
var Modal = React55.forwardRef(
|
|
5660
5661
|
({
|
|
@@ -5666,6 +5667,8 @@ var Modal = React55.forwardRef(
|
|
|
5666
5667
|
tone = "default",
|
|
5667
5668
|
footer,
|
|
5668
5669
|
size = "md",
|
|
5670
|
+
placement = "center",
|
|
5671
|
+
hideHeader = false,
|
|
5669
5672
|
closeOnScrimClick = true,
|
|
5670
5673
|
hideClose = false,
|
|
5671
5674
|
closeLabel = "Close",
|
|
@@ -5711,13 +5714,21 @@ var Modal = React55.forwardRef(
|
|
|
5711
5714
|
};
|
|
5712
5715
|
if (!mounted) return null;
|
|
5713
5716
|
const state = open ? "open" : "closed";
|
|
5717
|
+
const showHeader = !hideHeader;
|
|
5718
|
+
const hasVisibleTitle = showHeader && Boolean(title);
|
|
5719
|
+
const hasVisibleDescription = showHeader && Boolean(description);
|
|
5720
|
+
const isTop = placement === "top";
|
|
5714
5721
|
return (0, import_react_dom6.createPortal)(
|
|
5715
5722
|
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
|
|
5716
5723
|
"div",
|
|
5717
5724
|
{
|
|
5718
5725
|
"data-state": state,
|
|
5726
|
+
"data-placement": placement,
|
|
5719
5727
|
"aria-hidden": !open,
|
|
5720
|
-
className:
|
|
5728
|
+
className: cn49(
|
|
5729
|
+
"fixed inset-0 flex justify-center p-base text-ink transition-[visibility] duration-200 data-[state=closed]:pointer-events-none data-[state=closed]:invisible",
|
|
5730
|
+
isTop ? "items-start pt-[12dvh]" : "items-end sm:items-center"
|
|
5731
|
+
),
|
|
5721
5732
|
style: { zIndex: "var(--z-modal, 1200)" },
|
|
5722
5733
|
children: [
|
|
5723
5734
|
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
@@ -5735,13 +5746,15 @@ var Modal = React55.forwardRef(
|
|
|
5735
5746
|
ref: setRefs,
|
|
5736
5747
|
role: "dialog",
|
|
5737
5748
|
"aria-modal": "true",
|
|
5738
|
-
"aria-labelledby":
|
|
5739
|
-
"aria-label":
|
|
5740
|
-
"aria-describedby":
|
|
5749
|
+
"aria-labelledby": hasVisibleTitle ? titleId : void 0,
|
|
5750
|
+
"aria-label": hasVisibleTitle ? void 0 : ariaLabel,
|
|
5751
|
+
"aria-describedby": hasVisibleDescription ? descId : void 0,
|
|
5741
5752
|
tabIndex: -1,
|
|
5742
5753
|
"data-state": state,
|
|
5754
|
+
"data-placement": placement,
|
|
5743
5755
|
className: cn49(
|
|
5744
|
-
"relative flex
|
|
5756
|
+
"relative flex w-full flex-col overflow-hidden rounded-lg border border-hairline bg-canvas text-ink shadow-modal",
|
|
5757
|
+
isTop ? "max-h-[calc(88dvh-2rem)]" : "max-h-[calc(100dvh-2rem)]",
|
|
5745
5758
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue",
|
|
5746
5759
|
"transition duration-200 ease-out",
|
|
5747
5760
|
"data-[state=open]:translate-y-0 data-[state=open]:scale-100 data-[state=open]:opacity-100",
|
|
@@ -5751,7 +5764,7 @@ var Modal = React55.forwardRef(
|
|
|
5751
5764
|
),
|
|
5752
5765
|
...props,
|
|
5753
5766
|
children: [
|
|
5754
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "flex shrink-0 items-start justify-between gap-base px-lg pt-lg", children: [
|
|
5767
|
+
showHeader ? /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "flex shrink-0 items-start justify-between gap-base px-lg pt-lg", children: [
|
|
5755
5768
|
/* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "flex min-w-0 flex-col gap-sm", children: [
|
|
5756
5769
|
icon ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
5757
5770
|
"span",
|
|
@@ -5780,8 +5793,17 @@ var Modal = React55.forwardRef(
|
|
|
5780
5793
|
onClick: () => onOpenChange(false)
|
|
5781
5794
|
}
|
|
5782
5795
|
) : null
|
|
5783
|
-
] }),
|
|
5784
|
-
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
5796
|
+
] }) : null,
|
|
5797
|
+
/* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
|
|
5798
|
+
"div",
|
|
5799
|
+
{
|
|
5800
|
+
className: cn49(
|
|
5801
|
+
"min-h-0 flex-1 overflow-y-auto overscroll-contain px-lg pb-lg",
|
|
5802
|
+
showHeader && "pt-base"
|
|
5803
|
+
),
|
|
5804
|
+
children
|
|
5805
|
+
}
|
|
5806
|
+
),
|
|
5785
5807
|
footer ? /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "flex shrink-0 items-center justify-end gap-sm px-lg pb-lg", children: footer }) : null
|
|
5786
5808
|
]
|
|
5787
5809
|
}
|
package/dist/index.js
CHANGED
|
@@ -5529,7 +5529,8 @@ var cn49 = (...parts) => parts.filter(Boolean).join(" ");
|
|
|
5529
5529
|
var widths = {
|
|
5530
5530
|
sm: "sm:w-[var(--container-modal-sm,400px)]",
|
|
5531
5531
|
md: "sm:w-[var(--container-modal,480px)]",
|
|
5532
|
-
lg: "sm:w-[var(--container-modal-lg,640px)]"
|
|
5532
|
+
lg: "sm:w-[var(--container-modal-lg,640px)]",
|
|
5533
|
+
xl: "sm:w-[var(--container-modal-xl,640px)]"
|
|
5533
5534
|
};
|
|
5534
5535
|
var Modal = React55.forwardRef(
|
|
5535
5536
|
({
|
|
@@ -5541,6 +5542,8 @@ var Modal = React55.forwardRef(
|
|
|
5541
5542
|
tone = "default",
|
|
5542
5543
|
footer,
|
|
5543
5544
|
size = "md",
|
|
5545
|
+
placement = "center",
|
|
5546
|
+
hideHeader = false,
|
|
5544
5547
|
closeOnScrimClick = true,
|
|
5545
5548
|
hideClose = false,
|
|
5546
5549
|
closeLabel = "Close",
|
|
@@ -5586,13 +5589,21 @@ var Modal = React55.forwardRef(
|
|
|
5586
5589
|
};
|
|
5587
5590
|
if (!mounted) return null;
|
|
5588
5591
|
const state = open ? "open" : "closed";
|
|
5592
|
+
const showHeader = !hideHeader;
|
|
5593
|
+
const hasVisibleTitle = showHeader && Boolean(title);
|
|
5594
|
+
const hasVisibleDescription = showHeader && Boolean(description);
|
|
5595
|
+
const isTop = placement === "top";
|
|
5589
5596
|
return createPortal6(
|
|
5590
5597
|
/* @__PURE__ */ jsxs51(
|
|
5591
5598
|
"div",
|
|
5592
5599
|
{
|
|
5593
5600
|
"data-state": state,
|
|
5601
|
+
"data-placement": placement,
|
|
5594
5602
|
"aria-hidden": !open,
|
|
5595
|
-
className:
|
|
5603
|
+
className: cn49(
|
|
5604
|
+
"fixed inset-0 flex justify-center p-base text-ink transition-[visibility] duration-200 data-[state=closed]:pointer-events-none data-[state=closed]:invisible",
|
|
5605
|
+
isTop ? "items-start pt-[12dvh]" : "items-end sm:items-center"
|
|
5606
|
+
),
|
|
5596
5607
|
style: { zIndex: "var(--z-modal, 1200)" },
|
|
5597
5608
|
children: [
|
|
5598
5609
|
/* @__PURE__ */ jsx55(
|
|
@@ -5610,13 +5621,15 @@ var Modal = React55.forwardRef(
|
|
|
5610
5621
|
ref: setRefs,
|
|
5611
5622
|
role: "dialog",
|
|
5612
5623
|
"aria-modal": "true",
|
|
5613
|
-
"aria-labelledby":
|
|
5614
|
-
"aria-label":
|
|
5615
|
-
"aria-describedby":
|
|
5624
|
+
"aria-labelledby": hasVisibleTitle ? titleId : void 0,
|
|
5625
|
+
"aria-label": hasVisibleTitle ? void 0 : ariaLabel,
|
|
5626
|
+
"aria-describedby": hasVisibleDescription ? descId : void 0,
|
|
5616
5627
|
tabIndex: -1,
|
|
5617
5628
|
"data-state": state,
|
|
5629
|
+
"data-placement": placement,
|
|
5618
5630
|
className: cn49(
|
|
5619
|
-
"relative flex
|
|
5631
|
+
"relative flex w-full flex-col overflow-hidden rounded-lg border border-hairline bg-canvas text-ink shadow-modal",
|
|
5632
|
+
isTop ? "max-h-[calc(88dvh-2rem)]" : "max-h-[calc(100dvh-2rem)]",
|
|
5620
5633
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue",
|
|
5621
5634
|
"transition duration-200 ease-out",
|
|
5622
5635
|
"data-[state=open]:translate-y-0 data-[state=open]:scale-100 data-[state=open]:opacity-100",
|
|
@@ -5626,7 +5639,7 @@ var Modal = React55.forwardRef(
|
|
|
5626
5639
|
),
|
|
5627
5640
|
...props,
|
|
5628
5641
|
children: [
|
|
5629
|
-
/* @__PURE__ */ jsxs51("div", { className: "flex shrink-0 items-start justify-between gap-base px-lg pt-lg", children: [
|
|
5642
|
+
showHeader ? /* @__PURE__ */ jsxs51("div", { className: "flex shrink-0 items-start justify-between gap-base px-lg pt-lg", children: [
|
|
5630
5643
|
/* @__PURE__ */ jsxs51("div", { className: "flex min-w-0 flex-col gap-sm", children: [
|
|
5631
5644
|
icon ? /* @__PURE__ */ jsx55(
|
|
5632
5645
|
"span",
|
|
@@ -5655,8 +5668,17 @@ var Modal = React55.forwardRef(
|
|
|
5655
5668
|
onClick: () => onOpenChange(false)
|
|
5656
5669
|
}
|
|
5657
5670
|
) : null
|
|
5658
|
-
] }),
|
|
5659
|
-
/* @__PURE__ */ jsx55(
|
|
5671
|
+
] }) : null,
|
|
5672
|
+
/* @__PURE__ */ jsx55(
|
|
5673
|
+
"div",
|
|
5674
|
+
{
|
|
5675
|
+
className: cn49(
|
|
5676
|
+
"min-h-0 flex-1 overflow-y-auto overscroll-contain px-lg pb-lg",
|
|
5677
|
+
showHeader && "pt-base"
|
|
5678
|
+
),
|
|
5679
|
+
children
|
|
5680
|
+
}
|
|
5681
|
+
),
|
|
5660
5682
|
footer ? /* @__PURE__ */ jsx55("div", { className: "flex shrink-0 items-center justify-end gap-sm px-lg pb-lg", children: footer }) : null
|
|
5661
5683
|
]
|
|
5662
5684
|
}
|
package/dist/styles.css
CHANGED
|
@@ -311,6 +311,9 @@
|
|
|
311
311
|
.relative {
|
|
312
312
|
position: relative;
|
|
313
313
|
}
|
|
314
|
+
.sticky {
|
|
315
|
+
position: sticky;
|
|
316
|
+
}
|
|
314
317
|
.inset-0 {
|
|
315
318
|
inset: 0;
|
|
316
319
|
}
|
|
@@ -329,6 +332,9 @@
|
|
|
329
332
|
.-top-xxs {
|
|
330
333
|
top: calc(var(--spacing-xxs) * -1);
|
|
331
334
|
}
|
|
335
|
+
.top-0 {
|
|
336
|
+
top: 0;
|
|
337
|
+
}
|
|
332
338
|
.top-1\.5 {
|
|
333
339
|
top: calc(var(--spacing) * 1.5);
|
|
334
340
|
}
|
|
@@ -404,6 +410,9 @@
|
|
|
404
410
|
.m-0 {
|
|
405
411
|
margin: 0;
|
|
406
412
|
}
|
|
413
|
+
.-mx-lg {
|
|
414
|
+
margin-inline: calc(var(--spacing-lg) * -1);
|
|
415
|
+
}
|
|
407
416
|
.-mx-md {
|
|
408
417
|
margin-inline: calc(var(--spacing-md) * -1);
|
|
409
418
|
}
|
package/package.json
CHANGED
|
@@ -2,8 +2,10 @@ import * as React from "react";
|
|
|
2
2
|
import { createPortal } from "react-dom";
|
|
3
3
|
import { IconButton } from "../IconButton";
|
|
4
4
|
|
|
5
|
-
export type ModalSize = "sm" | "md" | "lg";
|
|
5
|
+
export type ModalSize = "sm" | "md" | "lg" | "xl";
|
|
6
6
|
export type ModalTone = "default" | "danger";
|
|
7
|
+
/** `top` anchors the panel near the top of the viewport (e.g. a command palette). */
|
|
8
|
+
export type ModalPlacement = "center" | "top";
|
|
7
9
|
|
|
8
10
|
export interface ModalProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
9
11
|
/** Controlled open state. The dialog stays mounted and animates on `data-state`. */
|
|
@@ -18,6 +20,10 @@ export interface ModalProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "
|
|
|
18
20
|
/** Pinned action row, right-aligned (e.g. Cancel / Create). */
|
|
19
21
|
footer?: React.ReactNode;
|
|
20
22
|
size?: ModalSize;
|
|
23
|
+
/** `center` (default) vertically centers the panel; `top` anchors it 12vh from the top. */
|
|
24
|
+
placement?: ModalPlacement;
|
|
25
|
+
/** Hide the header row (icon, title, description, close). The body loses its top padding and `aria-label` names the dialog. */
|
|
26
|
+
hideHeader?: boolean;
|
|
21
27
|
/** Accessible name when there is no visible `title`. */
|
|
22
28
|
"aria-label"?: string;
|
|
23
29
|
closeOnScrimClick?: boolean;
|
|
@@ -32,6 +38,7 @@ const widths: Record<ModalSize, string> = {
|
|
|
32
38
|
sm: "sm:w-[var(--container-modal-sm,400px)]",
|
|
33
39
|
md: "sm:w-[var(--container-modal,480px)]",
|
|
34
40
|
lg: "sm:w-[var(--container-modal-lg,640px)]",
|
|
41
|
+
xl: "sm:w-[var(--container-modal-xl,640px)]",
|
|
35
42
|
};
|
|
36
43
|
|
|
37
44
|
export const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
@@ -45,6 +52,8 @@ export const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
|
45
52
|
tone = "default",
|
|
46
53
|
footer,
|
|
47
54
|
size = "md",
|
|
55
|
+
placement = "center",
|
|
56
|
+
hideHeader = false,
|
|
48
57
|
closeOnScrimClick = true,
|
|
49
58
|
hideClose = false,
|
|
50
59
|
closeLabel = "Close",
|
|
@@ -98,11 +107,20 @@ export const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
|
98
107
|
if (!mounted) return null;
|
|
99
108
|
const state = open ? "open" : "closed";
|
|
100
109
|
|
|
110
|
+
const showHeader = !hideHeader;
|
|
111
|
+
const hasVisibleTitle = showHeader && Boolean(title);
|
|
112
|
+
const hasVisibleDescription = showHeader && Boolean(description);
|
|
113
|
+
const isTop = placement === "top";
|
|
114
|
+
|
|
101
115
|
return createPortal(
|
|
102
116
|
<div
|
|
103
117
|
data-state={state}
|
|
118
|
+
data-placement={placement}
|
|
104
119
|
aria-hidden={!open}
|
|
105
|
-
className=
|
|
120
|
+
className={cn(
|
|
121
|
+
"fixed inset-0 flex justify-center p-base text-ink transition-[visibility] duration-200 data-[state=closed]:pointer-events-none data-[state=closed]:invisible",
|
|
122
|
+
isTop ? "items-start pt-[12dvh]" : "items-end sm:items-center",
|
|
123
|
+
)}
|
|
106
124
|
style={{ zIndex: "var(--z-modal, 1200)" }}
|
|
107
125
|
>
|
|
108
126
|
<div
|
|
@@ -115,13 +133,15 @@ export const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
|
115
133
|
ref={setRefs}
|
|
116
134
|
role="dialog"
|
|
117
135
|
aria-modal="true"
|
|
118
|
-
aria-labelledby={
|
|
119
|
-
aria-label={
|
|
120
|
-
aria-describedby={
|
|
136
|
+
aria-labelledby={hasVisibleTitle ? titleId : undefined}
|
|
137
|
+
aria-label={hasVisibleTitle ? undefined : ariaLabel}
|
|
138
|
+
aria-describedby={hasVisibleDescription ? descId : undefined}
|
|
121
139
|
tabIndex={-1}
|
|
122
140
|
data-state={state}
|
|
141
|
+
data-placement={placement}
|
|
123
142
|
className={cn(
|
|
124
|
-
"relative flex
|
|
143
|
+
"relative flex w-full flex-col overflow-hidden rounded-lg border border-hairline bg-canvas text-ink shadow-modal",
|
|
144
|
+
isTop ? "max-h-[calc(88dvh-2rem)]" : "max-h-[calc(100dvh-2rem)]",
|
|
125
145
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-blue",
|
|
126
146
|
"transition duration-200 ease-out",
|
|
127
147
|
"data-[state=open]:translate-y-0 data-[state=open]:scale-100 data-[state=open]:opacity-100",
|
|
@@ -131,46 +151,53 @@ export const Modal = React.forwardRef<HTMLDivElement, ModalProps>(
|
|
|
131
151
|
)}
|
|
132
152
|
{...props}
|
|
133
153
|
>
|
|
134
|
-
|
|
135
|
-
<div className="flex
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
<div className="flex flex-col gap-xs">
|
|
150
|
-
{title ? (
|
|
151
|
-
<h2 id={titleId} className="text-heading-sm text-ink">
|
|
152
|
-
{title}
|
|
153
|
-
</h2>
|
|
154
|
-
) : null}
|
|
155
|
-
{description ? (
|
|
156
|
-
<p id={descId} className="text-body-md text-muted">
|
|
157
|
-
{description}
|
|
158
|
-
</p>
|
|
154
|
+
{showHeader ? (
|
|
155
|
+
<div className="flex shrink-0 items-start justify-between gap-base px-lg pt-lg">
|
|
156
|
+
<div className="flex min-w-0 flex-col gap-sm">
|
|
157
|
+
{icon ? (
|
|
158
|
+
<span
|
|
159
|
+
aria-hidden="true"
|
|
160
|
+
className={cn(
|
|
161
|
+
"inline-flex size-9 items-center justify-center rounded-sm",
|
|
162
|
+
tone === "danger"
|
|
163
|
+
? "bg-semantic-error-soft text-semantic-error"
|
|
164
|
+
: "bg-surface-soft text-ink",
|
|
165
|
+
)}
|
|
166
|
+
>
|
|
167
|
+
{icon}
|
|
168
|
+
</span>
|
|
159
169
|
) : null}
|
|
170
|
+
<div className="flex flex-col gap-xs">
|
|
171
|
+
{title ? (
|
|
172
|
+
<h2 id={titleId} className="text-heading-sm text-ink">
|
|
173
|
+
{title}
|
|
174
|
+
</h2>
|
|
175
|
+
) : null}
|
|
176
|
+
{description ? (
|
|
177
|
+
<p id={descId} className="text-body-md text-muted">
|
|
178
|
+
{description}
|
|
179
|
+
</p>
|
|
180
|
+
) : null}
|
|
181
|
+
</div>
|
|
160
182
|
</div>
|
|
183
|
+
{!hideClose ? (
|
|
184
|
+
<IconButton
|
|
185
|
+
icon="x"
|
|
186
|
+
aria-label={closeLabel}
|
|
187
|
+
variant="ghost"
|
|
188
|
+
size="md"
|
|
189
|
+
className="-mr-xs -mt-xs"
|
|
190
|
+
onClick={() => onOpenChange(false)}
|
|
191
|
+
/>
|
|
192
|
+
) : null}
|
|
161
193
|
</div>
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
onClick={() => onOpenChange(false)}
|
|
170
|
-
/>
|
|
171
|
-
) : null}
|
|
172
|
-
</div>
|
|
173
|
-
<div className="min-h-0 flex-1 overflow-y-auto overscroll-contain px-lg pt-base pb-lg">
|
|
194
|
+
) : null}
|
|
195
|
+
<div
|
|
196
|
+
className={cn(
|
|
197
|
+
"min-h-0 flex-1 overflow-y-auto overscroll-contain px-lg pb-lg",
|
|
198
|
+
showHeader && "pt-base",
|
|
199
|
+
)}
|
|
200
|
+
>
|
|
174
201
|
{children}
|
|
175
202
|
</div>
|
|
176
203
|
{footer ? (
|
|
@@ -3,18 +3,51 @@ import { Modal } from "./Modal";
|
|
|
3
3
|
import { Button } from "../Button";
|
|
4
4
|
import { Input } from "../Input";
|
|
5
5
|
import { Icon } from "../Icon";
|
|
6
|
+
import { SearchBar } from "../SearchBar";
|
|
7
|
+
import { ListItem } from "../ListItem";
|
|
6
8
|
|
|
7
|
-
type Which = "learn" | "create" | "delete" | null;
|
|
9
|
+
type Which = "learn" | "create" | "delete" | "palette" | null;
|
|
10
|
+
|
|
11
|
+
const groups: Array<{
|
|
12
|
+
label: string;
|
|
13
|
+
items: Array<{ id: string; icon: "file" | "folder" | "users" | "settings"; label: string; meta?: string }>;
|
|
14
|
+
}> = [
|
|
15
|
+
{
|
|
16
|
+
label: "Pages",
|
|
17
|
+
items: [
|
|
18
|
+
{ id: "p1", icon: "file", label: "Overview", meta: "Dash" },
|
|
19
|
+
{ id: "p2", icon: "file", label: "Usage report", meta: "Dash" },
|
|
20
|
+
{ id: "p3", icon: "file", label: "Billing history", meta: "Dash" },
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: "Workspace",
|
|
25
|
+
items: [
|
|
26
|
+
{ id: "w1", icon: "folder", label: "Default project", meta: "Open" },
|
|
27
|
+
{ id: "w2", icon: "users", label: "Invite a teammate", meta: "Team" },
|
|
28
|
+
{ id: "w3", icon: "settings", label: "Workspace settings", meta: "Config" },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
];
|
|
8
32
|
|
|
9
33
|
export default function ModalPreview() {
|
|
10
34
|
const [open, setOpen] = React.useState<Which>(null);
|
|
11
35
|
const [project, setProject] = React.useState("Default project");
|
|
36
|
+
const [query, setQuery] = React.useState("");
|
|
12
37
|
const [log, setLog] = React.useState("Open a dialog.");
|
|
13
38
|
const close = () => setOpen(null);
|
|
14
39
|
const onOpenChange = (v: boolean) => {
|
|
15
40
|
if (!v) close();
|
|
16
41
|
};
|
|
17
42
|
|
|
43
|
+
const needle = query.trim().toLowerCase();
|
|
44
|
+
const filtered = groups
|
|
45
|
+
.map((g) => ({
|
|
46
|
+
...g,
|
|
47
|
+
items: g.items.filter((i) => i.label.toLowerCase().includes(needle)),
|
|
48
|
+
}))
|
|
49
|
+
.filter((g) => g.items.length > 0);
|
|
50
|
+
|
|
18
51
|
return (
|
|
19
52
|
<div className="w-full max-w-3xl mx-auto p-lg">
|
|
20
53
|
<div className="flex flex-wrap items-center gap-sm rounded-lg border border-hairline bg-canvas p-lg">
|
|
@@ -27,6 +60,9 @@ export default function ModalPreview() {
|
|
|
27
60
|
<Button variant="danger" onClick={() => setOpen("delete")}>
|
|
28
61
|
Delete project
|
|
29
62
|
</Button>
|
|
63
|
+
<Button variant="soft" onClick={() => setOpen("palette")}>
|
|
64
|
+
Command palette
|
|
65
|
+
</Button>
|
|
30
66
|
<span className="text-body-sm text-muted">{log}</span>
|
|
31
67
|
</div>
|
|
32
68
|
|
|
@@ -104,6 +140,53 @@ export default function ModalPreview() {
|
|
|
104
140
|
</>
|
|
105
141
|
}
|
|
106
142
|
/>
|
|
143
|
+
|
|
144
|
+
<Modal
|
|
145
|
+
open={open === "palette"}
|
|
146
|
+
onOpenChange={onOpenChange}
|
|
147
|
+
placement="top"
|
|
148
|
+
hideHeader
|
|
149
|
+
size="xl"
|
|
150
|
+
aria-label="Command palette"
|
|
151
|
+
>
|
|
152
|
+
<div className="sticky top-0 -mx-lg border-b border-hairline bg-canvas px-lg">
|
|
153
|
+
<SearchBar
|
|
154
|
+
label="Search commands and pages"
|
|
155
|
+
placeholder="Search commands and pages…"
|
|
156
|
+
value={query}
|
|
157
|
+
onValueChange={setQuery}
|
|
158
|
+
buttonLabel="Go"
|
|
159
|
+
formClassName="py-base"
|
|
160
|
+
/>
|
|
161
|
+
</div>
|
|
162
|
+
<div className="flex flex-col gap-lg pt-base">
|
|
163
|
+
{filtered.length === 0 ? (
|
|
164
|
+
<p className="py-lg text-center text-body-sm text-muted">No matches for “{query}”.</p>
|
|
165
|
+
) : (
|
|
166
|
+
filtered.map((group) => (
|
|
167
|
+
<div key={group.label} className="flex flex-col gap-xs">
|
|
168
|
+
<p className="px-xs text-body-sm text-muted">{group.label}</p>
|
|
169
|
+
<ul className="flex flex-col gap-xs">
|
|
170
|
+
{group.items.map((item) => (
|
|
171
|
+
<li key={item.id}>
|
|
172
|
+
<ListItem
|
|
173
|
+
icon={item.icon}
|
|
174
|
+
label={item.label}
|
|
175
|
+
meta={item.meta}
|
|
176
|
+
onClick={(e) => {
|
|
177
|
+
e.preventDefault();
|
|
178
|
+
setLog(`Ran “${item.label}”.`);
|
|
179
|
+
close();
|
|
180
|
+
}}
|
|
181
|
+
/>
|
|
182
|
+
</li>
|
|
183
|
+
))}
|
|
184
|
+
</ul>
|
|
185
|
+
</div>
|
|
186
|
+
))
|
|
187
|
+
)}
|
|
188
|
+
</div>
|
|
189
|
+
</Modal>
|
|
107
190
|
</div>
|
|
108
191
|
);
|
|
109
192
|
}
|