|
| 1 | +import "@reach/dialog/styles.css"; |
| 2 | + |
| 3 | +import React from "react"; |
| 4 | +import { DialogOverlay, DialogContent } from "@reach/dialog"; |
| 5 | + |
| 6 | +export let name = "With Wrapped Components"; |
| 7 | + |
| 8 | +const FilteredDialogContent = React.forwardRef(({ fakeProp, ...rest }, ref) => ( |
| 9 | + <DialogContent |
| 10 | + {...rest} |
| 11 | + ref={ref} |
| 12 | + style={{ boxShadow: "0px 10px 50px hsla(0, 0%, 0%, 0.33)" }} |
| 13 | + /> |
| 14 | +)); |
| 15 | + |
| 16 | +const FilteredDialogOverlay = React.forwardRef(({ fakeProp, ...rest }, ref) => ( |
| 17 | + <DialogOverlay |
| 18 | + {...rest} |
| 19 | + ref={ref} |
| 20 | + style={{ background: "rgba(0, 50, 150, 0.9)" }} |
| 21 | + /> |
| 22 | +)); |
| 23 | + |
| 24 | +export let Example = () => { |
| 25 | + const overlayRef = React.useRef(null); |
| 26 | + const contentRef = React.useRef(null); |
| 27 | + const [showDialog, setShowDialog] = React.useState(false); |
| 28 | + const open = () => setShowDialog(true); |
| 29 | + const close = () => setShowDialog(false); |
| 30 | + |
| 31 | + return ( |
| 32 | + <div> |
| 33 | + <button onClick={open}>Show Dialog</button> |
| 34 | + |
| 35 | + <FilteredDialogOverlay |
| 36 | + fakeProp="this should do nothing" |
| 37 | + ref={overlayRef} |
| 38 | + isOpen={showDialog} |
| 39 | + onDismiss={close} |
| 40 | + > |
| 41 | + <FilteredDialogContent |
| 42 | + fakeProp="blah" |
| 43 | + aria-label="Announcement" |
| 44 | + ref={contentRef} |
| 45 | + > |
| 46 | + <p>Got a case of the blues?</p> |
| 47 | + <button onClick={close}>So blue</button> |
| 48 | + </FilteredDialogContent> |
| 49 | + </FilteredDialogOverlay> |
| 50 | + </div> |
| 51 | + ); |
| 52 | +}; |
0 commit comments