Skip to content

Commit bfd2707

Browse files
authored
Codebase migrations (danilowoz#126)
* test(Refactor): (danilowoz#117) * test(Refactor): * Holder / SVG tests * Svg tests * Removed old tests * Coverage * Migrate to travis * Update travis * Update travis * ci(Release): * test(package): * ci(Travis): * chore(devDependencies): Package to generate the changelog * feat(Codebase): Format * feat(Types): Export types * ci(Build step): * feat(RTL): Flip the content BREAKING CHANGE: Flip all content instead of only flip the animation direction Closes danilowoz#122 * Migrate codebase to Typescript (danilowoz#120) * Ignore rpt2_cache * Add typescript pkg; Add tsc runner script * Replace babel with ts compiler * Typescript configs * Update lockfile * Convert Holder to tsx * Convert svg to tsx * Convert index.js to ts * Convert uid to ts * Convert BulletListStyle to tsx * Convert CodeStyle to tsx * Convert FacebookStyle to tsx * Convert InstagramStyle to tsx * Convert ListStyle to tsx * Remove flow preset * Add ts-node for ts execustion env for nodejs * Remove flow preset & rollup-babel plugin; Add ts-node for ts env in nodejs * Update lockfile * Update watch script for tsc * Rename IProps to IContentLoaderProps; Use FC for validation * Remove unwanted ISvgProps; import IContentLoaderProps for type validations * import and re-export IContentLoaderProps for better types * Import and use types from IContentLoaderProps * Remove eslint; replaced by tslint and tslint-prettier * Add tslint-config-prettier * Implement stricter type checking * Remove comments as it is handled by tslint-config-prettier now * Replace lint by tsc * remove eslint and flow configs * Add style default props * Add jest options to include ts test files * Add options to load json file * Migrate tests from JS to TS for better interoperability * Updated snapshots * Remove ts-node * Break line after react import * Remove export from bottom of file and move to component definition BREAKING CHANGE: Migrate codebase to typescript Closes danilowoz#120
1 parent fb0e65b commit bfd2707

Some content is hidden

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

52 files changed

+19376
-3445
lines changed

.babelrc.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ const loose = true
55
module.exports = {
66
presets: [
77
[
8-
'@babel/preset-env', {
8+
'@babel/preset-env',
9+
{
910
modules,
1011
loose
1112
}
1213
],
13-
'@babel/preset-react',
14-
'@babel/preset-flow'
15-
],
14+
'@babel/preset-react'
15+
]
1616
}

.circleci/config.yml

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

.eslintrc

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

.flowconfig

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

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ coverage
1111
.docz/
1212
.rpt2_cache
1313
settings.json
14-
*.code-workspace
14+
*.code-workspace

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "es5"
5+
}

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: node_js
2+
sudo: false
3+
node_js:
4+
- 9
5+
cache:
6+
directories:
7+
- node_modules
8+
install:
9+
- npm install
10+
- npm install -g codecov
11+
script:
12+
- npm run test
13+
- npm run build
14+
after_success:
15+
- npm run coverage
16+
- npm run release

docs/intro.mdx

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ route: /
44
---
55

66
# Introduction
7+
78
<p align="center">
89
<img width="350" alt="react-content-loader" src="https://user-images.githubusercontent.com/4838076/34419335-5669c3f8-ebea-11e7-9668-c47b7846970b.png" />
910
</p>
@@ -15,13 +16,14 @@ React component that uses SVG to create a collection of loaders which simulates
1516
the structure of the content that will be loaded, similar to Facebook cards loaders.
1617

1718
## Features
18-
* :gear: **Completely customizable:** you can change the colors, speed, sizes and even with RTL content support;
19-
* :pencil2: **Create your own loading:** use the
19+
20+
- :gear: **Completely customizable:** you can change the colors, speed, sizes and even with RTL content support;
21+
- :pencil2: **Create your own loading:** use the
2022
[create-content-loader](https://danilowoz.github.io/create-content-loader/) to create
2123
your own custom loadings easily;
22-
* :ok_hand: **You can use right now:** there are a lot of presets to use it, see the
24+
- :ok_hand: **You can use right now:** there are a lot of presets to use it, see the
2325
[examples](usage#different-type-of-loaders);
24-
* :rocket: **Performance:** written using only the SVG API.
26+
- :rocket: **Performance:** written using only the SVG API.
2527

2628
## Installation
2729

@@ -44,22 +46,21 @@ const MyFacebookLoader = () => <Facebook />
4446
**Or in custom mode, using the
4547
[online tool](https://danilowoz.github.io/create-react-content-loader/)**
4648

47-
4849
## Options
4950

50-
| <p align="left">Name</p>|<p align="left">Type</p>|<p align="left">Default</p>| <p align="left">Description</p> |
51-
| ----------------------- | ----------- | ---------------------- | ------------------------------------------------------------------------- |
52-
| **animate** | `Boolean` | `true` | `false` to render with no animation |
53-
| **ariaLabel** | `String | Boolean` | `Loading interface...` | Describe what element it is |
54-
| **speed** | `Number` | `2` | Animation speed in seconds |
55-
| **className** | `String` | ` ` | Classname in the `<svg/>` |
56-
| **width** | `Number` | `400` | viewBox width of `<svg/>` |
57-
| **height** | `Number` | `130` | viewBox height of `<svg/>` |
58-
| **rtl** | `Boolean` | `false` | Right-to-left animation |
59-
| **preserveAspectRatio** | `String` | `xMidYMid meet` | Aspect ratio option of `<svg/>` |
60-
| **primaryColor** | `String` | `#f3f3f3` | Background |
61-
| **secondaryColor** | `String` | `#ecebeb` | Animation color |
62-
| **primaryOpacity** | `Number` | `1` | Background opacity (0 = transparent, 1 = opaque) |
63-
| **secondaryOpacity** | `Number` | `1` | Animation opacity (0 = transparent, 1 = opaque) |
64-
| **style** | `Object` | `null` | Ex: `{ width: '100%', height: '70px' }` |
65-
| **uniquekey** | `String` | random unique id | Use the same value of prop key, that will solve inconsistency on the SSR. |
51+
| Name | Type | Default | Description |
52+
| ----------------------- | ------------------ | ---------------------- | ------------------------------------------------------------------------- |
53+
| **animate** | `Boolean` | `true` | `false` to render with no animation |
54+
| **ariaLabel** | `String | Boolean` | `Loading interface...` | Describe what element it is |
55+
| **speed** | `Number` | `2` | Animation speed in seconds |
56+
| **className** | `String` | `` | Classname in the `<svg/>` |
57+
| **width** | `Number` | `400` | viewBox width of `<svg/>` |
58+
| **height** | `Number` | `130` | viewBox height of `<svg/>` |
59+
| **rtl** | `Boolean` | `false` | Right-to-left animation |
60+
| **preserveAspectRatio** | `String` | `xMidYMid meet` | Aspect ratio option of `<svg/>` |
61+
| **primaryColor** | `String` | `#f3f3f3` | Background |
62+
| **secondaryColor** | `String` | `#ecebeb` | Animation color |
63+
| **primaryOpacity** | `Number` | `1` | Background opacity (0 = transparent, 1 = opaque) |
64+
| **secondaryOpacity** | `Number` | `1` | Animation opacity (0 = transparent, 1 = opaque) |
65+
| **style** | `Object` | `null` | Ex: `{ width: '100%', height: '70px' }` |
66+
| **uniquekey** | `String` | random unique id | Use the same value of prop key, that will solve inconsistency on the SSR. |

docs/usage.mdx

Lines changed: 53 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,107 +2,125 @@
22
name: Usage
33
route: /usage
44
---
5+
56
import { Playground, PropsTable } from 'docz'
7+
68
import ContentLoader, {
79
Facebook,
810
Instagram,
911
Code,
1012
List,
11-
BulletList
12-
} from "../src/index"
13-
import FacebookStyle from "../src/stylized/FacebookStyle"
14-
13+
BulletList,
14+
} from '../src'
15+
import FacebookStyle from '../src/stylized/FacebookStyle'
1516

1617
# React Content Loader
18+
1719
<PropsTable of={FacebookStyle} />
1820

1921
## Different Type of Loaders
2022

2123
### Facebook Style Loader
24+
2225
<Playground>
23-
<Facebook/>
26+
<Facebook />
2427
</Playground>
2528

2629
### Instagram Style Loader
30+
2731
<Playground>
28-
<Instagram/>
32+
<Instagram />
2933
</Playground>
3034

3135
### Code Style Loader
36+
3237
<Playground>
33-
<Code/>
38+
<Code />
3439
</Playground>
3540

3641
### List Style Loader
42+
3743
<Playground>
38-
<List/>
44+
<List />
3945
</Playground>
4046

4147
### BulletList Style Loader
48+
4249
<Playground>
43-
<BulletList/>
50+
<BulletList />
4451
</Playground>
4552

4653
### Custom Loader
54+
4755
<Playground>
48-
<ContentLoader
49-
height={140}
50-
speed={1}
51-
primaryColor={"#333"}
52-
secondaryColor={"#999"}
53-
>
54-
<rect x="80" y="17" rx="4" ry="4" width="300" height="13" />
55-
<rect x="82" y="44" rx="3" ry="3" width="250" height="10" />
56-
<circle cx="35" cy="35" r="35" />
57-
</ContentLoader>
56+
<ContentLoader
57+
height={140}
58+
speed={1}
59+
primaryColor={'#333'}
60+
secondaryColor={'#999'}
61+
>
62+
<rect x="80" y="17" rx="4" ry="4" width="300" height="13" />
63+
<rect x="82" y="44" rx="3" ry="3" width="250" height="10" />
64+
<circle cx="35" cy="35" r="35" />
65+
</ContentLoader>
5866
</Playground>
5967

6068
## Unique key
69+
6170
<Playground>
62-
<Facebook uniquekey="unique-key" />
71+
<Facebook uniquekey="unique-key" />
6372
</Playground>
6473

6574
## No Animation
75+
6676
Set animate props to false to stop Animation
6777

6878
<Playground>
69-
<Facebook animate={false} />
79+
<Facebook animate={false} />
7080
</Playground>
7181

72-
## Right To Left Animation
82+
## RTL: Right To Left Animation
83+
7384
Set rtl props to animate from right to left
85+
7486
<Playground>
75-
<Instagram rtl />
87+
<Instagram rtl />
7688
</Playground>
7789

7890
## Use ViewBox
91+
7992
Use viewbox props to set viewbox value.
8093
Additionally, pass viewBox props as empty string to remove viewBox.
94+
8195
<Playground>
82-
<ContentLoader viewBox="" />
96+
<ContentLoader viewBox="" />
8397
</Playground>
8498

8599
## Custom aria label
100+
86101
<Playground>
87-
<ContentLoader ariaLabel="My custom loader" />
102+
<ContentLoader ariaLabel="My custom loader" />
88103
</Playground>
89104

90105
### Remove aria label
106+
91107
<Playground>
92-
<ContentLoader ariaLabel={false} />
108+
<ContentLoader ariaLabel={false} />
93109
</Playground>
94110

95111
## BugFix in Safari
96-
When using `rgba` as a `primaryColor` or `secondaryColor` value,
112+
113+
When using `rgba` as a `primaryColor` or `secondaryColor` value,
97114
[Safari does not respect the alpha channel](https://github.com/w3c/svgwg/issues/180),
98-
meaning that the color will be opaque. To prevent this, instead of using an
115+
meaning that the color will be opaque. To prevent this, instead of using an
99116
`rgba` value for `primaryColor`/`secondaryColor`, use the `rgb` equivalent and
100117
move the alpha channel value to the `primaryOpacity`/`secondaryOpacity` props.
118+
101119
<Playground>
102-
<ContentLoader
103-
primaryColor="rgb(0,0,0)"
104-
secondaryColor="rgb(0,0,0)"
105-
primaryOpacity={0.06}
106-
secondaryOpacity={0.12}
107-
/>
108-
</Playground>
120+
<ContentLoader
121+
primaryColor="rgb(0,0,0)"
122+
secondaryColor="rgb(0,0,0)"
123+
primaryOpacity={0.06}
124+
secondaryOpacity={0.12}
125+
/>
126+
</Playground>

doczrc.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import emoji from "remark-emoji"
2+
23
export default {
34
title: "React Content Loader",
5+
typescript: true,
46
mdPlugins: [emoji],
57
codeSandbox: false,
68
htmlContext: {

0 commit comments

Comments
 (0)