Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
"format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,css,scss,json,md}\""
},
"devDependencies": {
"prettier": "^3.6.2"
"autoprefixer": "^10.4.21",
"postcss": "^8.5.6",
"prettier": "^3.6.2",
"tailwindcss": "^3.4.18"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe use tailwind 4

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tailwind v3 is more stable than v4, that's why i used it.

},
"eslintConfig": {
"extends": [
Expand Down
6 changes: 6 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: [
require('tailwindcss'),
require('autoprefixer')
],
};
4 changes: 2 additions & 2 deletions src/components/celebration/Celebration.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.celebration-notification {
/* .celebration-notification {
position: fixed;
top: 30%;
left: 50%;
Expand Down Expand Up @@ -67,4 +67,4 @@ h3 {
100% {
opacity: 1;
}
}
} */
118 changes: 103 additions & 15 deletions src/components/celebration/Celebration.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import './Celebration.css';
import React, { useRef } from 'react';
import ShareButton from './../sharebutton/ShareButton';
import PropTypes from 'prop-types';
Expand All @@ -9,22 +8,111 @@ export default function Celebration({
handleRestartGame,
}) {
const highScoreRef = useRef(null);

return (
<div className='celebration-container'>
<div className='celebration-notification'>
<p ref={highScoreRef}>
Highscore achieved: <span>{highScore}</span>
<br />
</p>
{
<p>
<span>{elapsedTime}s</span>
</p>
<div
style={{
position: 'fixed',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
zIndex: 9999,
width: '90%',
maxWidth: '500px',
backgroundColor: 'rgba(0, 0, 0, 0.9)',
backdropFilter: 'blur(10px)',
borderRadius: '12px',
padding: '40px 30px',
textAlign: 'center',
boxShadow: '0 8px 32px rgba(0, 0, 0, 0.5)',
animation: 'fadeIn 0.5s ease-in-out',
}}
>
Comment on lines +15 to +30

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are here so many inline Styles?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I first tried tailwind implementation, but it was not that effective. That's why I switched to inline for more prioritized CSS.

<style>{`
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
<div className='button'>
<ShareButton highScore={highScore} highScoreRef={highScoreRef} />
</div>
<button onClick={handleRestartGame} className='restart-btn'>
`}</style>

<p
ref={highScoreRef}
style={{
margin: 0,
padding: 0,
fontSize: '24px',
fontWeight: '600',
color: '#06b6d4',
marginBottom: '20px',
}}
>
Highscore achieved:{' '}
<span
style={{
color: '#84cc16',
fontSize: '32px',
fontWeight: 'bold',
display: 'inline-block',
marginLeft: '10px',
}}
>
{highScore}
</span>
</p>

<p
style={{
margin: 0,
padding: 0,
fontSize: '18px',
color: '#06b6d4',
marginBottom: '30px',
}}
>
Time:{' '}
<span
style={{
color: '#84cc16',
fontWeight: 'bold',
}}
>
{elapsedTime}s
</span>
</p>

<div
style={{
display: 'flex',
flexDirection: 'column',
gap: '15px',
alignItems: 'center',
}}
>
<ShareButton highScore={highScore} highScoreRef={highScoreRef} />
<button
onClick={handleRestartGame}
style={{
padding: '12px 24px',
border: '2px solid #06b6d4',
backgroundColor: 'transparent',
color: '#06b6d4',
fontWeight: '600',
fontSize: '16px',
borderRadius: '6px',
cursor: 'pointer',
width: '100%',
transition: 'all 0.3s ease',
boxSizing: 'border-box',
}}
onMouseEnter={e => {
e.target.style.backgroundColor = 'rgba(6, 182, 212, 0.1)';
e.target.style.transform = 'scale(1.02)';
}}
onMouseLeave={e => {
e.target.style.backgroundColor = 'transparent';
e.target.style.transform = 'scale(1)';
}}
>
Restart Game
</button>
</div>
Expand Down
Loading