Skip to content

Commit 3f620aa

Browse files
authored
feat: new documentation website ✨ (#450)
1 parent ce59bad commit 3f620aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4249
-11998
lines changed

.github/workflows/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
run: yarn workspace react-responsive-modal build
4848

4949
- name: Build docs
50-
run: yarn workspace react-responsive-modal docz:build
50+
run: yarn workspace website build
5151

5252
- name: Cypress run
5353
uses: cypress-io/github-action@v2
@@ -56,4 +56,4 @@ jobs:
5656
install: false
5757
# Use monorepo
5858
project: ./react-responsive-modal
59-
start: yarn dlx serve -l 3000 react-responsive-modal/.docz/dist
59+
start: yarn workspace website start -p 3000

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ node_modules
44
.cache
55
dist
66
coverage
7-
.docz
7+
.next
8+
out
89
.yarn/*
910
!.yarn/releases
1011
!.yarn/plugins
1112
.pnp.*
13+
.next

.prettierignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
dist
2-
.docz
2+
.next
3+
out
34
coverage
45
.yarn
56
CHANGELOG.md

.yarnrc.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ npmAuthToken: "${NPM_TOKEN-''}"
44

55
plugins:
66
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
7-
spec: "@yarnpkg/plugin-interactive-tools"
7+
spec: '@yarnpkg/plugin-interactive-tools'
88
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
9-
spec: "@yarnpkg/plugin-workspace-tools"
9+
spec: '@yarnpkg/plugin-workspace-tools'
1010

1111
yarnPath: .yarn/releases/yarn-2.3.3.cjs

README.md

-1
This file was deleted.

README.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# react-responsive-modal
2+
3+
[![npm version](https://img.shields.io/npm/v/react-responsive-modal.svg)](https://www.npmjs.com/package/react-responsive-modal)
4+
[![npm downloads per month](https://img.shields.io/npm/dm/react-responsive-modal.svg)](https://www.npmjs.com/package/react-responsive-modal)
5+
[![codecov](https://img.shields.io/codecov/c/github/pradel/react-responsive-modal/master.svg)](https://codecov.io/gh/pradel/react-responsive-modal)
6+
7+
A simple responsive and accessible react modal.
8+
9+
- Focus trap inside the modal.
10+
- Centered modals.
11+
- Scrolling modals.
12+
- Multiple modals.
13+
- Accessible modals.
14+
- Easily customizable via props.
15+
16+
## Documentation
17+
18+
- [Getting started](https://react-responsive-modal.leopradel.com/)
19+
- [Installation](https://react-responsive-modal.leopradel.com/#installation)
20+
- [Usage](https://react-responsive-modal.leopradel.com/#usage)
21+
- [Props](https://react-responsive-modal.leopradel.com/#props)
22+
- [Licence](https://react-responsive-modal.leopradel.com/#license)
23+
- [Examples](https://react-responsive-modal.leopradel.com/examples)
24+
- [Centered modal](https://react-responsive-modal.leopradel.com/examples#centered-modal)
25+
- [Multiple modal](https://react-responsive-modal.leopradel.com/examples#multiple-modal)
26+
- [Custom styling](https://react-responsive-modal.leopradel.com/examples#custom-styling)
27+
- [Custom animation](https://react-responsive-modal.leopradel.com/examples#custom-animation)
28+
- [Custom container](https://react-responsive-modal.leopradel.com/examples#custom-container)
29+
30+
## Installation
31+
32+
With npm: `npm install react-responsive-modal --save`
33+
34+
Or with yarn: `yarn add react-responsive-modal`
35+
36+
## Usage
37+
38+
[![Edit react-responsive-modal](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/9jxp669j2o)
39+
40+
```javascript
41+
import React, { useState } from 'react';
42+
import ReactDOM from 'react-dom';
43+
import 'react-responsive-modal/styles.css';
44+
import { Modal } from 'react-responsive-modal';
45+
46+
const App = () => {
47+
const [open, setOpen] = useState(false);
48+
49+
const onOpenModal = () => setOpen(true);
50+
const onCloseModal = () => setOpen(false);
51+
52+
return (
53+
<div>
54+
<button onClick={onOpenModal}>Open modal</button>
55+
<Modal open={open} onClose={onCloseModal} center>
56+
<h2>Simple centered modal</h2>
57+
</Modal>
58+
</div>
59+
);
60+
};
61+
62+
ReactDOM.render(<App />, document.getElementById('app'));
63+
```
64+
65+
## Props
66+
67+
Check the documentation: https://react-responsive-modal.leopradel.com/#props.
68+
69+
## License
70+
71+
MIT © [Léo Pradel](https://www.leopradel.com/)

netlify.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
[build]
3-
publish = "react-responsive-modal/.docz/dist"
4-
command = "yarn workspace react-responsive-modal docz:build"
3+
publish = "website/out"
4+
command = "yarn workspace react-responsive-modal build && yarn workspace website build && yarn workspace website export"
55

66
[build.environment]
77
NODE_VERSION = "12"

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"private": true,
33
"scripts": {
4-
"prettier": "prettier --write \"**/*.{js,ts,tsx,css,scss,json,md,mdx}\""
4+
"prettier": "prettier --write \"**/*.{js,ts,tsx,css,scss,json,md,mdx,yml}\""
55
},
66
"workspaces": [
7-
"react-responsive-modal"
7+
"react-responsive-modal",
8+
"website"
89
],
910
"prettier": {
1011
"singleQuote": true
@@ -15,7 +16,7 @@
1516
}
1617
},
1718
"lint-staged": {
18-
"*.{js,ts,tsx,css,scss,json,md,mdx}": "prettier --write"
19+
"*.{js,ts,tsx,css,scss,json,md,mdx,yml}": "prettier --write"
1920
},
2021
"devDependencies": {
2122
"husky": "4.3.0",

react-responsive-modal/cypress/integration/modal.spec.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,37 @@
22

33
describe('simple modal', () => {
44
beforeEach(() => {
5-
cy.visit('http://localhost:3000/examples');
5+
cy.visit('http://localhost:3000');
66
// Page is heavy to load so we wait for it to be loaded
77
cy.wait(500);
88
});
99

1010
it('should open modal when clicking open button', () => {
11-
cy.get('button').eq(2).click();
11+
cy.get('button').eq(0).click();
1212
cy.get('[data-testid=modal]').should('exist');
1313
});
1414

1515
// TODO overlay not working, see how to fix
1616
// it('should close modal when clicking overlay', () => {
17-
// cy.get('button').eq(2).click();
17+
// cy.get('button').eq(0).click();
1818
// cy.get('[data-testid=overlay]').click();
1919
// cy.get('[data-testid=modal]').should('not.exist');
2020
// });
2121

2222
it('should close modal when clicking the close icon', () => {
23-
cy.get('button').eq(2).click();
23+
cy.get('button').eq(0).click();
2424
cy.get('[data-testid=close-button]').click();
2525
cy.get('[data-testid=modal]').should('not.exist');
2626
});
2727

2828
it('should close modal when pressing esc key', () => {
29-
cy.get('button').eq(2).click();
29+
cy.get('button').eq(0).click();
3030
cy.get('body').type('{esc}');
3131
cy.get('[data-testid=modal]').should('not.exist');
3232
});
3333

3434
it('should close only last modal when pressing esc key when multiple modals are opened', () => {
35-
cy.get('button').eq(8).click();
35+
cy.get('button').eq(1).click();
3636
cy.get('[data-testid=modal] button').eq(0).click();
3737
cy.get('[data-testid=modal]').should('have.length', 2);
3838
cy.get('body').type('{esc}');
@@ -42,19 +42,19 @@ describe('simple modal', () => {
4242
});
4343

4444
it('should block the scroll when modal is opened', () => {
45-
cy.get('button').eq(2).click();
45+
cy.get('button').eq(0).click();
4646
cy.get('html').should('have.css', 'position', 'fixed');
4747
});
4848

4949
it('should unblock the scroll when modal is closed', () => {
50-
cy.get('button').eq(2).click();
50+
cy.get('button').eq(0).click();
5151
cy.get('html').should('have.css', 'position', 'fixed');
5252
cy.get('body').type('{esc}');
5353
cy.get('html').should('not.have.css', 'position', 'fixed');
5454
});
5555

5656
it('should unblock scroll only after last modal is closed when multiple modals are opened', () => {
57-
cy.get('button').eq(8).click();
57+
cy.get('button').eq(1).click();
5858
cy.get('[data-testid=modal] button').eq(0).click();
5959
cy.get('[data-testid=modal]').should('have.length', 2);
6060
cy.get('html').should('have.css', 'position', 'fixed');

react-responsive-modal/docs/docs.css

-13
This file was deleted.

0 commit comments

Comments
 (0)