Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | 10x 10x 6x 8x 4x 2x 6x 6x 6x 7x 3x 7x 4x 3x 10x 5x 5x 5x 5x 1x 4x 4x 5x 5x 5x 5x 4x 5x | <script lang="ts">
import { history } from '../stores/history.svelte'
import { settings } from '../stores/settings.svelte'
import type { TimerMode } from '../types'
function formatTime(ms: number) {
return new Date(ms).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })
}
function formatDate(ms: number) {
return new Date(ms).toLocaleDateString()
}
const t = settings.t
function getModeLabel(mode: TimerMode) {
if (mode === 'work') return t('work')
if (mode === 'short-break') return t('shortBreak')
if (Emode === 'long-break') return t('longBreak')
return mode
}
</script>
<div class="history-panel">
<div class="history-header">
<h2 id="history-title" class="history-heading">{t('historyTitle')}</h2>
{#if history.entries.length > 0}
<button class="btn-clear" onclick={() => history.clearHistory()}>{t('clearHistory')}</button>
{/if}
</div>
{#if history.entries.length === 0}
<p class="empty">{t('emptyHistory')}</p>
{:else}
<ul class="history-list" role="list">
{#each history.entries as entry (entry.id)}
<li
class="history-item"
role="listitem"
class:play-event={entry.type === 'play'}
aria-label="{entry.type === 'play' ? t('sessionStart') : getModeLabel(entry.mode)}: {entry.taskTitle || t('semTarefa')} - {formatDate(entry.completedAt)} {formatTime(entry.completedAt)}"
>
<div class="history-main">
{#if entry.type === 'play'}
<span class="mode-badge play">▶ {t('sessionStart')}</span>
{:else}
<span class="mode-badge" class:work={entry.mode === 'work'}>
{getModeLabel(entry.mode)}
</span>
{/if}
<span class="task-title">
{entry.taskTitle || t('semTarefa')}
</span>
</div>
<div class="history-meta">
{#if entry.type !== 'play'}
<span>{Math.round((entry.duration || 0) / 60)} {t('min')}</span>
<span class="dot">•</span>
{/if}
<span>{formatDate(entry.completedAt)} {formatTime(entry.completedAt)}</span>
</div>
</li>
{/each}
</ul>
{/if}
</div>
<style>
.history-panel {
display: flex;
flex-direction: column;
gap: 1rem;
padding: 2rem;
min-width: 320px;
background: var(--surface);
border-radius: 8px;
}
.history-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.history-heading {
font-size: 1.1rem;
font-weight: 700;
color: var(--text);
margin: 0;
}
.btn-clear {
background: transparent;
border: none;
color: var(--text-muted);
font-size: 0.8rem;
cursor: pointer;
}
.btn-clear:hover {
color: var(--accent);
}
.empty {
color: var(--text-muted);
font-size: 0.875rem;
text-align: center;
margin: 2rem 0;
}
.history-list {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: 0.5rem;
max-height: 300px;
overflow-y: auto;
}
.history-item {
display: flex;
flex-direction: column;
gap: 4px;
padding: 0.75rem;
background: var(--bg);
border-radius: 6px;
border-left: 3px solid var(--border);
}
.history-item.play-event {
border-left-color: #3b82f6; /* Blueish to differentiate */
background: transparent;
}
.history-main {
display: flex;
align-items: center;
gap: 8px;
}
.mode-badge {
font-size: 0.7rem;
padding: 2px 6px;
border-radius: 4px;
background: var(--surface-hover);
color: var(--text-muted);
font-weight: 600;
}
.mode-badge.work {
background: var(--accent);
color: #fff;
}
.mode-badge.play {
background: transparent;
color: #3b82f6;
border: 1px solid #3b82f6;
}
.task-title {
font-size: 0.9rem;
color: var(--text);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.history-meta {
display: flex;
align-items: center;
gap: 6px;
font-size: 0.75rem;
color: var(--text-muted);
}
.dot {
font-size: 0.5rem;
}
</style>
|