Skip to content

Commit e4227ff

Browse files
authored
The file structure of the examples page has been adjusted. (#54)
* htmlの内容はほぼ同じなため、templateContentを使う * topのモーダルのオプションを削除する * prevent-scrollページ作成 WIP
1 parent fad41ca commit e4227ff

File tree

11 files changed

+69
-102
lines changed

11 files changed

+69
-102
lines changed

examples-routes.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module.exports = [
2+
{ path: '/', title: 'useModal example' },
3+
{ path: '/prevent-scroll', title: 'useModal with preventScroll example' },
4+
{ path: '/close-button', title: 'useModal with closeButton example' },
5+
{
6+
path: '/close-button/render-option',
7+
title: 'useModal with renderCloseButton option example',
8+
},
9+
{ path: '/modal-config', title: 'useModal with ModalConfig example' },
10+
];

examples/src/close-button/index.html

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/src/close-button/render-option/index.html

Lines changed: 0 additions & 14 deletions
This file was deleted.

examples/src/index.html

Lines changed: 0 additions & 16 deletions
This file was deleted.

examples/src/index.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import React, { PropsWithChildren } from 'react';
22
import { render } from 'react-dom';
33

4+
import routes from '../../examples-routes';
5+
46
import { Modal as CommonModal } from './js';
57
import { Modal as CloseButtonModal } from './js/close-button';
68
import { Modal as CloseButtonWithRenderOptionModal } from './js/close-button/render-option';
79
import { ModalWrapper as ModalConfigModal } from './js/modal-config';
10+
import { Modal as PreventScrollModal } from './js/prevent-scroll';
811

912
const CurrentModal = () => {
1013
switch (
1114
window.location.pathname
1215
.replace(/^\/react-hooks-use-modal/, '')
1316
.replace(/\/$/, '')
1417
) {
18+
case '/prevent-scroll': {
19+
return <PreventScrollModal />;
20+
}
1521
case '/close-button': {
1622
return <CloseButtonModal />;
1723
}
@@ -27,23 +33,17 @@ const CurrentModal = () => {
2733
}
2834
};
2935

30-
const routes = [
31-
'/',
32-
'/close-button',
33-
'/close-button/render-option',
34-
'/modal-config',
35-
];
3636
const Wrapper = ({ children }: PropsWithChildren<{}>) => {
3737
return (
3838
<div>
3939
{children}
4040
<nav style={{ marginTop: '40px' }}>
41-
{routes.map((route, i) => (
41+
{routes.map(({ path }, i) => (
4242
<a
43-
href={`/react-hooks-use-modal${route}`}
43+
href={`/react-hooks-use-modal${path}`}
4444
style={{ marginLeft: i !== 0 ? '10px' : '' }}
4545
>
46-
{route}
46+
{path}
4747
</a>
4848
))}
4949
</nav>

examples/src/js/index.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@ const modalStyle: React.CSSProperties = {
99
};
1010

1111
export const Modal = () => {
12-
const [Modal, open, close, isOpen] = useModal('root', {
13-
preventScroll: true,
14-
focusTrapOptions: {
15-
clickOutsideDeactivates: false,
16-
},
17-
});
12+
const [Modal, open, close, isOpen] = useModal('root');
1813

1914
return (
2015
<div>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react';
2+
3+
import { useModal } from '../../../../src';
4+
5+
const modalStyle: React.CSSProperties = {
6+
backgroundColor: '#fff',
7+
padding: '60px 100px',
8+
borderRadius: '10px',
9+
};
10+
11+
export const Modal = () => {
12+
const [Modal, open, close, isOpen] = useModal('root', {
13+
preventScroll: true,
14+
});
15+
16+
return (
17+
<div>
18+
<div>Modal is Open? {isOpen ? 'Yes' : 'No'}</div>
19+
<button onClick={open}>OPEN</button>
20+
<Modal>
21+
<div style={modalStyle}>
22+
<h1>Title</h1>
23+
<p>This is a customizable modal.</p>
24+
<button onClick={close}>CLOSE</button>
25+
</div>
26+
</Modal>
27+
</div>
28+
);
29+
};

examples/src/modal-config/index.html

Lines changed: 0 additions & 14 deletions
This file was deleted.

package-lock.json

Lines changed: 0 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"eslint-config-prettier": "^8.5.0",
3131
"eslint-config-react-app": "^7.0.1",
3232
"gh-pages": "^2.1.1",
33-
"globby": "^11.1.0",
3433
"html-webpack-plugin": "^5.3.2",
3534
"husky": "^8.0.1",
3635
"lint-staged": "^13.0.3",

0 commit comments

Comments
 (0)