-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 32604e3
Showing
13 changed files
with
8,140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"presets": ["env", "react"], | ||
"plugins": [ | ||
"transform-class-properties" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
repo_token: e2373kVV1jqo1WsJ0vsksY214TujlFSSa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
coverage | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
language: node_js | ||
|
||
node_js: | ||
- stable | ||
|
||
install: | ||
- yarn install | ||
|
||
script: | ||
- yarn test | ||
- yarn cover | ||
|
||
# Send coverage data to Coveralls | ||
after_script: "cat coverage/lcov.info | node_modules/coveralls/bin/coveralls.js" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(The MIT License) | ||
|
||
Copyright (c) 2009-2014 TJ Holowaychuk <[email protected]> | ||
Copyright (c) 2013-2014 Roman Shtylman <[email protected]> | ||
Copyright (c) 2014-2015 Douglas Christopher Wilson <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# React Swipy (`react-swipy`) | ||
[](https://travis-ci.org/goncy/react-swipy) | ||
[](https://coveralls.io/github/goncy/react-swipy?branch=master) | ||
|
||
A simple Tinder-like swipeable React component | ||
|
||
## Installation | ||
```sh | ||
npm install --save react-swipy | ||
``` | ||
|
||
## Why | ||
I didn't like the lack of control on mose deck-based swipeable components out there | ||
|
||
## How | ||
[](https://codesandbox.io/s/5x53pnrn3x) | ||
```jsx | ||
import React, {Component} from "react"; | ||
import Swipeable from "react-swipy" | ||
|
||
import Card from "./components/Card"; | ||
import Button from "./components/Button"; | ||
|
||
const wrapperStyles = {position: "relative", width: "250px", height: "250px"}; | ||
const actionsStyles = { | ||
display: "flex", | ||
justifyContent: "space-between", | ||
marginTop: 12, | ||
}; | ||
|
||
class App extends Component { | ||
state = { | ||
cards: ["First", "Second", "Third"], | ||
}; | ||
|
||
remove = () => | ||
this.setState(({cards}) => ({ | ||
cards: cards.slice(1, cards.length), | ||
})); | ||
|
||
render() { | ||
const {cards} = this.state; | ||
|
||
return ( | ||
<div> | ||
<div style={wrapperStyles}> | ||
{cards.length > 0 ? ( | ||
<div style={wrapperStyles}> | ||
<Swipeable | ||
buttons={({right, left}) => ( | ||
<div style={actionsStyles}> | ||
<Button onClick={right}>Accept</Button> | ||
<Button onClick={left}>Reject</Button> | ||
</div> | ||
)} | ||
onAfterSwipe={this.remove} | ||
> | ||
<Card>{cards[0]}</Card> | ||
</Swipeable> | ||
{cards.length > 1 && <Card zIndex={-1}>{cards[1]}</Card>} | ||
</div> | ||
) : ( | ||
<Card zIndex={-2}>No more cards</Card> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default App; | ||
``` |
Oops, something went wrong.