тиндер почти готов, но есть на что посмотреть
All checks were successful
Create and publish a Docker image / Publish image (push) Successful in 50s
Create and publish a Docker image / Deploy image (push) Successful in 3s

This commit is contained in:
VITALY-VORON 2023-08-24 19:40:38 +03:00
parent 55e7796b96
commit 4c651d6835
2 changed files with 118 additions and 35 deletions

View File

@ -0,0 +1,68 @@
/* Tinder.css */
.tinder-container {
margin-top: 30%;
height: 50vh;
width: 100%;
display: flex;
justify-content: space-evenly;
align-items: center;
flex-direction: column;
overflow: hidden;
}
.card-container {
position: relative;
display: flex;
height: 80px;
width: 120px;
flex-direction: column;
}
.swipe {
position: absolute;
width: 100%;
max-width: 300px;
max-height: 400px;
cursor: pointer;
transition: transform 0.25s ease-in-out, opacity 0.25s ease-in-out;
}
.swipe-left {
transform: translateX(-100%) rotate(-5deg);
opacity: 0;
}
.swipe-right {
transform: translateX(100%) rotate(5deg);
opacity: 0;
}
.card {
width: 80px;
max-width: 300px;
max-height: 400px;
border-radius: 10px;
background-size: cover;
background-position: center;
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: flex-end;
padding: 16px;
box-shadow: 0px 2px 10px rgba(0, 0, 0, 0.1);
}
.card-content {
background-color: rgba(255, 255, 255, 0.8);
border-radius: 10px;
padding: 8px;
text-align: center;
}
.infoText {
margin-top: 16px;
}

View File

@ -1,5 +1,6 @@
import React, {useState} from 'react'; import React, {useState} from 'react';
import TinderCard from 'react-tinder-card' import TinderCard from 'react-tinder-card';
import './Tinder.css'
const db = [ const db = [
{ {
@ -24,46 +25,60 @@ const db = [
} }
] ]
const Tinder = ()=> { const Tinder = () => {
const characters = db;
const characters = db const [lastDirection, setLastDirection] = useState();
const [lastDirection, setLastDirection] = useState()
const swiped = (direction, nameToDelete) => { const swiped = (direction, nameToDelete) => {
console.log('removing: ' + nameToDelete) console.log('removing: ' + nameToDelete);
setLastDirection(direction) setLastDirection(direction);
} };
const outOfFrame = (name) => { const outOfFrame = (name) => {
console.log(name + ' left the screen!') console.log(name + ' left the screen!');
} };
return ( return (
<div style={{ <div className='tinder-container'>
height: '100vh', {/* <div style={{
width: '100%',
display: 'flex', display: 'flex',
justifyContent: 'center',
flexDirection: 'column', flexDirection: 'column',
height: '100%',
width: '100%',
alignContent: 'center',
flexWrap: 'wrap', flexWrap: 'wrap',
justifyContent: 'space-evenly',
alignItems: 'center', alignItems: 'center',
overflow: 'hidden', background: 'white',
}}> }}> */}
<link href='https://fonts.googleapis.com/css?family=Damion&display=swap' rel='stylesheet' /> <h1>Card</h1>
<link href='https://fonts.googleapis.com/css?family=Alatsi&display=swap' rel='stylesheet' /> <div className='card-container'>
<h1>React Tinder Card</h1> {characters.map((character) => (
<div className='cardContainer'> <TinderCard
{characters.map((character) => className='swipe'
<TinderCard className='swipe' key={character.name} onSwipe={(dir) => swiped(dir, character.name)} onCardLeftScreen={() => outOfFrame(character.name)}> key={character.name}
<div style={{ backgroundImage: 'url(' + character.url + ')' }} className='card'> onSwipe={(dir) => swiped(dir, character.name)}
<h3>{character.name}</h3> onCardLeftScreen={() => outOfFrame(character.name)}
>
<div className='card'>
<div
className='card-content'
style={{ backgroundImage: `url(${character.url})` }}
>
<h3>{character.name}</h3>
</div>
</div>
</TinderCard>
))}
</div> </div>
</TinderCard> {lastDirection ? (
<h2 className='infoText'>You swiped {lastDirection}</h2>
) : (
<h2 className='infoText' />
)} )}
</div>
{lastDirection ? <h2 className='infoText'>You swiped {lastDirection}</h2> : <h2 className='infoText' />}
</div> </div>
) // </div>
} );
};
export default Tinder;
export default Tinder;