Skip to content
This repository was archived by the owner on Jun 2, 2024. It is now read-only.

Commit 5fd040a

Browse files
authored
Rename Resolve component to ShowAsync (#30)
* feat: rename Resolve component to ShowAsync * docs: improve wording in readme * docs: improve wording in definition files * perf: reduce bundle size
1 parent 88e229e commit 5fd040a

27 files changed

+795
-342
lines changed

README.md

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<h1>react-semantic-render</h1>
66

7-
<h4>Blazing fast semantic helper components for rendering content with <a href="https://reactjs.org/" target="_blank">React</a>.</h4>
7+
<h4>Semantic helper components for rendering content with <a href="https://reactjs.org/" target="_blank">React</a>.</h4>
88

99
<p>
1010
<a href="https://www.npmjs.com/package/react-semantic-render">
@@ -40,12 +40,10 @@
4040
## Key features
4141

4242
* __Growing list of semantic helper components__
43-
* __[List](https://csvenke.github.io/react-semantic-render/#/List)__ - Render content from an array of data.
44-
* __[Resolve](https://csvenke.github.io/react-semantic-render/#/Resolve)__ - Render content asynchronously.
45-
* __[Show](https://csvenke.github.io/react-semantic-render/#/Show)__ - Render content when a condition is true.
46-
* __[Switch](https://csvenke.github.io/react-semantic-render/#/Switch)__ - Render content from case that matches specified expression.
47-
* __[Switch.Case](https://csvenke.github.io/react-semantic-render/#/SwitchCase)__
48-
* __[Switch.Default](https://csvenke.github.io/react-semantic-render/#/SwitchDefault)__
43+
* __[List](https://csvenke.github.io/react-semantic-render/#/List)__: Renders content from an array of data.
44+
* __[Show](https://csvenke.github.io/react-semantic-render/#/Show)__: Renders content when specified condition is true.
45+
* __[ShowAsync](https://csvenke.github.io/react-semantic-render/#/ShowAsync)__: Renders content when specified promise is pending, resolved and rejected.
46+
* __[Switch](https://csvenke.github.io/react-semantic-render/#/Switch)__: Renders content from first __[Switch.Case](https://csvenke.github.io/react-semantic-render/#/SwitchCase)__ that matches, else __[Switch.Default](https://csvenke.github.io/react-semantic-render/#/SwitchDefault)__ if it exists.
4947
* __Small bundle size__
5048
* __Blazing fast__
5149
* __TypeScript type definitions__
@@ -69,52 +67,35 @@ $ yarn add react-semantic-render
6967

7068
```jsx
7169
import { Show, List } from 'react-semantic-render';
70+
```
7271

73-
const Menu = ({ showMenuItems }) => (
74-
<nav>
75-
<a href="/">Home</a>
76-
<Show when={showMenuItems}>
77-
<ul>
78-
<List
79-
items={['prices', 'contact', 'about']}
80-
render={m => (
81-
<li key={m}>
82-
<a href={`/${m}`}>{m}</a>
83-
</li>
84-
)}
85-
/>
86-
</ul>
87-
</Show>
88-
</nav>
89-
);
72+
```jsx
73+
<div>
74+
<Show when={true}>
75+
<List
76+
items={[1, 2, 3, 4, 5]}
77+
render={data => <div>{data}</div>}
78+
/>
79+
</Show>
80+
</div>
9081
```
9182

9283
## Why
9384

9485
In the example above you see two very common use cases where you have to render something when a condition is true and render content from an array of data.
9586
This is usually solved with inline arrow functions that are hard to read and easily becomes unmanageable in more complex components.
9687

97-
Below you can see how it would look like with inline arrow functions.
88+
Below you can see how it would look with inline arrow functions.
9889

9990
```jsx
100-
const Menu = ({ showMenuItems }) => (
101-
<nav>
102-
<a href="/">Home</a>
103-
{showMenuItems ? (
104-
<ul>
105-
{['prices', 'contact', 'about'].map(m => (
106-
<li key={m}>
107-
<a href={`/${m}`}>{m}</a>
108-
</li>
109-
))}
110-
</ul>
111-
) : null}
112-
</nav>
113-
)
91+
<div>
92+
{true ? (
93+
{[1, 2, 3, 4, 5].map(data => <div>{data}</div>)}
94+
) : null}
95+
</div>
11496
```
11597

116-
117-
The purpose of this library is to develop and maintain semantic helper components that removes the need for inline arrow functions in react components.
98+
The purpose of this library is to provide helpful semantic render components that makes the `React.Component` render method easier to read and follow.
11899

119100
Do you have an idea about a component you think belong here? [Tell us here!](https://github.com/csvenke/react-semantic-render/issues/new)
120101

@@ -124,17 +105,31 @@ For full list of components and how they are used, go to our [documentation](htt
124105

125106
## Development
126107

127-
```bash
128-
# Install dependencies
108+
##### Install dependencies
109+
```
129110
$ npm install
111+
```
130112

131-
# Run linters
113+
##### Run linters
114+
```
132115
$ npm run lint
116+
$ npm run lint:fix
117+
```
133118

134-
# Run tests
119+
##### Run tests
120+
```
135121
$ npm run test
122+
$ npm run test:watch
123+
```
136124

137-
# Build project
125+
##### Build docs
126+
```
127+
$ npm run docs
128+
$ npm run docs:server
129+
```
130+
131+
##### Build project
132+
```
138133
$ npm run build
139134
```
140135

@@ -143,7 +138,7 @@ $ npm run build
143138
In lieu of a formal styleguide, take care to maintain the existing coding style.
144139

145140
* Add unit tests for any new or changed functionality.
146-
* All library component props must be documented with jsdoc `/** */`, so that typescript definition files can be generated.
141+
* All library components exposed to the user must be documented with jsdoc `/** */`.
147142
* All library components must have `prop-types` that matches the component props interface.
148143

149144
#### Commit style guide
@@ -161,4 +156,4 @@ Don't worry about making a mistake, `commitlint` will stop you if you do, and yo
161156

162157
## License
163158

164-
This project is licensed under the MIT License - see [LICENSE](https://github.com/csvenke/react-semantic-render/blob/master/LICENSE) file for details.
159+
[MIT](https://github.com/csvenke/react-semantic-render/blob/master/LICENSE)

docs/build/1.2b7afc21.js renamed to docs/build/1.78d04fad.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/build/bundle.18ec5f95.js

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

docs/build/bundle.4474faa6.js

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

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>react-semantic-render</title></head><body><div id="rsg-root"></div><script src="build/bundle.4474faa6.js"></script></body></html>
1+
<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>react-semantic-render</title></head><body><div id="rsg-root"></div><script src="build/bundle.18ec5f95.js"></script></body></html>

0 commit comments

Comments
 (0)