|
12 | 12 |
|
13 | 13 | import {Button, ComboBox, Dialog, DialogTrigger, Heading, Input, Label, ListBox, Modal, ModalOverlay, Popover, TextField} from 'react-aria-components';
|
14 | 14 | import {Meta, StoryFn} from '@storybook/react';
|
15 |
| -import React, {useEffect} from 'react'; |
| 15 | +import React from 'react'; |
16 | 16 | import './styles.css';
|
17 | 17 | import {MyListBoxItem} from './utils';
|
18 | 18 | import styles from '../example/index.css';
|
@@ -69,129 +69,6 @@ export const ModalExample: ModalStory = () => (
|
69 | 69 | </DialogTrigger>
|
70 | 70 | );
|
71 | 71 |
|
72 |
| -export const ModalInteractionOutsideExample: ModalStory = () => { |
73 |
| - |
74 |
| - useEffect(() => { |
75 |
| - let button = document.createElement('button'); |
76 |
| - button.id = 'test-button'; |
77 |
| - button.textContent = 'Click to close'; |
78 |
| - button.style.position = 'fixed'; |
79 |
| - button.style.top = '0'; |
80 |
| - button.style.right = '0'; |
81 |
| - button.style.zIndex = '200'; |
82 |
| - document.body.appendChild(button); |
83 |
| - |
84 |
| - return () => { |
85 |
| - document.body.removeChild(button); |
86 |
| - }; |
87 |
| - }, []); |
88 |
| - |
89 |
| - return ( |
90 |
| - <DialogTrigger> |
91 |
| - <Button>Open modal</Button> |
92 |
| - <ModalOverlay |
93 |
| - isDismissable |
94 |
| - shouldCloseOnInteractOutside={el => { |
95 |
| - if (el.id === 'test-button') {return true;} |
96 |
| - return false; |
97 |
| - }} |
98 |
| - style={{ |
99 |
| - position: 'fixed', |
100 |
| - zIndex: 100, |
101 |
| - top: 0, |
102 |
| - left: 0, |
103 |
| - bottom: 0, |
104 |
| - right: 0, |
105 |
| - background: 'rgba(0, 0, 0, 0.5)', |
106 |
| - display: 'flex', |
107 |
| - alignItems: 'center', |
108 |
| - justifyContent: 'center' |
109 |
| - }}> |
110 |
| - <Modal |
111 |
| - style={{ |
112 |
| - background: 'Canvas', |
113 |
| - color: 'CanvasText', |
114 |
| - border: '1px solid gray', |
115 |
| - padding: 30 |
116 |
| - }}> |
117 |
| - <Dialog> |
118 |
| - {({close}) => ( |
119 |
| - <form style={{display: 'flex', flexDirection: 'column'}}> |
120 |
| - <Heading slot="title" style={{marginTop: 0}}>Sign up</Heading> |
121 |
| - <label> |
122 |
| - First Name: <input placeholder="John" /> |
123 |
| - </label> |
124 |
| - <label> |
125 |
| - Last Name: <input placeholder="Smith" /> |
126 |
| - </label> |
127 |
| - <Button onPress={close} style={{marginTop: 10}}> |
128 |
| - Submit |
129 |
| - </Button> |
130 |
| - </form> |
131 |
| - )} |
132 |
| - </Dialog> |
133 |
| - </Modal> |
134 |
| - </ModalOverlay> |
135 |
| - </DialogTrigger> |
136 |
| - ); |
137 |
| -}; |
138 |
| - |
139 |
| -export const ModalInteractionOutsideDefaultOverlayExample: ModalStory = () => { |
140 |
| - |
141 |
| - useEffect(() => { |
142 |
| - let button = document.createElement('button'); |
143 |
| - button.id = 'test-button'; |
144 |
| - button.textContent = 'Click to close'; |
145 |
| - button.style.position = 'fixed'; |
146 |
| - button.style.top = '0'; |
147 |
| - button.style.right = '0'; |
148 |
| - button.style.zIndex = '200'; |
149 |
| - document.body.appendChild(button); |
150 |
| - return () => { |
151 |
| - document.body.removeChild(button); |
152 |
| - }; |
153 |
| - }, []); |
154 |
| - |
155 |
| - return ( |
156 |
| - <DialogTrigger> |
157 |
| - <Button>Open modal</Button> |
158 |
| - <Modal |
159 |
| - isDismissable |
160 |
| - shouldCloseOnInteractOutside={el => { |
161 |
| - if (el.id === 'test-button') {return true;} |
162 |
| - return false; |
163 |
| - }} |
164 |
| - style={{ |
165 |
| - position: 'fixed', |
166 |
| - top: '50%', |
167 |
| - left: '50%', |
168 |
| - transform: 'translate(-50%, -50%)', |
169 |
| - background: 'Canvas', |
170 |
| - color: 'CanvasText', |
171 |
| - border: '1px solid gray', |
172 |
| - padding: 30 |
173 |
| - }}> |
174 |
| - <Dialog> |
175 |
| - {({close}) => ( |
176 |
| - <form style={{display: 'flex', flexDirection: 'column'}}> |
177 |
| - <Heading slot="title" style={{marginTop: 0}}>Sign up</Heading> |
178 |
| - <label> |
179 |
| - First Name: <input placeholder="John" /> |
180 |
| - </label> |
181 |
| - <label> |
182 |
| - Last Name: <input placeholder="Smith" /> |
183 |
| - </label> |
184 |
| - <Button onPress={close} style={{marginTop: 10}}> |
185 |
| - Submit |
186 |
| - </Button> |
187 |
| - </form> |
188 |
| - )} |
189 |
| - </Dialog> |
190 |
| - </Modal> |
191 |
| - </DialogTrigger> |
192 |
| - ); |
193 |
| -}; |
194 |
| - |
195 | 72 | function InertTest() {
|
196 | 73 | return (
|
197 | 74 | <DialogTrigger>
|
|
0 commit comments