Skip to content

Commit a2eaa7b

Browse files
authored
Merge pull request #73 from microcmsio/feature/dialog-element
[feature] Modal components with <dialog> element
2 parents 920f253 + b32d0b0 commit a2eaa7b

16 files changed

+21920
-518
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ $ npm run watch
210210
### Start demo
211211
212212
```
213-
$ npm start
213+
$ npm run start:demo
214214
```
215215
216216
Then access it on http://localhost:3001/react-hooks-use-modal

css-modules.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '*.module.css' {
2+
const classes: { readonly [key: string]: string };
3+
export default classes;
4+
}

examples-routes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ module.exports = [
1313
path: '/components-option',
1414
title: 'useModal with components option example',
1515
},
16+
{
17+
path: '/future',
18+
title: 'Future useModal example',
19+
},
1620
];

examples/src/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { ModalWrapper as ComponentsOptionModal } from './js/components-option';
88
import { Modal as InitialValueModal } from './js/initial-value';
99
import { ModalWrapper as ModalProviderModal } from './js/modal-config';
1010
import { Modal as PreventScrollModal } from './js/prevent-scroll';
11+
import { Modal as FutureCommonModal } from './js/future';
1112

1213
const CurrentModal = () => {
1314
switch (
@@ -27,6 +28,9 @@ const CurrentModal = () => {
2728
case '/components-option': {
2829
return <ComponentsOptionModal />;
2930
}
31+
case '/future': {
32+
return <FutureCommonModal />;
33+
}
3034
default: {
3135
return <CommonModal />;
3236
}

examples/src/js/future/index.tsx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import React, { useState } from 'react';
2+
3+
import { useModal } from '../../../../src/future';
4+
5+
const contentStyle1: React.CSSProperties = {
6+
width: '400px',
7+
padding: '10px 40px 40px',
8+
backgroundColor: '#fff',
9+
borderRadius: '10px',
10+
};
11+
const contentStyle2: React.CSSProperties = {
12+
width: '400px',
13+
height: '100%',
14+
padding: '10px 40px 40px',
15+
boxSizing: 'border-box',
16+
backgroundColor: '#fff',
17+
borderRadius: '10px',
18+
};
19+
const dialogStyle2: React.CSSProperties = {
20+
justifyContent: 'flex-end',
21+
};
22+
23+
export const Modal = () => {
24+
const [Modal1, open1, close1, isOpen1] = useModal();
25+
const [Modal2, open2, close2] = useModal();
26+
const [value, setValue] = useState('');
27+
28+
return (
29+
<div>
30+
<div>Modal is Open? {isOpen1 ? 'Yes' : 'No'}</div>
31+
<button onClick={open1}>OPEN</button>
32+
<Modal1
33+
title="Title"
34+
description="This is a customizable modal."
35+
contentProps={{
36+
style: contentStyle1,
37+
}}
38+
>
39+
<input
40+
type="text"
41+
value={value}
42+
onChange={(e) => setValue(e.target.value)}
43+
/>
44+
<button onClick={close1}>CLOSE</button>
45+
<button onClick={open2}>OPEN 2</button>
46+
</Modal1>
47+
<Modal2
48+
title="Title"
49+
description="This is a customizable modal."
50+
dialogProps={{
51+
style: dialogStyle2,
52+
}}
53+
contentProps={{
54+
style: contentStyle2,
55+
}}
56+
>
57+
<button onClick={close2}>CLOSE</button>
58+
</Modal2>
59+
</div>
60+
);
61+
};

0 commit comments

Comments
 (0)