Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
goncy committed Jun 8, 2018
0 parents commit 32604e3
Show file tree
Hide file tree
Showing 13 changed files with 8,140 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": ["env", "react"],
"plugins": [
"transform-class-properties"
]
}
1 change: 1 addition & 0 deletions .coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
repo_token: e2373kVV1jqo1WsJ0vsksY214TujlFSSa
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
coverage
dist
14 changes: 14 additions & 0 deletions .travis.yml
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"
24 changes: 24 additions & 0 deletions LICENSE
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.
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# React Swipy (`react-swipy`)
[![Build Status](https://travis-ci.org/goncy/react-swipy.svg?branch=master)](https://travis-ci.org/goncy/react-swipy)
[![Coverage Status](https://coveralls.io/repos/github/goncy/react-swipy/badge.svg?branch=master)](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
[![See in CodeSandbox](https://codesandbox.io/static/img/play-codesandbox.svg)](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;
```
Loading

0 comments on commit 32604e3

Please sign in to comment.