Skip to content

Commit f86365b

Browse files
committed
2 parents df7f426 + 089a3a0 commit f86365b

File tree

91 files changed

+18272
-7078
lines changed

Some content is hidden

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

91 files changed

+18272
-7078
lines changed

.babelrc

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

.babelrc.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module.exports = function(api) {
2+
const plugins = [
3+
'@babel/plugin-transform-flow-strip-types',
4+
'@babel/plugin-syntax-dynamic-import',
5+
'@babel/plugin-proposal-export-default-from',
6+
'@babel/plugin-proposal-export-namespace-from',
7+
'@babel/plugin-proposal-object-rest-spread',
8+
'babel-plugin-flow-react-proptypes',
9+
'@babel/plugin-proposal-class-properties',
10+
]
11+
const presets = [
12+
[
13+
'@babel/preset-env',
14+
api.env('es5')
15+
? { forceAllTransforms: true }
16+
: { targets: { node: 'current' } },
17+
],
18+
'@babel/preset-react',
19+
'@babel/preset-flow',
20+
]
21+
22+
if (api.env(['test', 'coverage', 'es5'])) {
23+
plugins.push('@babel/plugin-transform-runtime')
24+
}
25+
if (api.env('coverage')) {
26+
plugins.push('babel-plugin-istanbul')
27+
}
28+
29+
return { plugins, presets }
30+
}

.circleci/config.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
version: 2
2+
jobs:
3+
build:
4+
docker:
5+
- image: circleci/node:8
6+
7+
steps:
8+
- checkout
9+
- restore_cache:
10+
name: Restore Yarn Package Cache
11+
keys:
12+
- v1-yarn-packages-{{ checksum "yarn.lock" }}
13+
14+
- run:
15+
name: Setup NPM Token
16+
command: |
17+
yarn config set registry "https://registry.npmjs.org/"
18+
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc
19+
echo "registry=https://registry.npmjs.org/" >> .npmrc
20+
21+
- run:
22+
name: Install Dependencies
23+
command: yarn install --frozen-lockfile
24+
- save_cache:
25+
name: Save Yarn Package Cache
26+
key: v1-yarn-packages-{{ checksum "yarn.lock" }}
27+
paths:
28+
- ~/.cache/yarn
29+
30+
- run:
31+
name: build
32+
command: yarn run prepublishOnly
33+
- run:
34+
name: upload test coverage
35+
command: yarn codecov || true
36+
- run:
37+
name: release
38+
command: yarn run semantic-release || true

.eslintrc

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
{
22
"extends": [
3-
"@jedwards1211/eslint-config-react", "@jedwards1211/eslint-config-flow"
3+
"@jedwards1211/eslint-config-react",
4+
"@jedwards1211/eslint-config-flow",
5+
"eslint-config-prettier"
46
],
5-
"parser": "babel-eslint"
7+
"parser": "babel-eslint",
8+
"parserOptions": {
9+
"ecmaVersion": 6,
10+
"sourceType": "module"
11+
},
12+
"env": {
13+
"es6": true
14+
},
15+
"settings": {
16+
"react": {
17+
"pragma": "React",
18+
"version": "detect",
19+
"flowVersion": "0.92.0"
20+
}
21+
}
622
}

.flowconfig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
[ignore]
2+
<PROJECT_ROOT>/[^/\\]+\.js$
3+
<PROJECT_ROOT>/[^/\\]+\.js\.flow$
4+
<PROJECT_ROOT>/es/.*
25
<PROJECT_ROOT>/lib/.*
36
<PROJECT_ROOT>/node_modules/immutable/.*
47
<PROJECT_ROOT>/node_modules/jss/.*
8+
<PROJECT_ROOT>/node_modules/.*/fbjs/.*
59
<PROJECT_ROOT>/node_modules/fbjs/.*
6-
<PROJECT_ROOT>/node_modules/.*/tests?/.*\.json
10+
<PROJECT_ROOT>/node_modules/.*/config-chain/.*
711

812
[include]
913
./src
@@ -15,4 +19,3 @@
1519
module.system=node
1620
esproposal.class_static_fields=enable
1721
esproposal.class_instance_fields=enable
18-

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
.eslintcache
12
.nyc_output
23
coverage
4+
es
35
node_modules
4-
lib
5-
storybook-static
66
.eslintcache
7+
/*.js
8+
/*.js.flow
9+
!/.babelrc.js

.npmignore

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
.babelrc
2-
.eslintrc
3-
.nyc_output
4-
.storybook
5-
.travis.yml
6-
coverage
7-
node_modules
8-
test
9-
stories
10-
scripts
11-
storybook-static
12-
.eslintcache
13-
.idea
14-
solano.yml
15-
renovate.json
16-
commitlint.config.js
17-
flow-typed
18-
1+
**
2+
!**/*.js
3+
!**/*.js.flow
4+
!/*.md
5+
!yarn.lock
6+
/lib
7+
/src
8+
/stories
9+
/test
10+
/coverage
11+
/flow-typed
12+
__tests__
13+
/.*
14+
!/.flowconfig

.travis.yml

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

LICENSE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-

README.md

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# react-view-slider
22

3-
[![Build Status](https://travis-ci.org/jcoreio/react-view-slider.svg?branch=master)](https://travis-ci.org/jcoreio/react-view-slider)
4-
[![Coverage Status](https://codecov.io/gh/jcoreio/react-view-slider/branch/master/graph/badge.svg)](https://codecov.io/gh/jcoreio/react-view-slider)
3+
[![CircleCI](https://circleci.com/gh/jcoreio/react-view-slider.svg?style=svg)](https://circleci.com/gh/jcoreio/react-view-slider)
4+
[![Coverage Status](https://codecov.io/gh/jcoreio/react-view-slider)](https://codecov.io/gh/jcoreio/react-view-slider)
55
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
66
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
7+
[![npm version](https://badge.fury.io/js/react-view-slider.svg)](https://badge.fury.io/js/react-view-slider)
78

89
Not another carousel; a simpler component that animates horizontal slide transitions between steps of a wizard or levels
910
of a drilldown.
1011

11-
1212
# Table of Contents
1313

1414
- [Usage](#usage)
@@ -29,7 +29,15 @@ import ViewSlider from 'react-view-slider'
2929

3030
// This function renders the view at the given index.
3131
// At minimum you should pass the key, ref, style, and className props to the returned element.
32-
const renderView = ({index, key, ref, style, className, active, transitionState}) => (
32+
const renderView = ({
33+
index,
34+
key,
35+
ref,
36+
style,
37+
className,
38+
active,
39+
transitionState,
40+
}) => (
3341
<div key={key} ref={ref} style={style} className={className}>
3442
<h3>View {index}</h3>
3543
<p>I am {active ? 'active' : 'inactive'}</p>
@@ -42,10 +50,10 @@ const renderView = ({index, key, ref, style, className, active, transitionState}
4250

4351
ReactDOM.render(
4452
<ViewSlider
45-
renderView={renderView}
46-
numViews={3}
47-
activeView={0}
48-
animateHeight
53+
renderView={renderView}
54+
numViews={3}
55+
activeView={0}
56+
animateHeight
4957
/>,
5058
document.getElementById('root')
5159
)
@@ -55,24 +63,25 @@ ReactDOM.render(
5563

5664
##### `renderView: (props: ViewProps) => React.Element<any>` **(required)**
5765

58-
This function renders each view. `ViewSlider` will call it with the following `props`:
59-
* `index: number` - the index of the view (starting at 0)
60-
* `key: number` - the key you should pass to the returned element
61-
* `ref: (c: HTMLElement) => any` - the ref you should pass to the returned element
62-
* `style: Object` - the style you should pass to the returned element
63-
* `active: boolean` - whether the view should currently be showing
64-
* `transitionState: 'in' | 'out' | 'entering' | 'leaving'` - the view's transition state
66+
This function renders each view. `ViewSlider` will call it with the following `props`:
67+
68+
- `index: number` - the index of the view (starting at 0)
69+
- `key: number` - the key you should pass to the returned element
70+
- `ref: (c: HTMLElement) => any` - the ref you should pass to the returned element
71+
- `style: Object` - the style you should pass to the returned element
72+
- `active: boolean` - whether the view should currently be showing
73+
- `transitionState: 'in' | 'out' | 'entering' | 'leaving'` - the view's transition state
6574

6675
At minimum you should pass the `key`, `ref`, `style`, and `className` props to the returned element.
6776

6877
##### `numViews: number` **(required)**
6978

70-
The number of views present. `ViewSlider` will only render all views when transitioning; when idle, it will
79+
The number of views present. `ViewSlider` will only render all views when transitioning; when idle, it will
7180
only render the active view.
7281

7382
##### `activeView: number` **(required)**
7483

75-
The index of the view that should be showing. Whenever you change this, `ViewSlider` will animate a horizontal slide
84+
The index of the view that should be showing. Whenever you change this, `ViewSlider` will animate a horizontal slide
7685
transition to the view at the new index.
7786

7887
##### `keepViewsMounted: boolean` (default: `false`)
@@ -133,12 +142,12 @@ import ViewSlider from 'react-view-slider/lib/withTransitionContext'
133142
```
134143

135144
This works exactly like `ViewSlider` except that it renders its views within a `TransitionContext` component from
136-
`react-transition-context` with the given `transitionState`. This is useful for doing things like focusing an `<input>`
145+
`react-transition-context` with the given `transitionState`. This is useful for doing things like focusing an `<input>`
137146
element after one of the views has transitioned in.
138147

139148
## `SimpleViewSlider`
140149

141-
This is a wrapper for `ViewSlider` that takes a single child element. It renders the `ViewSlider` with the child's key
150+
This is a wrapper for `ViewSlider` that takes a single child element. It renders the `ViewSlider` with the child's key
142151
(converted to a number) as the `activeView` and caches past child elements by key.
143152

144153
### Example
@@ -148,24 +157,19 @@ import SimpleViewSlider from 'react-view-slider/lib/simple'
148157

149158
ReactDOM.render(
150159
<SimpleViewSlider>
151-
<div key={0}>
152-
This is view 0
153-
</div>
160+
<div key={0}>This is view 0</div>
154161
</SimpleViewSlider>,
155162
document.getElementById('root')
156163
)
157164

158165
// Rendering a child with a different key will trigger the transition.
159166
ReactDOM.render(
160167
<SimpleViewSlider>
161-
<div key={1}>
162-
This is view 1
163-
</div>
168+
<div key={1}>This is view 1</div>
164169
</SimpleViewSlider>,
165170
document.getElementById('root')
166171
)
167172
```
168173

169174
If you want to use `SimpleViewSlider` with `react-transition-context`,
170175
use `react-view-slider/lib/simpleWithTransitionContext`.
171-

0 commit comments

Comments
 (0)