Cards
This commit is contained in:
parent
edccd52fbd
commit
0cc7a05e94
@ -3,6 +3,7 @@ import './App.css';
|
|||||||
import Start from './components/Start/Start';
|
import Start from './components/Start/Start';
|
||||||
import Second from './components/Second/Second';
|
import Second from './components/Second/Second';
|
||||||
import Tinder from './components/Tinder/Tinder';
|
import Tinder from './components/Tinder/Tinder';
|
||||||
|
import Map from './components/Map/Map';
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
|
||||||
@ -18,7 +19,10 @@ function App() {
|
|||||||
content = <Second getValue={handleButtonValue}/>
|
content = <Second getValue={handleButtonValue}/>
|
||||||
break;
|
break;
|
||||||
case '/tinder':
|
case '/tinder':
|
||||||
content = <Tinder />
|
content = <Tinder getValue={handleButtonValue}/>
|
||||||
|
break;
|
||||||
|
case '/map':
|
||||||
|
content = <Map/>
|
||||||
break;
|
break;
|
||||||
default: content = <Start getValue={handleButtonValue}/>
|
default: content = <Start getValue={handleButtonValue}/>
|
||||||
}
|
}
|
||||||
|
9
src/components/Map/Map.js
Normal file
9
src/components/Map/Map.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
const Map = () => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Map;
|
9
src/components/Second/Map/Map.js
Normal file
9
src/components/Second/Map/Map.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
const Map = () => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Map;
|
@ -1,6 +1,6 @@
|
|||||||
.tinder-container {
|
.tinder-container {
|
||||||
margin-top: 30%;
|
margin-top: 30%;
|
||||||
height: 50vh;
|
height: 85vh;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
@ -13,13 +13,14 @@
|
|||||||
.card-container {
|
.card-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
height: 80px;
|
height: 100%;
|
||||||
width: 120px;
|
width: 300px;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.swipe {
|
.swipe {
|
||||||
|
margin-top: 15%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
@ -40,7 +41,8 @@
|
|||||||
|
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
width: 80px;
|
height: 400px;
|
||||||
|
width: 90%;
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
max-height: 400px;
|
max-height: 400px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
@ -25,26 +25,43 @@ const db = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const Tinder = () => {
|
const Tinder = (props) => {
|
||||||
|
|
||||||
|
const route = props.getValue;
|
||||||
|
|
||||||
const characters = db;
|
const characters = db;
|
||||||
const [lastDirection, setLastDirection] = useState();
|
const [lastDirection, setLastDirection] = useState();
|
||||||
const [cardId, setCardId] = useState([]);
|
const [cardId, setCardId] = useState([]);
|
||||||
|
const [allIds, setAllIds] = useState([]);
|
||||||
const swiped = (direction, id) => {
|
const [cardLenth, setCardLenth] = useState(false);
|
||||||
setLastDirection(direction);
|
|
||||||
if (direction === 'right') {
|
|
||||||
cardId.push(id);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
let uniqueTags = [];
|
let uniqueTags = [];
|
||||||
|
let allTags = [];
|
||||||
|
|
||||||
|
const swiped = (direction, id) => {
|
||||||
|
setLastDirection(direction);
|
||||||
|
allIds.push(id);
|
||||||
|
if (direction === 'right') {
|
||||||
|
cardId.push(id);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
const getId = () => {
|
const getId = () => {
|
||||||
|
|
||||||
uniqueTags = cardId.filter(function(elem, pos) {
|
uniqueTags = cardId.filter(function(elem, pos) {
|
||||||
return cardId.indexOf(elem) === pos;
|
return cardId.indexOf(elem) === pos;
|
||||||
});
|
});
|
||||||
console.log(uniqueTags);
|
|
||||||
|
allTags = allIds.filter(function(elem, pos){
|
||||||
|
return allIds.indexOf(elem) === pos;
|
||||||
|
});
|
||||||
|
|
||||||
|
characters.length === allTags.length ? setCardLenth(true) : setCardLenth(false);
|
||||||
|
|
||||||
|
if(cardLenth) {
|
||||||
|
route('/map')
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -58,7 +75,7 @@ const db = [
|
|||||||
onSwipe={(dir) => {
|
onSwipe={(dir) => {
|
||||||
swiped(dir, character.id);
|
swiped(dir, character.id);
|
||||||
getId();
|
getId();
|
||||||
console.log(uniqueTags);
|
// console.log(uniqueTags);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div className='card'>
|
<div className='card'>
|
||||||
@ -72,11 +89,6 @@ const db = [
|
|||||||
</TinderCard>
|
</TinderCard>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{lastDirection ? (
|
|
||||||
<h2 className='infoText'>You swiped {lastDirection}</h2>
|
|
||||||
) : (
|
|
||||||
null
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user