Last active
February 27, 2022 17:13
-
-
Save DevMonzer/7efc09aaddff7cb79e087d6f9e2d7b6a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
.celebrities-component { | |
background-image: url('../../img/background.JPG'); | |
background-position: center center; | |
background-repeat: repeat; | |
background-size: 100% 100%; | |
overflow: hidden; | |
padding-left: 4rem; | |
} | |
.celebrities-container { | |
display: grid; | |
grid-template-columns: repeat(5, minmax(3.5rem, 1fr)); | |
place-items: center; | |
position: relative; | |
color: black; | |
} | |
.container { | |
margin-bottom: 2rem; | |
} | |
.celebrities-img { | |
width: 9rem; | |
height: 9rem; | |
border-radius: 50%; | |
border: 8px solid var(--color-black); | |
} | |
.celebrities-img:hover { | |
border: 8px solid var(--color-grey-light); | |
} | |
.celebrities-image { | |
width: 9rem; | |
height: 9rem; | |
} | |
.celebrities-paragraph { | |
color: rgb(255, 171, 15); | |
text-align: center; | |
font-size: 1.3rem; | |
font-weight: bold; | |
padding-top: 0.5rem; | |
} | |
h6 { | |
font-size: 1.5rem; | |
text-align: center; | |
} | |
p { | |
padding-top: 0.7rem; | |
} | |
button { | |
background-color: transparent; | |
border: none; | |
} | |
.voting-btn { | |
padding: 0.5rem 1rem; | |
border-radius: 5px; | |
color: var(--color-white); | |
background-color: var(--color-black); | |
transition: 0.3s; | |
} | |
.voting-btn:hover { | |
background-color: rgb(255, 171, 15); | |
color: var(--color-black); | |
} | |
/*********************** RESPONSIVENEES ***********************/ | |
@media only screen and (max-width: 2560px) { | |
.celebrities-container { | |
display: grid; | |
grid-template-columns: repeat(5, 1fr); | |
place-items: center; | |
padding: 1rem; | |
position: relative; | |
justify-content: center; | |
align-items: center; | |
} | |
} | |
@media only screen and (max-width: 1200px) { | |
.celebrities-component { | |
padding-left: 3rem; | |
} | |
} | |
@media only screen and (max-width: 1200px) { | |
.celebrities-component { | |
padding-left: 1.5rem; | |
} | |
} | |
@media only screen and (max-width: 900px) { | |
.celebrities-img { | |
width: 8rem; | |
height: 8rem; | |
border: 5px solid var(--color-black); | |
} | |
.celebrities-img:hover { | |
border: 5px solid var(--color-grey-light); | |
} | |
.celebrities-paragraph { | |
margin-top: -0.5rem; | |
} | |
/*********************** POPUP ************************/ | |
.click-me { | |
width: 5rem; | |
height: 2.5rem; | |
margin-left: 1.4rem; | |
} | |
.content { | |
left: -12%; | |
} | |
} | |
@media only screen and (max-width: 800px) { | |
.celebrities-img { | |
width: 7rem; | |
height: 7rem; | |
border: 5px solid var(--color-black); | |
} | |
.celebrities-img:hover { | |
border: 5px solid var(--color-grey-light); | |
} | |
.celebrities-paragraph { | |
font-size: 1rem; | |
} | |
} | |
@media only screen and (max-width: 700px) { | |
.celebrities-container { | |
padding-left: 0rem; | |
} | |
.celebrities-img { | |
width: 6rem; | |
height: 6rem; | |
} | |
/*********************** POPUP ************************/ | |
.click-me { | |
width: 3.8rem; | |
height: 2rem; | |
margin-left: 0.9rem; | |
} | |
.content { | |
width: 28rem; | |
left: -15%; | |
} | |
} | |
@media only screen and (max-width: 600px) { | |
.celebrities-img { | |
width: 5.5rem; | |
height: 5.5rem; | |
} | |
} | |
@media only screen and (max-width: 550px) { | |
.celebrities-paragraph { | |
font-size: 0.8rem; | |
font-weight: normal; | |
margin-top: -0.6rem; | |
} | |
.celebrities-img { | |
width: 5rem; | |
height: 5rem; | |
} | |
} | |
@media only screen and (max-width: 500px) { | |
.celebrities-img { | |
width: 4.5rem; | |
height: 4.5rem; | |
} | |
} | |
@media only screen and (max-width: 450px) { | |
.celebrities-component { | |
padding-left: 1rem; | |
} | |
.celebrities-img { | |
border: 3.5px solid var(--color-black); | |
} | |
.celebrities-img:hover { | |
border: 3.5px solid var(--color-grey-light); | |
} | |
.celebrities-img { | |
width: 4rem; | |
height: 4rem; | |
} | |
} | |
@media only screen and (max-width: 420px) { | |
.celebrities-img { | |
width: 3.6rem; | |
height: 3.6rem; | |
} | |
} | |
@media only screen and (max-width: 380px) { | |
.celebrities-img { | |
width: 3.4rem; | |
height: 3.4rem; | |
} | |
} |
This file contains hidden or 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
import React from 'react'; | |
import Dialog from '../Dialog/dialog'; | |
import img1 from '../../img/users/user-1.jpeg'; | |
import img2 from '../../img/users/user-2.jpeg'; | |
import img3 from '../../img/users/user-3.jpeg'; | |
import img4 from '../../img/users/user-4.jpg'; | |
import img5 from '../../img/users/user-5.jpg'; | |
import './Celebrities.css'; | |
export default class Celebrities extends React.Component { | |
constructor() { | |
super(); | |
this.state = { | |
celebrities: [ | |
{ | |
id: 1, | |
name: 'احمد', | |
img: `${img1}`, | |
fullName: 'احمد محمد احمد محمد', | |
info: 'احمد ipsum dolor sit amet consectetur adipisicing elit. Tenetur architecto voluptatibus ipsa saepe hic rem quis quidem molestiae suscipit tempore. ', | |
}, | |
{ | |
id: 2, | |
name: 'سارة', | |
img: `${img2}`, | |
fullName: 'سارة محمد', | |
info: 'سارة ipsum dolor sit amet consectetur adipisicing elit. Tenetur architecto voluptatibus ipsa saepe hic rem quis quidem molestiae suscipit tempore.', | |
}, | |
{ | |
id: 3, | |
name: 'محمد', | |
img: `${img3}`, | |
fullName: 'محمد احمد', | |
info: 'محمد ipsum dolor sit amet consectetur adipisicing elit. Tenetur architecto voluptatibus ipsa saepe hic rem quis quidem molestiae suscipit tempore.', | |
}, | |
{ | |
id: 4, | |
name: 'اسراء', | |
img: `${img4}`, | |
fullName: 'اسراء محمد', | |
info: 'اسراء ipsum dolor sit amet consectetur adipisicing elit. Tenetur architecto voluptatibus ipsa saepe hic rem quis quidem molestiae suscipit tempore. ', | |
}, | |
{ | |
id: 5, | |
name: 'حسن', | |
img: `${img5}`, | |
fullName: 'حسن محمد', | |
info: 'حسن ipsum dolor sit amet consectetur adipisicing elit. Tenetur architecto voluptatibus ipsa saepe hic rem quis quidem molestiae suscipit tempore. ', | |
}, | |
], | |
}; | |
} | |
// // Fetching data from the API | |
// componentDidMount() { | |
// fetch('https://jsonplaceholder.typicode.com/users') | |
// .then((reponse) => { | |
// if (!reponse.ok) | |
// throw new Error(`HTTP error! status: ${reponse.status}`); | |
// return reponse.json(); | |
// }) | |
// .then((users) => this.setState({ celebrities: users })) | |
// .catch((error) => alert(`${error} Reload the page 💥💥`)); | |
// } | |
render() { | |
return ( | |
<> | |
<div className="celebrities-component"> | |
<div className=" celebrities-container"> | |
{this.state.celebrities.map((celebrity) => ( | |
<div className="container" key={celebrity.id}> | |
<button onClick={(e) => this.setState({ isOpen: true })}> | |
<img | |
className="celebrities-img" | |
src={celebrity.img} | |
alt={`Celebrity ${celebrity.id}`} | |
/> | |
<p className="celebrities-paragraph">{celebrity.name}</p> | |
<p className="celebrities-paragraph">{celebrity.info}</p> | |
<p className="celebrities-paragraph">{celebrity.fullName}</p> | |
{console.log(celebrity.fullName)} | |
</button> | |
<Dialog | |
isOpen={this.state.isOpen} | |
onClose={(e) => this.setState({ isOpen: false })} | |
> | |
<h6>{celebrity.fullName}</h6> | |
{console.log(celebrity.fullName)} | |
<img | |
className="celebrities-image" | |
src={celebrity.img} | |
alt={`Celebrity ${celebrity.id}`} | |
/> | |
<p>{celebrity.info}</p> | |
<button className="voting-btn">{celebrity.name}</button> | |
</Dialog> | |
</div> | |
))} | |
</div> | |
</div> | |
</> | |
); | |
} | |
} |
This file contains hidden or 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
import React, { Component } from 'react'; | |
let dialogStyles = { | |
width: '500px', | |
maxWidth: '100%', | |
margin: '0 auto', | |
position: 'fixed', | |
left: '50%', | |
top: '50%', | |
transform: 'translate(-50%,-50%)', | |
zIndex: '999', | |
backgroundColor: '#eee', | |
padding: '10px 20px 40px', | |
borderRadius: '8px', | |
display: 'flex', | |
flexDirection: 'column', | |
}; | |
let dialogCloseButtonStyles = { | |
marginBottom: '15px', | |
padding: '3px 8px', | |
cursor: 'pointer', | |
borderRadius: '50%', | |
border: 'none', | |
width: '30px', | |
height: '30px', | |
fontWeight: 'bold', | |
alignSelf: 'flex-end', | |
}; | |
class Dialog extends Component { | |
render() { | |
let dialog = ( | |
<div style={dialogStyles}> | |
<button style={dialogCloseButtonStyles} onClick={this.props.onClose}> | |
x | |
</button> | |
<div>{this.props.children}</div> | |
</div> | |
); | |
if (!this.props.isOpen) { | |
dialog = null; | |
} | |
return <div>{dialog}</div>; | |
} | |
} | |
export default Dialog; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment