Skip to content

Commit

Permalink
cleaned up and made new css file to make vote.js look better
Browse files Browse the repository at this point in the history
  • Loading branch information
candywal committed Dec 6, 2023
1 parent 89a81c2 commit dd67b5f
Showing 1 changed file with 14 additions and 35 deletions.
49 changes: 14 additions & 35 deletions Frontend/src/pages/vote.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,9 @@
import React, { useState } from 'react';
import Image from 'next/image';

import styles from './vote.module.css';

// Inline styling
const styles = {
container: {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
gap: '20px',
position: 'relative',
},
imageWrapper: {
position: 'relative',
width: '300px', // Adjust based on how large you want the images to display
height: '300px', // Adjust based on how large you want the images to display
cursor: 'pointer',
transition: 'transform 1s, opacity 1s',
},
default: {
opacity: 1, // Ensure the default opacity is 1
transform: 'scale(1)',
},
winning: {
transform: 'scale(1.2)',
zIndex: 1,
},
losing: {
opacity: 0.5,
},
};

export default function Vote() {
const [images, setImages] = useState([{ src: '/image1.png', id: 1 }, { src: '/image1.png', id: 2 }]);
Expand All @@ -44,26 +19,30 @@ export default function Vote() {
};

return (
<div style={styles.container}>
<div className={styles.container}>
{images.map((image) => (
<div
key={image.id}
style={{
...styles.imageWrapper,
...(selectedImage === null ? styles.default : selectedImage === image.id ? styles.winning : styles.losing),
}}
className={`${styles.imageWrapper} ${
selectedImage === null
? styles.default
: selectedImage === image.id
? styles.winning
: styles.losing
}`}
onClick={() => handleImageClick(image.id)}
>
<Image
src={image.src}
alt='Votable Image'
width={1024} // Original width of the image
height={1024} // Original height of the image
style={{ width: '100%', height: '100%' }} // Adjust the display size within the wrapper
width={1024}
height={1024}
style={{ width: '100%', height: '100%' }}
/>
</div>
))}
</div>

);
}

Expand Down

0 comments on commit dd67b5f

Please sign in to comment.