diff --git a/src/App.js b/src/App.js index 7937817..83064bd 100644 --- a/src/App.js +++ b/src/App.js @@ -24,25 +24,8 @@ import Home from "./components/home/Home"; import FlagsApi from "./components/flags/FlagsApi"; import Profile from "./components/flags/Profile"; -// -// const store = storeCreator(); -// -// -// - const store = createStore(appReducers); -// function addTodo(text) { -// return { -// type: 'ADD_TODO', -// text -// } -// } - -// store.dispatch(addTodo('Read the docs')) -// store.dispatch(addTodo('Read about the middleware')) - - store.dispatch({type: 'initial'}); // store.dispatch('add'); function App() { diff --git a/src/components/flags/FlagsApi.js b/src/components/flags/FlagsApi.js index 9c9c7a7..0e48f48 100644 --- a/src/components/flags/FlagsApi.js +++ b/src/components/flags/FlagsApi.js @@ -24,7 +24,8 @@ class FlagsApi extends React.Component { answerLocked = false; state = { - loading: true + loading: true, + paused: false }; async handleClick(action) { @@ -119,7 +120,7 @@ class FlagsApi extends React.Component { async startGame() { this.gameEnded = false; this.answerLocked = false; - this.setState({ loading: true }); + this.setState({ loading: true, paused: false }); this.stopTimer(); await this.handleClick('api') .then(() => this.startTimer()) @@ -167,6 +168,35 @@ class FlagsApi extends React.Component { this.array = []; console.log('Timer stop'); } + + togglePause = () => { + if (this.props.lifes <= 0) return; + + if (this.state.paused) { + this.resumeGame(); + } else { + this.pauseGame(); + } + } + + pauseGame = () => { + this.stopTimer(); + this.setState({ paused: true }); + } + + resumeGame = () => { + this.setState({ paused: false }); + this.startTimerFromCurrent(); + } + + startTimerFromCurrent = () => { + let interval = setInterval(() => { + this.props.dispatch({type: 'tick'}); + this.tickTimer(); + }, 1000); + + this.array.push(interval); + } tickTimer() { if (this.props.timer == 15) { @@ -174,7 +204,6 @@ class FlagsApi extends React.Component { } else { if (this.props.timer == 0) { this.timeout(); - } } } @@ -222,25 +251,9 @@ class FlagsApi extends React.Component { answers = []; question = []; prepareStat() { - // console.log('FOO'); - // console.log(this.props); - // console.log(this.props.flags); this.props.flagi.map((item) => - // () => alert() this.question.push(item) - // console.log(item) - // (item) => { alert(); console.log('xaxa' + item)} ); - - - // this.array.map(item => clearInterval(item)); - - - // console.log(); - // for (let item of this.props.flagi) { - // this.question.push(item.getAllKeys()[0]) - // } - // console.log(this.question); } saveAnswer(correct) { @@ -275,20 +288,17 @@ class FlagsApi extends React.Component {
Test your geography knowledge and compete for the top spot!
- {isLoggedIn ? ( - <> += 2 ? 'anim-desc-visible' : 'anim-hidden'}> + Test your geography knowledge and compete for the top spot! +
+No scores yet. Be the first to play!
) : ( -| + | = 4 ? 'anim-highscores-bounce' : 'anim-hidden'}`} + style={{ fontSize: '1.5rem', padding: '1rem' }} + > High Scores | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Rank | Player | Top Score | @@ -176,7 +244,7 @@ const Home = () => {Time Total | ||||||||
| {medal}{rank} | {player.firstName} | {player.highScore} | diff --git a/src/components/home/styles.css b/src/components/home/styles.css index 022d36a..cc83984 100644 --- a/src/components/home/styles.css +++ b/src/components/home/styles.css @@ -3,10 +3,20 @@ display: flex; flex-direction: column; min-height: 100vh; + overflow-x: hidden; +} + +.page-wrapper.animating { + overflow: hidden; +} + +body:has(.page-wrapper.animating) { + overflow: hidden; } .main-content { flex: 1; + overflow: hidden; } /* Close/Logout button */ @@ -249,3 +259,173 @@ text-align: center; } } + +/* ===== PAGE LOAD ANIMATIONS ===== */ + +/* Hidden state for all animated elements */ +.anim-hidden { + opacity: 0; + visibility: hidden; +} + +/* Title animation - fade in and scale */ +@keyframes titleAppear { + 0% { + opacity: 0; + transform: scale(0.8); + } + 100% { + opacity: 1; + transform: scale(1); + } +} + +.anim-title-visible { + animation: titleAppear 0.6s ease-out forwards; +} + +/* Description fade in */ +@keyframes descFadeIn { + 0% { + opacity: 0; + transform: translateY(-10px); + } + 100% { + opacity: 1; + transform: translateY(0); + } +} + +.anim-desc-visible { + animation: descFadeIn 0.5s ease-out forwards; +} + +/* Buttons appear */ +@keyframes buttonsAppear { + 0% { + opacity: 0; + transform: scale(0.9); + } + 50% { + transform: scale(1.05); + } + 100% { + opacity: 1; + transform: scale(1); + } +} + +.anim-buttons-visible { + animation: buttonsAppear 0.5s ease-out forwards; +} + +/* Table slide up from below (blurred) */ +@keyframes tableSlideUp { + 0% { + opacity: 0; + transform: translateY(100px); + } + 100% { + opacity: 1; + transform: translateY(0); + } +} + +.anim-table-hidden { + opacity: 0; + transform: translateY(100px); +} + +.anim-table-visible { + animation: tableSlideUp 0.8s ease-out forwards; +} + +/* Hide scrollbars on table during animation */ +.table-responsive { + overflow: hidden !important; +} + +.animating .leaderboard-table, +.animating .table-responsive { + overflow: hidden !important; + scrollbar-width: none; + -ms-overflow-style: none; +} + +.animating .leaderboard-table::-webkit-scrollbar, +.animating .table-responsive::-webkit-scrollbar { + display: none; +} + +/* High Scores bouncing text */ +@keyframes highScoresBounce { + 0% { + opacity: 0; + transform: translateX(100%); + } + 25% { + opacity: 1; + transform: translateX(-10%); + } + 45% { + transform: translateX(8%); + } + 65% { + transform: translateX(-4%); + } + 80% { + transform: translateX(2%); + } + 100% { + transform: translateX(0); + } +} + +.anim-highscores-bounce { + animation: highScoresBounce 1.2s ease-out forwards; +} + +/* Simple fade in */ +@keyframes fadeIn { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +.anim-fade-in { + animation: fadeIn 0.4s ease-out forwards; +} + +/* Row states - blurred and revealed */ +.anim-row-blurred td { + filter: blur(8px); + transition: filter 0.4s ease-out; +} + +.anim-row-revealed td { + filter: blur(0); + transition: filter 0.4s ease-out; +} + +/* Top scorer special reveal */ +@keyframes topScorerReveal { + 0% { + filter: blur(8px); + transform: scale(1); + } + 50% { + filter: blur(0); + transform: scale(1.02); + } + 100% { + filter: blur(0); + transform: scale(1); + } +} + +.leaderboard-table tbody tr:first-child.anim-row-revealed td { + animation: topScorerReveal 0.6s ease-out forwards; +}|||||||||