feat(web): add Header and ReportPicker components
Header shows active report name (left) with dropdown chevron and gear icon linking to /settings (right). ReportPicker uses native Popover API with 11 reports grouped into Common, Time-based, Recurring, and Archive. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,125 @@
|
|||||||
|
<script>
|
||||||
|
import ReportPicker from './ReportPicker.svelte';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export let activeReport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {(reportName: string) => void}
|
||||||
|
*/
|
||||||
|
export let onReportChange;
|
||||||
|
|
||||||
|
/** @type {HTMLButtonElement|null} */
|
||||||
|
let anchorEl = null;
|
||||||
|
|
||||||
|
/** @type {ReportPicker} */
|
||||||
|
let picker;
|
||||||
|
|
||||||
|
/** Map backend report names to display labels */
|
||||||
|
const reportLabels = /** @type {Record<string, string>} */ ({
|
||||||
|
list: 'Pending',
|
||||||
|
next: 'Next',
|
||||||
|
active: 'Active',
|
||||||
|
ready: 'Ready',
|
||||||
|
overdue: 'Overdue',
|
||||||
|
waiting: 'Waiting',
|
||||||
|
newest: 'Newest',
|
||||||
|
oldest: 'Oldest',
|
||||||
|
recurring: 'Recurring',
|
||||||
|
template: 'Template',
|
||||||
|
completed: 'Completed'
|
||||||
|
});
|
||||||
|
|
||||||
|
$: displayLabel = reportLabels[activeReport] || activeReport;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<header class="header">
|
||||||
|
<button
|
||||||
|
class="report-btn"
|
||||||
|
bind:this={anchorEl}
|
||||||
|
on:click={() => picker.toggle()}
|
||||||
|
>
|
||||||
|
<span class="report-label">{displayLabel}</span>
|
||||||
|
<svg class="chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<a href="/settings" class="settings-btn" aria-label="Settings">
|
||||||
|
<svg class="icon" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<ReportPicker
|
||||||
|
bind:this={picker}
|
||||||
|
{activeReport}
|
||||||
|
onSelect={onReportChange}
|
||||||
|
anchorEl={anchorEl}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: var(--spacing-sm) var(--spacing-md);
|
||||||
|
background-color: var(--bg-primary);
|
||||||
|
border-bottom: 1px solid var(--border-color);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-btn {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-xs);
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
padding: var(--spacing-xs) var(--spacing-sm);
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
cursor: pointer;
|
||||||
|
font-family: inherit;
|
||||||
|
min-width: unset;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-btn:hover {
|
||||||
|
background-color: var(--bg-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-label {
|
||||||
|
font-size: var(--font-size-lg);
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chevron {
|
||||||
|
width: 1rem;
|
||||||
|
height: 1rem;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 44px;
|
||||||
|
height: 44px;
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
color: var(--text-secondary);
|
||||||
|
transition: background-color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-btn:hover {
|
||||||
|
background-color: var(--bg-secondary);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon {
|
||||||
|
width: 1.25rem;
|
||||||
|
height: 1.25rem;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export let activeReport;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {(reportName: string) => void}
|
||||||
|
*/
|
||||||
|
export let onSelect;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {HTMLElement}
|
||||||
|
*/
|
||||||
|
export let anchorEl;
|
||||||
|
|
||||||
|
/** @type {HTMLElement|null} */
|
||||||
|
let popoverEl = null;
|
||||||
|
|
||||||
|
const groups = [
|
||||||
|
{
|
||||||
|
label: 'Common',
|
||||||
|
reports: [
|
||||||
|
{ label: 'Pending', value: 'list' },
|
||||||
|
{ label: 'Next', value: 'next' },
|
||||||
|
{ label: 'Active', value: 'active' },
|
||||||
|
{ label: 'Ready', value: 'ready' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Time-based',
|
||||||
|
reports: [
|
||||||
|
{ label: 'Overdue', value: 'overdue' },
|
||||||
|
{ label: 'Waiting', value: 'waiting' },
|
||||||
|
{ label: 'Newest', value: 'newest' },
|
||||||
|
{ label: 'Oldest', value: 'oldest' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Recurring',
|
||||||
|
reports: [
|
||||||
|
{ label: 'Recurring', value: 'recurring' },
|
||||||
|
{ label: 'Template', value: 'template' }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Archive',
|
||||||
|
reports: [
|
||||||
|
{ label: 'Completed', value: 'completed' }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
export function toggle() {
|
||||||
|
if (popoverEl) {
|
||||||
|
popoverEl.togglePopover();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} value
|
||||||
|
*/
|
||||||
|
function select(value) {
|
||||||
|
onSelect(value);
|
||||||
|
if (popoverEl) {
|
||||||
|
popoverEl.hidePopover();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="report-picker" popover bind:this={popoverEl}>
|
||||||
|
{#each groups as group}
|
||||||
|
<div class="group">
|
||||||
|
<div class="group-label">{group.label}</div>
|
||||||
|
{#each group.reports as report}
|
||||||
|
<button
|
||||||
|
class="report-option"
|
||||||
|
class:active={activeReport === report.value}
|
||||||
|
on:click={() => select(report.value)}
|
||||||
|
>
|
||||||
|
{report.label}
|
||||||
|
</button>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.report-picker {
|
||||||
|
position: fixed;
|
||||||
|
top: 48px;
|
||||||
|
left: var(--spacing-md);
|
||||||
|
right: auto;
|
||||||
|
margin: 0;
|
||||||
|
padding: var(--spacing-sm);
|
||||||
|
background-color: var(--bg-primary);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
box-shadow: var(--shadow-lg);
|
||||||
|
min-width: 180px;
|
||||||
|
max-width: 240px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group {
|
||||||
|
padding: var(--spacing-xs) 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.group + .group {
|
||||||
|
border-top: 1px solid var(--border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.group-label {
|
||||||
|
font-size: var(--font-size-xs);
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-tertiary);
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
padding: var(--spacing-xs) var(--spacing-sm);
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-option {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
padding: var(--spacing-sm) var(--spacing-sm);
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0.25rem;
|
||||||
|
font-size: var(--font-size-sm);
|
||||||
|
font-family: inherit;
|
||||||
|
color: var(--text-primary);
|
||||||
|
text-align: left;
|
||||||
|
cursor: pointer;
|
||||||
|
min-height: 36px;
|
||||||
|
min-width: unset;
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-option:hover {
|
||||||
|
background-color: var(--bg-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.report-option.active {
|
||||||
|
background-color: var(--color-primary);
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
Reference in New Issue
Block a user