mirror of
https://github.com/shadoll/sLogos.git
synced 2026-02-04 11:03:24 +00:00
Refactor Footer and Header components for improved layout; enhance FlagQuiz with question re-rendering and state management
This commit is contained in:
@@ -4,8 +4,9 @@
|
|||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<div class="footer-flex">
|
<div class="footer-flex">
|
||||||
<span class="footer-left">shadoll Logo Gallery</span>
|
|
||||||
<span class="footer-center">All logos are property of their respective owners.</span>
|
<span class="footer-center">All logos are property of their respective owners.</span>
|
||||||
|
<div class="footer-bottom">
|
||||||
|
<span class="footer-left">shadoll Logo Gallery and Quiz game</span>
|
||||||
<a
|
<a
|
||||||
href="https://github.com/shadoll/sLogos"
|
href="https://github.com/shadoll/sLogos"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
@@ -23,13 +24,12 @@
|
|||||||
/></svg>
|
/></svg>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</div>
|
||||||
|
</footer><style>
|
||||||
<style>
|
|
||||||
footer {
|
footer {
|
||||||
padding: 1.5rem;
|
padding: 1.5rem;
|
||||||
background: var(--color-background);
|
background: var(--color-background);
|
||||||
color: var(--color-text-muted);
|
color: var(--color-text-secondary);
|
||||||
border-top: 1px solid var(--color-border);
|
border-top: 1px solid var(--color-border);
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
margin-top: auto;
|
margin-top: auto;
|
||||||
@@ -43,19 +43,24 @@
|
|||||||
gap: 1em;
|
gap: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer-left {
|
|
||||||
flex: 1;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer-center {
|
.footer-center {
|
||||||
flex: 2;
|
flex: 2;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-bottom {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex: 1;
|
||||||
|
gap: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-left {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.footer-github {
|
.footer-github {
|
||||||
flex: 0;
|
|
||||||
margin-left: 1em;
|
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
@@ -63,16 +68,27 @@
|
|||||||
@media (max-width: 700px) {
|
@media (max-width: 700px) {
|
||||||
.footer-flex {
|
.footer-flex {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
align-items: center;
|
||||||
gap: 0.3em;
|
gap: 0.5em;
|
||||||
}
|
}
|
||||||
.footer-left, .footer-center {
|
|
||||||
text-align: left;
|
.footer-center {
|
||||||
|
text-align: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
margin-bottom: 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.footer-bottom {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-left {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
.footer-github {
|
.footer-github {
|
||||||
margin-left: 0;
|
margin-left: auto;
|
||||||
margin-top: 0.5em;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -399,10 +399,6 @@
|
|||||||
color: #6b7280; /* gray */
|
color: #6b7280; /* gray */
|
||||||
}
|
}
|
||||||
|
|
||||||
.achievement-block {
|
|
||||||
margin-left: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 700px) {
|
@media (max-width: 700px) {
|
||||||
.header-row {
|
.header-row {
|
||||||
grid-template-columns: 1fr auto auto;
|
grid-template-columns: 1fr auto auto;
|
||||||
|
|||||||
@@ -33,6 +33,9 @@
|
|||||||
let timerDuration = 2000; // 2 seconds
|
let timerDuration = 2000; // 2 seconds
|
||||||
let timerStartTime = 0;
|
let timerStartTime = 0;
|
||||||
|
|
||||||
|
// Force component re-render key to prevent button state persistence
|
||||||
|
let questionKey = 0;
|
||||||
|
|
||||||
// Scoring
|
// Scoring
|
||||||
let score = { correct: 0, total: 0, skipped: 0 };
|
let score = { correct: 0, total: 0, skipped: 0 };
|
||||||
let gameStats = { correct: 0, wrong: 0, total: 0, skipped: 0 };
|
let gameStats = { correct: 0, wrong: 0, total: 0, skipped: 0 };
|
||||||
@@ -206,6 +209,26 @@
|
|||||||
// Cancel any active auto-advance timer
|
// Cancel any active auto-advance timer
|
||||||
cancelAutoAdvanceTimer();
|
cancelAutoAdvanceTimer();
|
||||||
|
|
||||||
|
// Increment question key to force complete re-render and clear button states
|
||||||
|
questionKey++;
|
||||||
|
|
||||||
|
// Remove focus from any previously focused buttons and ensure clean state
|
||||||
|
if (typeof document !== 'undefined') {
|
||||||
|
// Use setTimeout to ensure DOM updates are complete
|
||||||
|
setTimeout(() => {
|
||||||
|
const activeElement = document.activeElement;
|
||||||
|
if (activeElement && activeElement.tagName === 'BUTTON') {
|
||||||
|
activeElement.blur();
|
||||||
|
}
|
||||||
|
// Force removal of any residual button states
|
||||||
|
const buttons = document.querySelectorAll('.option, .flag-option');
|
||||||
|
buttons.forEach(button => {
|
||||||
|
button.blur();
|
||||||
|
button.classList.remove('selected', 'correct', 'wrong');
|
||||||
|
});
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Randomly choose question type
|
// Randomly choose question type
|
||||||
questionType = Math.random() < 0.5 ? 'flag-to-country' : 'country-to-flag';
|
questionType = Math.random() < 0.5 ? 'flag-to-country' : 'country-to-flag';
|
||||||
|
|
||||||
@@ -647,7 +670,7 @@
|
|||||||
<img src={getFlagImage(currentQuestion.correct)} alt="Flag" class="quiz-flag" />
|
<img src={getFlagImage(currentQuestion.correct)} alt="Flag" class="quiz-flag" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="options">
|
<div class="options" key={questionKey}>
|
||||||
{#each currentQuestion.options as option, index}
|
{#each currentQuestion.options as option, index}
|
||||||
<button
|
<button
|
||||||
class="option"
|
class="option"
|
||||||
@@ -684,7 +707,7 @@
|
|||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flag-options">
|
<div class="flag-options" key={questionKey}>
|
||||||
{#each currentQuestion.options as option, index}
|
{#each currentQuestion.options as option, index}
|
||||||
<button
|
<button
|
||||||
class="flag-option"
|
class="flag-option"
|
||||||
@@ -1078,6 +1101,12 @@
|
|||||||
background: var(--color-bg-hover);
|
background: var(--color-bg-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Prevent residual hover states on new questions */
|
||||||
|
.option:not(:hover):not(.selected):not(.correct):not(.wrong) {
|
||||||
|
border-color: var(--color-border);
|
||||||
|
background: var(--color-bg-primary);
|
||||||
|
}
|
||||||
|
|
||||||
.option.selected {
|
.option.selected {
|
||||||
border-color: var(--color-primary);
|
border-color: var(--color-primary);
|
||||||
background: var(--color-primary-light);
|
background: var(--color-primary-light);
|
||||||
@@ -1119,6 +1148,12 @@
|
|||||||
background: var(--color-bg-hover);
|
background: var(--color-bg-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Prevent residual hover states on new questions for flag options */
|
||||||
|
.flag-option:not(:hover):not(.selected):not(.correct):not(.wrong) {
|
||||||
|
border-color: var(--color-border);
|
||||||
|
background: var(--color-bg-primary);
|
||||||
|
}
|
||||||
|
|
||||||
.flag-option.selected {
|
.flag-option.selected {
|
||||||
border-color: var(--color-primary);
|
border-color: var(--color-primary);
|
||||||
background: var(--color-primary-light);
|
background: var(--color-primary-light);
|
||||||
|
|||||||
Reference in New Issue
Block a user