Skip to content

Commit b90c723

Browse files
authored
Merge pull request #165 from alperari/fix-readme-grammar
docs: 📝 correct README grammar & typos
2 parents 26f72a1 + 16339c7 commit b90c723

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

README.md

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ NiceModal.show('my-modal', { someProp: 'hello' }).then(() => {
4343

4444
```
4545

46-
**NOTE**: `@ebay/nice-modal-react` is not a React modal component but should be used with other modal/dialog implementions by UI libraries like [Material UI](https://material-ui.com/), [Ant.Design](https://ant.design), [Bootstrap React](https://react-bootstrap.github.io/), etc.
46+
**NOTE**: `@ebay/nice-modal-react` is not a React modal component but should be used with other modal/dialog implementations by UI libraries like [Material UI](https://material-ui.com/), [Ant.Design](https://ant.design), [Bootstrap React](https://react-bootstrap.github.io/), etc.
4747

4848
# Examples
4949
You can see a list of examples at: https://ebay.github.io/nice-modal-react
@@ -58,13 +58,13 @@ You can see a list of examples at: https://ebay.github.io/nice-modal-react
5858
* Easy to integrate with any UI library.
5959

6060
# Motivation
61-
Using modals in React is a bit frustrating. Think of that if you need to implement below UI:
61+
Using modals in React is a bit frustrating. Think of that if you need to implement the below UI:
6262

6363
<img src="images/modal-example.jpg" width="700px"/>
6464

65-
The dialog is used to create a JIRA ticket. It could be shown from many places, from the header, to the context menu, to the list page. Traditionally, we had declared modal components with a JSX tag. But then the question became, “Where should we declare the tag?”
65+
The dialog is used to create a JIRA ticket. It could be shown from many places, from the header to the context menu, to the list page. Traditionally, we had declared modal components with a JSX tag. But then the question became, “Where should we declare the tag?”
6666

67-
The most common option was to declare it wherever it was being used. But using modals in a declarative way is not only about a JSX tag, but also about maintaining the modal’s state like visibility, parameters in the container component. Declaring it everywehre means managing state everywhere. It's frustrating.
67+
The most common option was to declare it wherever it was being used. But using modals in a declarative way is not only about a JSX tag but also about maintaining the modal’s state like visibility, and parameters in the container component. Declaring it everywhere means managing the state everywhere. It's frustrating.
6868

6969
The other option put it in the Root component, for example:
7070

@@ -88,20 +88,18 @@ However, when you declare the modal in the root component, there are some issues
8888

8989
Unfortunately, most examples of using modals just follow this practice, it causes such confusions when managing modals in React.
9090

91-
I believe you must once encountered with the scenario that originally you only needed to show a modal when click a button, then when requirements changed, you need to open the same modal from a different place. Then you have to refactor your code to re-consider where to declare the modal. The root cause of such annoying things is just because we have not understood the essential of a modal.
91+
I believe you must once encountered with the scenario that originally you only needed to show a modal when you click a button, then when requirements changed, you need to open the same modal from a different place. Then you have to refactor your code to re-consider where to declare the modal. The root cause of such annoying things is just because we have not understood the essentials of a modal.
9292

9393
# Rethink the Modal Usage Pattern in React
94-
According to the [wikipedia](https://en.wikipedia.org/wiki/Modal_window), a modal can be described as:
94+
According to the [Wikipedia](https://en.wikipedia.org/wiki/Modal_window), a modal can be described as:
9595

9696
> A window that prevents the user from interacting with your application until he closes the window.
9797
98-
From the definition we can get a conclusion: a modal is a global view that's not necessarily related with a specific context.
98+
From the definition, we can get a conclusion: a modal is a global view that's not necessarily related with a specific context.
9999

100-
This is very similar with the page concept in a single page UI application. The visibility/ state of modals should be managed globally because, from the UI perspective, a modal could be showed above any page/component. The only difference between modal and page is: a modal allows you to not leave the current page to do some separate tasks.
100+
This is very similar with the page concept in a single page UI application. The visibility/ state of modals should be managed globally because, from the UI perspective, a modal could be shown above any page/component. The only difference between a modal and a page is: a modal allows you to not leave the current page to do some separate tasks.
101101

102-
For pages management, we already have router framework like React Router, it helps to navigate to a page by URL. Actually, you can think URL a global id for a page. So, similarly, what if you assign a uniq id to a modal then show/hide it by the id? This is just how we designed NiceModal.
103-
104-
However, besides using id, NiceModal allows to use the modal component directly to manage it.
102+
For pages management, we already have router framework like React Router, it helps to navigate to a page by URL. Actually, you can think of a URL as a global id for a page. So, similarly, what if you assign a unique id to a modal and then show/hide it by the id? This is just how we designed NiceModal.
105103

106104
# Usage
107105
## Installation
@@ -115,7 +113,7 @@ npm install @ebay/nice-modal-react
115113
```
116114

117115
## Create Your Modal Component
118-
With NiceModal you can create a separate modal component easily. It's just the same as you create a normal component but wrap it with high order compponent by `NiceModal.create`. For example, below code shows how to create a dialog with [Ant.Design](https://ant.design):
116+
With NiceModal you can create a separate modal component easily. It's just the same as creating a normal component but wrapping it with high order component by `NiceModal.create`. For example, the below code shows how to create a dialog with [Ant.Design](https://ant.design):
119117

120118
```jsx
121119
import { Modal } from 'antd';
@@ -139,7 +137,7 @@ export default NiceModal.create(({ name }: { name: string }) => {
139137
```
140138

141139
From the code, we can see:
142-
* The modal is uncontrolled. You can hide your modal inside the component regardless where it is showed.
140+
* The modal is uncontrolled. You can hide your modal inside the component regardless of where it is shown.
143141
* The high order component created by `NiceModal.create` ensures your component is not executed before it becomes visible.
144142
* You can call `modal.remove` to remove your modal component from the React component tree to reserve transitions.
145143

@@ -149,7 +147,7 @@ Next, let's see how to use the modal.
149147
There are very flexible APIs for you to manage modals. See below for the introduction.
150148

151149
### Embed your application with `NiceModal.Provider`:
152-
Since we will manage status of modals globally, the first thing is embedding your app with NiceModal provider, for example:
150+
Since we will manage the status of modals globally, the first thing is embedding your app with NiceModal provider, for example:
153151

154152
```js
155153
import NiceModal from '@ebay/nice-modal-react';
@@ -193,7 +191,7 @@ You can also control a nice modal by id:
193191
import NiceModal from '@ebay/nice-modal-react';
194192
import MyAntdModal from './my-antd-modal'; // created by above code
195193

196-
// If use by id, need to register the modal component.
194+
// If you use by id, you need to register the modal component.
197195
// Normally you create a modals.js file in your project
198196
// and register all modals there.
199197
NiceModal.register('my-antd-modal', MyAntdModal);
@@ -224,7 +222,7 @@ import MyAntdModal from './my-antd-modal'; // created by above code
224222

225223
NiceModal.register('my-antd-modal', MyAntdModal);
226224
//...
227-
// if use with id, need to register it first
225+
// if you use with id, you need to register it first
228226
const modal = useModal('my-antd-modal');
229227
// or if with component, no need to register
230228
const modal = useModal(MyAntdModal);
@@ -259,14 +257,15 @@ function App() {
259257
}
260258
```
261259

262-
With this approach, you can get the benifits:
260+
With this approach, you can get the benefits:
263261
* Inherit React context in the modal component under some component node.
264262
* Pass arguments to the modal component via props.
265263

266-
> NOTE: if you show the component by id but the modal is not declared or registered. Nothing will happen but only a warning message in the dev console.
264+
> NOTE: If you attempt to show the component by ID but the modal is not declared or registered, nothing will happen except for a warning message in the dev console.
267265
268266
### Using promise API
269-
Besides using props to interact with the modal from the parent component, you can do it easier by promise. For example, we have a user list page with a add user button to show a dialog to add user. After user is added the list should refresh itself to reflect the change, then we can use below code:
267+
268+
Besides using props to interact with the modal from the parent component, you can do more easily by promise. For example, we have a user list page with an add user button to show a dialog to add user. After user is added the list should refresh itself to reflect the change, then we can use below code:
270269

271270
```jsx
272271
NiceModal.show(AddUserModal)
@@ -284,7 +283,7 @@ NiceModal.show(AddUserModal)
284283
You can see the live example on codesandbox.
285284

286285
### Integrating with Redux
287-
Though not necessary, you can integrate Redux to manage state of nice modals. Then you can use Redux dev tools to track/debug state change of modals. Here is how to do it:
286+
Though not necessary, you can integrate Redux to manage the state of nice modals. Then you can use Redux dev tools to track/debug state change of modals. Here is how to do it:
288287

289288
```jsx
290289
// First combine the reducer
@@ -327,12 +326,12 @@ export default function ReduxProvider({ children }) {
327326
```
328327

329328
### Using with any UI library
330-
NiceModal provides lifecyle methods to manage the state of modals. You can use modal handler returned by `useModal` hook to bind any modal like component to the state. Below are typical state and methods you will use:
329+
NiceModal provides lifecycle methods to manage the state of modals. You can use modal handler returned by `useModal` hook to bind any modal-like component to the state. Below are typical states and methods you will use:
331330

332-
* **modal.visible**: the visibility of a modal.
333-
* **modal.hide**: will hide the modal, that is, change `modal.visible` to false.
334-
* **modal.remove**: remove the modal component from the tree so that you modal's code is not executed when it's invisible. Usually you call this method after the modal's transition.
335-
* **modal.keepMounted** if you don't want to remove the modal from the tree for some instances, you can decide if call `modal.remove` based on value of `keepMounted`.
331+
* ***modal.visible**: the visibility of a modal.
332+
* ***modal.hide**: will hide the modal, that is, change `modal.visible` to false.
333+
* ***modal.remove**: remove the modal component from the tree so that your modal's code is not executed when it's invisible. Usually, you call this method after the modal's transition.
334+
* ***modal.keepMounted** if you don't want to remove the modal from the tree for some instances, you can decide if call `modal.remove` based on the value of `keepMounted`.
336335

337336
Based on these properties/methods, you can easily use NiceModal with any modal-like component provided by any UI libraries.
338337

@@ -356,9 +355,9 @@ return (
356355
//...
357356
```
358357

359-
It binds `visible` property to the `modal` handler, and use `modal.hide` to hide the modal when close button is clicked. And after the close transition it calls `modal.remove` to remove the modal from dom node.
358+
It binds `visible` property to the `modal` handler, and uses `modal.hide` to hide the modal when close button is clicked. And after the close transition it calls `modal.remove` to remove the modal from the dom node.
360359

361-
For every modal implementation we always need to these binding manually. So, to make it easier to use we provides helper methods for 3 popular UI libraries Material UI, Ant.Design and Bootstrap React.
360+
For every modal implementation, we always need to do these bindings manually. So, to make it easier to use we provided helper methods for 3 popular UI libraries Material UI, Ant.Design and Bootstrap React.
362361

363362

364363
```jsx
@@ -397,7 +396,7 @@ const modal = useModal();
397396

398397
```
399398

400-
These helpers will bind modal's common actions to correct properties of the component. However you can always override the property after the helpers property. For example:
399+
These helpers will bind modal's common actions to correct properties of the component. However, you can always override the property after the helper's property. For example:
401400

402401
```jsx
403402
const handleSubmit = () => {

0 commit comments

Comments
 (0)