Skip to content

Commit c8dcad7

Browse files
andrewboldiclaude
andcommitted
refactor: move timer and bookmark into answer row
Timer countdown and bookmark icon now sit to the right of the give-up button in the same flex row, instead of floating as separate blocks. Cleaner layout, everything answer-related in one line. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent bd69cf6 commit c8dcad7

2 files changed

Lines changed: 28 additions & 15 deletions

File tree

src/lib/components/AnswerInput.svelte

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
<script lang="ts">
2+
import Timer from './Timer.svelte';
3+
24
interface Props {
35
examType: string;
46
onSubmit: (answer: string) => void;
57
onGiveUp: () => void;
8+
timerEnabled?: boolean;
9+
timerRunning?: boolean;
10+
timerSeconds?: number;
11+
bookmarked?: boolean;
12+
onBookmarkToggle?: () => void;
613
}
714
8-
let { examType, onSubmit, onGiveUp }: Props = $props();
15+
let { examType, onSubmit, onGiveUp, timerEnabled = false, timerRunning = false, timerSeconds = 180, bookmarked = false, onBookmarkToggle }: Props = $props();
916
let answer = $state('');
1017
let shaking = $state(false);
1118
@@ -51,6 +58,15 @@
5158
<!-- svelte-ignore a11y_click_events_have_key_events -->
5259
<!-- svelte-ignore a11y_no_static_element_interactions -->
5360
<span class="give-up" onclick={onGiveUp} title="Give up">&#127937;</span>
61+
{#if timerEnabled}
62+
<Timer running={timerRunning} />
63+
{/if}
64+
{#if onBookmarkToggle}
65+
<!-- svelte-ignore a11y_click_events_have_key_events -->
66+
<!-- svelte-ignore a11y_no_static_element_interactions -->
67+
<span class="bookmark-icon" onclick={onBookmarkToggle} title={bookmarked ? 'Remove bookmark' : 'Bookmark problem'}
68+
style="opacity: {bookmarked ? 1 : 0.3};">&#x1F516;</span>
69+
{/if}
5470
</div>
5571

5672
<style>
@@ -82,4 +98,10 @@
8298
font-size: 1.4em;
8399
margin-left: 12px;
84100
}
101+
.bookmark-icon {
102+
cursor: pointer;
103+
font-size: 1.4em;
104+
margin-left: 8px;
105+
transition: opacity 0.2s;
106+
}
85107
</style>

src/routes/play/+page.svelte

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import SolutionDisplay from '$lib/components/SolutionDisplay.svelte';
1111
import NextProblemButton from '$lib/components/NextProblemButton.svelte';
1212
import PrevProblemButton from '$lib/components/PrevProblemButton.svelte';
13-
import Timer from '$lib/components/Timer.svelte';
13+
1414
import DrawingCanvas from '$lib/components/DrawingCanvas.svelte';
1515
import SettingsModal from '$lib/components/SettingsModal.svelte';
1616
import StatsModal from '$lib/components/StatsModal.svelte';
@@ -126,25 +126,16 @@
126126
{textInvertFilter}
127127
/>
128128

129-
{#if $problem.id && $problem.status !== 'loading'}
130-
<!-- svelte-ignore a11y_click_events_have_key_events -->
131-
<!-- svelte-ignore a11y_no_static_element_interactions -->
132-
<div class="bookmark-btn text" onclick={() => bookmarks.toggle($problem.id)}
133-
style="text-align: center; cursor: pointer; font-size: 1.5em; opacity: {$bookmarks.includes($problem.id) ? 1 : 0.3};">
134-
&#x1F516;
135-
</div>
136-
{/if}
137-
138-
{#if $settings.timer === 'On' && ($problem.status === 'answering' || $problem.status === 'loading')}
139-
<Timer running={$problem.status === 'answering'} />
140-
{/if}
141-
142129
{#if $problem.status === 'answering' || $problem.status === 'loading'}
143130
<AnswerInput
144131
bind:this={answerInput}
145132
examType={$problem.examType}
146133
onSubmit={handleSubmit}
147134
onGiveUp={() => { if (confirm('Are you sure you want to give up?')) giveUp(); }}
135+
timerEnabled={$settings.timer === 'On'}
136+
timerRunning={$problem.status === 'answering'}
137+
bookmarked={$bookmarks.includes($problem.id)}
138+
onBookmarkToggle={() => bookmarks.toggle($problem.id)}
148139
/>
149140
{/if}
150141

0 commit comments

Comments
 (0)