diff --git a/package-lock.json b/package-lock.json index 76c2576..6b7bfe5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,10 @@ "web-vitals": "^1.1.2" }, "devDependencies": { - "prettier": "^3.6.2" + "autoprefixer": "^10.4.21", + "postcss": "^8.5.6", + "prettier": "^3.6.2", + "tailwindcss": "^3.4.18" } }, "node_modules/@adobe/css-tools": { diff --git a/package.json b/package.json index ad83776..836085d 100644 --- a/package.json +++ b/package.json @@ -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" }, "eslintConfig": { "extends": [ diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..2428c34 --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: [ + require('tailwindcss'), + require('autoprefixer') + ], +}; diff --git a/src/components/celebration/Celebration.css b/src/components/celebration/Celebration.css index 011b4c7..856f357 100644 --- a/src/components/celebration/Celebration.css +++ b/src/components/celebration/Celebration.css @@ -1,4 +1,4 @@ -.celebration-notification { +/* .celebration-notification { position: fixed; top: 30%; left: 50%; @@ -67,4 +67,4 @@ h3 { 100% { opacity: 1; } -} +} */ diff --git a/src/components/celebration/Celebration.js b/src/components/celebration/Celebration.js index 2c66267..63033e7 100644 --- a/src/components/celebration/Celebration.js +++ b/src/components/celebration/Celebration.js @@ -1,4 +1,3 @@ -import './Celebration.css'; import React, { useRef } from 'react'; import ShareButton from './../sharebutton/ShareButton'; import PropTypes from 'prop-types'; @@ -9,22 +8,111 @@ export default function Celebration({ handleRestartGame, }) { const highScoreRef = useRef(null); + return ( -
-
-

- Highscore achieved: {highScore} -
-

- { -

- {elapsedTime}s -

+
+ + +

+ Highscore achieved:{' '} + + {highScore} + +

+ +

+ Time:{' '} + + {elapsedTime}s + +

+ +
+ +
diff --git a/src/components/sharebutton/ShareButton.js b/src/components/sharebutton/ShareButton.js index aa76032..84c80f6 100644 --- a/src/components/sharebutton/ShareButton.js +++ b/src/components/sharebutton/ShareButton.js @@ -1,13 +1,11 @@ -import './sharebutton.css'; import React, { useState } from 'react'; import html2canvas from 'html2canvas'; import PropTypes from 'prop-types'; export default function ShareButton({ highScore, highScoreRef }) { const [screenshotImage, setScreenshotImage] = useState(null); + const [isDialogOpen, setIsDialogOpen] = useState(false); - const shareDialog = document.querySelector('.share-dialog'); - const closeButton = document.querySelector('.close-button'); const handleScreenshot = () => { html2canvas(highScoreRef.current, { useCORS: true, @@ -24,8 +22,10 @@ export default function ShareButton({ highScore, highScoreRef }) { .catch(error => { console.error('Error capturing screenshot:', error); }); + shareContent(); }; + const shareContent = async () => { if (navigator.share && screenshotImage) { try { @@ -37,172 +37,121 @@ export default function ShareButton({ highScore, highScoreRef }) { new File(['highScore'], screenshotImage, { type: 'image/jpeg' }), ], }); - console.log('Sharing successfully!'); + console.log('Shared successfully!'); } catch (error) { - console.error('Error while sharing: ', error); + console.error('Error while sharing:', error); } } else { - shareDialog.classList.add('is-open'); - closeButton.addEventListener('click', event => { - shareDialog.classList.remove('is-open'); - }); + setIsDialogOpen(true); } }; - const closeDialog = () => { - shareDialog.classList.remove('is-open'); - }; - return ( -
-
-
-

Share this pen

- -
-
- - + const closeDialog = () => setIsDialogOpen(false); - + return ( +
+ {/* Overlay and Dialog */} + {isDialogOpen && ( +
+
+
+

+ Share this game +

+ +
- -
-
-
https://aa-memory.vercel.app/
- + {/* Share Buttons */} +
+ {[ + { name: 'Facebook', color: '#3b5998' }, + { name: 'Twitter', color: '#1da1f2' }, + { name: 'LinkedIn', color: '#0077B5' }, + { name: 'Email', color: '#777' }, + ].map(platform => ( + + ))} +
+ + {/* Link Row */} +
+ + https://aa-memory.vercel.app/ + + +
+
-
+ )} + {/* Main Share Button */} - - - - - - - - - - + - - - - - - - - - - - - - - - - - + d='M4 12v8a2 2 0 002 2h12a2 2 0 002-2v-8m-6-6l-4 4m0 0l4 4m-4-4h12' + /> + + Share + - - - - - - - + {/* Inline Tailwind animation definition */} +
); } -// PropTypes validation ShareButton.propTypes = { highScore: PropTypes.number.isRequired, highScoreRef: PropTypes.shape({ diff --git a/src/components/sharebutton/sharebutton.css b/src/components/sharebutton/sharebutton.css index b86245b..8f6a077 100644 --- a/src/components/sharebutton/sharebutton.css +++ b/src/components/sharebutton/sharebutton.css @@ -1,4 +1,4 @@ -html { +/* html { box-sizing: border-box; } @@ -129,4 +129,4 @@ header { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; -} +} */ diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..d433e68 --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,48 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + darkMode: 'class', // enable class-based dark mode + theme: { + extend: { + // Custom breakpoints + screens: { + 'xxs': '320px', // extra extra small + 'xs': '390px', // extra small + }, + // Custom keyframes + keyframes: { + fade: { + '0%': { opacity: '0' }, + '100%': { opacity: '1' }, + }, + // fadeIn: { + // '0%': { opacity: '0', transform: 'scale(0.95)' }, + // '100%': { opacity: '1', transform: 'scale(1)' }, + // }, + shake: { + '10%, 90%': { transform: 'translateX(-1px)' }, + '20%, 80%': { transform: 'translateX(2px)' }, + '30%, 50%, 70%': { transform: 'translateX(-4px)' }, + '40%, 60%': { transform: 'translateX(4px)' }, + }, + collapse: { + '0%': { transform: 'scale(1) rotate(0deg)' }, + '50%': { transform: 'scale(0.2) rotate(360deg)' }, + '100%': { transform: 'scale(1) rotate(720deg)' }, + }, + }, + // Animation utilities + animation: { + fade: 'fade 3s linear', + // fadeIn: 'fadeIn 0.3s ease-out forwards', + shake: 'shake 1s cubic-bezier(0.36, 0.07, 0.19, 0.97)', + collapse: 'collapse 1.2s forwards', + }, + // Optional: light/dark theme variables + colors: { + themeText: 'var(--text)', + themeBg: 'var(--background)', + }, + }, + }, + plugins: [], +};