|
6 | 6 | Combobox, |
7 | 7 | DropdownMenu, |
8 | 8 | } from "@cloudflare/kumo"; |
| 9 | +import type { DialogProps } from "@cloudflare/kumo"; |
9 | 10 | import { Warning, X } from "@phosphor-icons/react"; |
10 | 11 |
|
11 | 12 | export function DialogBasicDemo() { |
@@ -383,3 +384,97 @@ export function DialogWithDropdownDemo() { |
383 | 384 | </Dialog.Root> |
384 | 385 | ); |
385 | 386 | } |
| 387 | + |
| 388 | +/** |
| 389 | + * Demonstrates that each dialog size holds its fixed width regardless of |
| 390 | + * content. Each dialog contains a wide table that would previously cause the |
| 391 | + * dialog to stretch beyond its intended size. |
| 392 | + */ |
| 393 | +export function DialogSizesDemo() { |
| 394 | + const sizes: { size: NonNullable<DialogProps["size"]>; label: string; width: string }[] = [ |
| 395 | + { size: "sm", label: "Small", width: "288px" }, |
| 396 | + { size: "base", label: "Base", width: "384px" }, |
| 397 | + { size: "lg", label: "Large", width: "512px" }, |
| 398 | + { size: "xl", label: "Extra Large", width: "768px" }, |
| 399 | + ]; |
| 400 | + |
| 401 | + return ( |
| 402 | + <div className="flex flex-wrap gap-2"> |
| 403 | + {sizes.map(({ size, label, width }) => ( |
| 404 | + <Dialog.Root key={size}> |
| 405 | + <Dialog.Trigger |
| 406 | + render={(p) => ( |
| 407 | + <Button variant="secondary" {...p}> |
| 408 | + {label} ({width}) |
| 409 | + </Button> |
| 410 | + )} |
| 411 | + /> |
| 412 | + <Dialog size={size} className="p-8"> |
| 413 | + <div className="mb-4 flex items-start justify-between gap-4"> |
| 414 | + <Dialog.Title className="text-2xl font-semibold"> |
| 415 | + {label} Dialog |
| 416 | + </Dialog.Title> |
| 417 | + <Dialog.Close |
| 418 | + aria-label="Close" |
| 419 | + render={(props) => ( |
| 420 | + <Button |
| 421 | + {...props} |
| 422 | + variant="secondary" |
| 423 | + shape="square" |
| 424 | + icon={<X />} |
| 425 | + aria-label="Close" |
| 426 | + /> |
| 427 | + )} |
| 428 | + /> |
| 429 | + </div> |
| 430 | + <Dialog.Description className="text-kumo-subtle"> |
| 431 | + This <code>size="{size}"</code> dialog should stay at {width} wide |
| 432 | + regardless of the content below. |
| 433 | + </Dialog.Description> |
| 434 | + <div className="mt-4 overflow-auto rounded-md border border-kumo-line"> |
| 435 | + <table className="w-max text-sm"> |
| 436 | + <thead className="bg-kumo-elevated text-left"> |
| 437 | + <tr> |
| 438 | + <th className="px-3 py-2">Resource</th> |
| 439 | + <th className="px-3 py-2">Region</th> |
| 440 | + <th className="px-3 py-2">Status</th> |
| 441 | + <th className="px-3 py-2">Latency</th> |
| 442 | + <th className="px-3 py-2">Requests</th> |
| 443 | + <th className="px-3 py-2">Last Deployed</th> |
| 444 | + </tr> |
| 445 | + </thead> |
| 446 | + <tbody className="divide-y divide-kumo-hairline"> |
| 447 | + <tr> |
| 448 | + <td className="px-3 py-2">api-gateway-prod</td> |
| 449 | + <td className="px-3 py-2">us-east-1</td> |
| 450 | + <td className="px-3 py-2 text-kumo-success">Healthy</td> |
| 451 | + <td className="px-3 py-2">12ms</td> |
| 452 | + <td className="px-3 py-2">1,234,567</td> |
| 453 | + <td className="px-3 py-2">2026-06-23</td> |
| 454 | + </tr> |
| 455 | + <tr> |
| 456 | + <td className="px-3 py-2">worker-analytics</td> |
| 457 | + <td className="px-3 py-2">eu-west-1</td> |
| 458 | + <td className="px-3 py-2 text-kumo-warning">Degraded</td> |
| 459 | + <td className="px-3 py-2">89ms</td> |
| 460 | + <td className="px-3 py-2">456,789</td> |
| 461 | + <td className="px-3 py-2">2026-06-22</td> |
| 462 | + </tr> |
| 463 | + </tbody> |
| 464 | + </table> |
| 465 | + </div> |
| 466 | + <div className="mt-6 flex justify-end gap-2"> |
| 467 | + <Dialog.Close |
| 468 | + render={(props) => ( |
| 469 | + <Button variant="secondary" {...props}> |
| 470 | + Close |
| 471 | + </Button> |
| 472 | + )} |
| 473 | + /> |
| 474 | + </div> |
| 475 | + </Dialog> |
| 476 | + </Dialog.Root> |
| 477 | + ))} |
| 478 | + </div> |
| 479 | + ); |
| 480 | +} |
0 commit comments