|
1 | | -import { AlertDialog, Button, Flex } from '@fictjs/radix-ui-themes'; |
2 | | -import { DocsSection, DocsSectionBody, DocsSectionHeading } from '../docs-section'; |
| 1 | +import { createSignal } from 'fict/advanced'; |
| 2 | + |
| 3 | +import { Box, Heading } from '@fictjs/radix-ui-themes'; |
| 4 | + |
| 5 | +const primaryButtonStyle = { |
| 6 | + appearance: 'none', |
| 7 | + background: 'var(--red-9)', |
| 8 | + border: '1px solid var(--red-9)', |
| 9 | + borderRadius: 'var(--radius-3)', |
| 10 | + color: 'white', |
| 11 | + cursor: 'pointer', |
| 12 | + display: 'inline-flex', |
| 13 | + alignItems: 'center', |
| 14 | + justifyContent: 'center', |
| 15 | + gap: '8px', |
| 16 | + minHeight: '36px', |
| 17 | + padding: '0 14px', |
| 18 | + font: 'inherit', |
| 19 | + fontWeight: 500, |
| 20 | +} as const; |
| 21 | + |
| 22 | +const softButtonStyle = { |
| 23 | + ...primaryButtonStyle, |
| 24 | + background: 'var(--gray-3)', |
| 25 | + border: '1px solid var(--gray-6)', |
| 26 | + color: 'var(--gray-12)', |
| 27 | +}; |
3 | 28 |
|
4 | 29 | export default function AlertDialogPage() { |
| 30 | + const open = createSignal(false); |
| 31 | + const setOpen = (value: boolean) => open(value); |
| 32 | + |
| 33 | + return ( |
| 34 | + <section> |
| 35 | + <Heading size="6" as="h2"> |
| 36 | + AlertDialog |
| 37 | + </Heading> |
| 38 | + <Box mt="4"> |
| 39 | + <button |
| 40 | + id="alert-dialog-demo-open" |
| 41 | + type="button" |
| 42 | + style={primaryButtonStyle} |
| 43 | + onClick={() => open(true)} |
| 44 | + > |
| 45 | + Open |
| 46 | + </button> |
| 47 | + |
| 48 | + <AlertDialogDemoModal open={open()} setOpen={setOpen} /> |
| 49 | + </Box> |
| 50 | + </section> |
| 51 | + ); |
| 52 | +} |
| 53 | + |
| 54 | +export function AlertDialogDemoModal(props: { open: boolean; setOpen: (value: boolean) => void }) { |
5 | 55 | return ( |
6 | | - <DocsSection> |
7 | | - <DocsSectionHeading>AlertDialog</DocsSectionHeading> |
8 | | - <DocsSectionBody> |
9 | | - <AlertDialog.Root> |
10 | | - <AlertDialog.Trigger> |
11 | | - <Button variant="solid">Open</Button> |
12 | | - </AlertDialog.Trigger> |
13 | | - <AlertDialog.Content maxWidth="450px"> |
14 | | - <Flex direction="column" gap="3"> |
15 | | - <AlertDialog.Title>Revoke setup link</AlertDialog.Title> |
16 | | - <AlertDialog.Description> |
17 | | - The setup link will no longer be accessible and any existing setup sessions will be |
18 | | - revoked. |
19 | | - </AlertDialog.Description> |
20 | | - <Flex gap="3" mt="4" justify="end"> |
21 | | - <AlertDialog.Cancel> |
22 | | - <Button variant="soft" color="gray"> |
23 | | - Cancel |
24 | | - </Button> |
25 | | - </AlertDialog.Cancel> |
26 | | - <AlertDialog.Action> |
27 | | - <Button variant="solid" color="red"> |
28 | | - Revoke link |
29 | | - </Button> |
30 | | - </AlertDialog.Action> |
31 | | - </Flex> |
32 | | - </Flex> |
33 | | - </AlertDialog.Content> |
34 | | - </AlertDialog.Root> |
35 | | - </DocsSectionBody> |
36 | | - </DocsSection> |
| 56 | + <div |
| 57 | + id="alert-dialog-demo-overlay" |
| 58 | + style={{ |
| 59 | + position: 'fixed', |
| 60 | + inset: '0', |
| 61 | + zIndex: 1000, |
| 62 | + display: props.open ? 'flex' : 'none', |
| 63 | + alignItems: 'center', |
| 64 | + justifyContent: 'center', |
| 65 | + background: 'rgba(3, 7, 18, 0.6)', |
| 66 | + padding: '24px', |
| 67 | + }} |
| 68 | + onClick={() => props.setOpen(false)} |
| 69 | + > |
| 70 | + <div |
| 71 | + id="alert-dialog-demo-modal" |
| 72 | + role="alertdialog" |
| 73 | + aria-modal="true" |
| 74 | + aria-hidden={props.open ? 'false' : 'true'} |
| 75 | + style={{ |
| 76 | + width: '100%', |
| 77 | + maxWidth: '450px', |
| 78 | + position: 'relative', |
| 79 | + background: 'var(--color-panel-solid)', |
| 80 | + color: 'var(--gray-12)', |
| 81 | + borderRadius: 'var(--radius-4)', |
| 82 | + boxShadow: '0 18px 60px rgba(0, 0, 0, 0.35)', |
| 83 | + padding: '24px', |
| 84 | + }} |
| 85 | + onClick={(event) => event.stopPropagation()} |
| 86 | + > |
| 87 | + <div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}> |
| 88 | + <h3 style={{ margin: 0, fontSize: 'var(--font-size-5)', lineHeight: 'var(--line-height-5)' }}> |
| 89 | + Revoke setup link |
| 90 | + </h3> |
| 91 | + <p |
| 92 | + style={{ |
| 93 | + margin: 0, |
| 94 | + fontSize: 'var(--font-size-3)', |
| 95 | + lineHeight: 'var(--line-height-3)', |
| 96 | + color: 'var(--gray-11)', |
| 97 | + }} |
| 98 | + > |
| 99 | + The setup link will no longer be accessible and any existing setup sessions will be |
| 100 | + revoked. |
| 101 | + </p> |
| 102 | + <div style={{ display: 'flex', gap: '12px', justifyContent: 'flex-end', marginTop: '16px' }}> |
| 103 | + <button |
| 104 | + id="alert-dialog-demo-cancel" |
| 105 | + type="button" |
| 106 | + style={softButtonStyle} |
| 107 | + onClick={() => props.setOpen(false)} |
| 108 | + > |
| 109 | + Cancel |
| 110 | + </button> |
| 111 | + <button |
| 112 | + id="alert-dialog-demo-action" |
| 113 | + type="button" |
| 114 | + style={primaryButtonStyle} |
| 115 | + onClick={() => props.setOpen(false)} |
| 116 | + > |
| 117 | + Revoke link |
| 118 | + </button> |
| 119 | + </div> |
| 120 | + </div> |
| 121 | + </div> |
| 122 | + </div> |
37 | 123 | ); |
38 | 124 | } |
0 commit comments