feat(shared-ui): add QuickInputBar and PillToolbar components

- Add QuickInputBar component with natural language parsing, syntax
  highlighting, search, and quick-create functionality
- Add PillToolbar, PillToolbarButton, PillToolbarDivider components
  for app-specific toolbar controls
- Add PillTimeRangeSelector for hour range selection
- Add PillViewSwitcher for view mode switching with sliding indicator
- Integrate QuickInputBar into Calendar, Contacts, and Todo apps
- Add app-specific toolbars: CalendarToolbar, ContactsToolbar, TodoToolbar
- Add DateStrip component for Calendar date navigation
- Fix type exports: export QuickAction and CreatePreview from quick-input
  module, remove duplicate exports from deprecated command-bar

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Till-JS 2025-12-12 02:17:17 +01:00
parent c6f8b9f87c
commit 0f10a38cc0
17 changed files with 3697 additions and 121 deletions

View file

@ -0,0 +1,471 @@
<script lang="ts">
interface Props {
/** Start hour (0-23) */
startHour: number;
/** End hour (1-24) */
endHour: number;
/** Called when start hour changes */
onStartHourChange: (hour: number) => void;
/** Called when end hour changes */
onEndHourChange: (hour: number) => void;
/** Dropdown direction */
direction?: 'up' | 'down';
/** Label format - 'range' shows "8-18h", 'icon' shows clock icon only */
labelFormat?: 'range' | 'icon';
/** Embedded mode - no background/border, for use inside a parent bar */
embedded?: boolean;
}
let {
startHour,
endHour,
onStartHourChange,
onEndHourChange,
direction = 'down',
labelFormat = 'range',
embedded = false,
}: Props = $props();
let isOpen = $state(false);
let triggerButton: HTMLButtonElement;
let dropdownPosition = $state({ top: 0, left: 0 });
function toggle() {
if (triggerButton) {
const rect = triggerButton.getBoundingClientRect();
if (direction === 'down') {
dropdownPosition = {
top: rect.bottom + 8,
left: rect.left,
};
} else {
dropdownPosition = {
top: rect.top - 8,
left: rect.left,
};
}
}
isOpen = !isOpen;
}
function close() {
isOpen = false;
}
function handleStartChange(hour: number) {
if (hour < endHour) {
onStartHourChange(hour);
}
}
function handleEndChange(hour: number) {
if (hour > startHour) {
onEndHourChange(hour);
}
}
function formatHour(hour: number): string {
return `${hour.toString().padStart(2, '0')}:00`;
}
let label = $derived(labelFormat === 'range' ? `${startHour}-${endHour}h` : '');
// Generate hour options
const startHours = Array.from({ length: 24 }, (_, i) => i);
const endHours = Array.from({ length: 24 }, (_, i) => i + 1);
</script>
<div class="pill-time-selector">
<button
bind:this={triggerButton}
onclick={toggle}
class="trigger-button"
class:pill={!embedded}
class:glass-pill={!embedded}
class:embedded-btn={embedded}
title="Zeitbereich auswählen"
>
<svg class="pill-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
/>
</svg>
{#if label}
<span class="pill-label">{label}</span>
{/if}
<svg
class="chevron-icon"
class:rotated={isOpen}
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</button>
{#if isOpen}
<button
class="backdrop"
onclick={close}
onkeydown={(e) => e.key === 'Escape' && close()}
aria-label="Close"
></button>
<div
class="dropdown glass-dropdown"
class:dropdown-up={direction === 'up'}
style="top: {dropdownPosition.top}px; left: {dropdownPosition.left}px;"
>
<div class="dropdown-header">Zeitbereich</div>
<div class="time-selectors">
<div class="time-column">
<label class="column-label">Von</label>
<div class="hour-list">
{#each startHours as hour}
<button
class="hour-option"
class:active={startHour === hour}
class:disabled={hour >= endHour}
onclick={() => handleStartChange(hour)}
disabled={hour >= endHour}
>
{formatHour(hour)}
</button>
{/each}
</div>
</div>
<div class="time-divider"></div>
<div class="time-column">
<label class="column-label">Bis</label>
<div class="hour-list">
{#each endHours as hour}
<button
class="hour-option"
class:active={endHour === hour}
class:disabled={hour <= startHour}
onclick={() => handleEndChange(hour)}
disabled={hour <= startHour}
>
{formatHour(hour)}
</button>
{/each}
</div>
</div>
</div>
<div class="dropdown-footer">
<span class="current-range">{formatHour(startHour)} - {formatHour(endHour)}</span>
</div>
</div>
{/if}
</div>
<style>
.pill-time-selector {
position: relative;
}
.trigger-button {
position: relative;
z-index: 10;
}
.pill {
display: flex;
align-items: center;
gap: 0.375rem;
padding: 0.5rem 0.75rem;
border-radius: 9999px;
font-size: 0.875rem;
font-weight: 500;
white-space: nowrap;
border: none;
cursor: pointer;
transition: all 0.2s;
}
.glass-pill {
background: rgba(255, 255, 255, 0.85);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(0, 0, 0, 0.1);
box-shadow:
0 4px 6px -1px rgba(0, 0, 0, 0.1),
0 2px 4px -1px rgba(0, 0, 0, 0.06);
color: #374151;
}
:global(.dark) .glass-pill {
background: rgba(255, 255, 255, 0.12);
border: 1px solid rgba(255, 255, 255, 0.15);
color: #f3f4f6;
}
.glass-pill:hover {
background: rgba(255, 255, 255, 0.95);
border-color: rgba(0, 0, 0, 0.15);
transform: translateY(-1px);
box-shadow:
0 10px 15px -3px rgba(0, 0, 0, 0.1),
0 4px 6px -2px rgba(0, 0, 0, 0.05);
}
:global(.dark) .glass-pill:hover {
background: rgba(255, 255, 255, 0.2);
border-color: rgba(255, 255, 255, 0.25);
}
.pill-icon {
width: 1rem;
height: 1rem;
flex-shrink: 0;
}
.pill-label {
font-size: 0.8125rem;
}
/* Embedded mode - no background/border */
.embedded-btn {
display: flex;
align-items: center;
gap: 0.375rem;
padding: 0.5rem 0.75rem;
border-radius: 9999px;
font-size: 0.875rem;
font-weight: 500;
white-space: nowrap;
border: none;
cursor: pointer;
transition: all 0.15s ease;
background: transparent;
color: #374151;
}
:global(.dark) .embedded-btn {
color: #f3f4f6;
}
.embedded-btn:hover {
background: rgba(0, 0, 0, 0.05);
}
:global(.dark) .embedded-btn:hover {
background: rgba(255, 255, 255, 0.1);
}
.chevron-icon {
width: 0.75rem;
height: 0.75rem;
transition: transform 0.2s;
margin-left: 0.125rem;
}
.chevron-icon.rotated {
transform: rotate(180deg);
}
.backdrop {
position: fixed;
inset: 0;
z-index: 9998;
background: transparent;
border: none;
cursor: default;
}
.dropdown {
position: fixed;
z-index: 9999;
min-width: 280px;
border-radius: 1rem;
overflow: hidden;
animation: dropdownIn 0.15s ease-out;
}
.dropdown-up {
transform: translateY(-100%);
}
@keyframes dropdownIn {
from {
opacity: 0;
transform: translateY(10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.dropdown-up {
animation-name: dropdownInUp;
}
@keyframes dropdownInUp {
from {
opacity: 0;
transform: translateY(-100%) translateY(-10px);
}
to {
opacity: 1;
transform: translateY(-100%);
}
}
.glass-dropdown {
background: rgba(255, 255, 255, 0.95);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid rgba(0, 0, 0, 0.1);
box-shadow:
0 20px 25px -5px rgba(0, 0, 0, 0.1),
0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
:global(.dark) .glass-dropdown {
background: rgba(30, 30, 30, 0.95);
border: 1px solid rgba(255, 255, 255, 0.15);
}
.dropdown-header {
padding: 0.75rem 1rem;
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
color: #6b7280;
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
:global(.dark) .dropdown-header {
color: #9ca3af;
border-bottom-color: rgba(255, 255, 255, 0.1);
}
.time-selectors {
display: flex;
padding: 0.5rem;
gap: 0.5rem;
}
.time-column {
flex: 1;
display: flex;
flex-direction: column;
gap: 0.375rem;
}
.column-label {
font-size: 0.6875rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.05em;
color: #6b7280;
padding: 0 0.5rem;
}
:global(.dark) .column-label {
color: #9ca3af;
}
.hour-list {
display: flex;
flex-direction: column;
gap: 0.125rem;
max-height: 200px;
overflow-y: auto;
scrollbar-width: thin;
scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}
.hour-list::-webkit-scrollbar {
width: 4px;
}
.hour-list::-webkit-scrollbar-track {
background: transparent;
}
.hour-list::-webkit-scrollbar-thumb {
background: rgba(0, 0, 0, 0.2);
border-radius: 2px;
}
:global(.dark) .hour-list::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.2);
}
.hour-option {
padding: 0.375rem 0.75rem;
border: none;
background: transparent;
border-radius: 0.5rem;
font-size: 0.8125rem;
font-weight: 500;
color: #374151;
cursor: pointer;
transition: all 0.15s;
text-align: left;
}
:global(.dark) .hour-option {
color: #e5e7eb;
}
.hour-option:hover:not(.disabled) {
background: rgba(0, 0, 0, 0.05);
}
:global(.dark) .hour-option:hover:not(.disabled) {
background: rgba(255, 255, 255, 0.1);
}
.hour-option.active {
background: color-mix(in srgb, var(--color-primary-500, #3b82f6) 20%, white 80%);
color: var(--color-primary-500, #3b82f6);
}
:global(.dark) .hour-option.active {
background: color-mix(in srgb, var(--color-primary-500, #3b82f6) 30%, transparent 70%);
color: var(--color-primary-500, #3b82f6);
}
.hour-option.disabled {
opacity: 0.35;
cursor: not-allowed;
}
.time-divider {
width: 1px;
background: rgba(0, 0, 0, 0.1);
margin: 0.5rem 0;
}
:global(.dark) .time-divider {
background: rgba(255, 255, 255, 0.1);
}
.dropdown-footer {
padding: 0.5rem 1rem;
border-top: 1px solid rgba(0, 0, 0, 0.1);
text-align: center;
}
:global(.dark) .dropdown-footer {
border-top-color: rgba(255, 255, 255, 0.1);
}
.current-range {
font-size: 0.8125rem;
font-weight: 600;
color: var(--color-primary-500, #3b82f6);
}
</style>

View file

@ -0,0 +1,94 @@
<script lang="ts">
import type { Snippet } from 'svelte';
interface Props {
/** Position of toolbar: 'top' or 'bottom' (default: 'top') */
position?: 'top' | 'bottom';
/** Top offset on desktop when position='top' (default: '70px' - below PillNav) */
topOffset?: string;
/** Bottom offset on desktop when position='bottom' (default: '70px' - above PillNav) */
bottomOffset?: string;
/** Bottom offset on mobile (default: '70px' - above PillNav) */
mobileBottomOffset?: string;
/** Content to render inside the toolbar */
children: Snippet;
}
let {
position = 'top',
topOffset = '70px',
bottomOffset = '70px',
mobileBottomOffset = '70px',
children,
}: Props = $props();
</script>
<div
class="pill-toolbar"
class:position-bottom={position === 'bottom'}
style="--toolbar-top-offset: {topOffset}; --toolbar-bottom-offset: {bottomOffset}; --toolbar-mobile-bottom-offset: {mobileBottomOffset};"
>
<div class="toolbar-bar glass-pill">
{@render children()}
</div>
</div>
<style>
.pill-toolbar {
position: fixed;
top: var(--toolbar-top-offset, 70px);
left: 0;
right: 0;
z-index: 999;
padding: 0.375rem 1rem;
pointer-events: none;
display: flex;
justify-content: center;
}
/* Bottom position */
.pill-toolbar.position-bottom {
top: auto;
bottom: var(--toolbar-bottom-offset, 70px);
}
/* Mobile: always position above bottom nav */
@media (max-width: 768px) {
.pill-toolbar {
top: auto;
bottom: calc(var(--toolbar-mobile-bottom-offset, 70px) + env(safe-area-inset-bottom, 0px));
}
}
/* Single unified bar */
.toolbar-bar {
display: flex;
align-items: center;
gap: 0.25rem;
padding: 0.25rem;
pointer-events: auto;
max-width: 100%;
overflow-x: auto;
scrollbar-width: none;
}
.toolbar-bar::-webkit-scrollbar {
display: none;
}
.glass-pill {
background: rgba(255, 255, 255, 0.85);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(0, 0, 0, 0.1);
box-shadow:
0 4px 6px -1px rgba(0, 0, 0, 0.1),
0 2px 4px -1px rgba(0, 0, 0, 0.06);
border-radius: 9999px;
}
:global(.dark) .glass-pill {
background: rgba(255, 255, 255, 0.12);
border: 1px solid rgba(255, 255, 255, 0.15);
}
</style>

View file

@ -0,0 +1,91 @@
<script lang="ts">
import type { Snippet } from 'svelte';
interface Props {
/** Click handler */
onclick: () => void;
/** Whether the button is in active state */
active?: boolean;
/** Tooltip title */
title?: string;
/** Whether to render as icon-only (smaller padding) */
iconOnly?: boolean;
/** Disabled state */
disabled?: boolean;
/** Button content (icon and/or text) */
children: Snippet;
}
let {
onclick,
active = false,
title,
iconOnly = false,
disabled = false,
children,
}: Props = $props();
</script>
<button
type="button"
class="toolbar-btn"
class:active
class:icon-only={iconOnly}
{title}
{disabled}
{onclick}
>
{@render children()}
</button>
<style>
.toolbar-btn {
display: flex;
align-items: center;
justify-content: center;
gap: 0.375rem;
padding: 0.5rem 0.75rem;
background: transparent;
border: none;
border-radius: 9999px;
cursor: pointer;
color: #374151;
font-size: 0.875rem;
font-weight: 500;
white-space: nowrap;
transition: all 0.15s ease;
}
:global(.dark) .toolbar-btn {
color: #f3f4f6;
}
.toolbar-btn:hover:not(:disabled) {
background: rgba(0, 0, 0, 0.05);
}
:global(.dark) .toolbar-btn:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.1);
}
.toolbar-btn.active {
background: color-mix(in srgb, #3b82f6 15%, transparent 85%);
color: #3b82f6;
}
.toolbar-btn.icon-only {
padding: 0.5rem;
}
.toolbar-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* Icon styling */
.toolbar-btn :global(svg) {
width: 1rem;
height: 1rem;
flex-shrink: 0;
}
</style>

View file

@ -0,0 +1,18 @@
<script lang="ts">
// No props needed - simple divider component
</script>
<div class="toolbar-divider"></div>
<style>
.toolbar-divider {
width: 1px;
height: 1.25rem;
background: rgba(0, 0, 0, 0.1);
flex-shrink: 0;
}
:global(.dark) .toolbar-divider {
background: rgba(255, 255, 255, 0.15);
}
</style>

View file

@ -0,0 +1,223 @@
<script lang="ts">
import { tick } from 'svelte';
export interface ViewOption {
/** Unique identifier */
id: string;
/** Display label */
label: string;
/** Optional icon name */
icon?: string;
/** Optional tooltip */
title?: string;
/** Whether this option is disabled */
disabled?: boolean;
}
interface Props {
/** Available view options */
options: ViewOption[];
/** Currently selected view id */
value: string;
/** Called when view changes */
onChange: (id: string) => void;
/** Primary color for active state */
primaryColor?: string;
/** Embedded mode - no background/border, for use inside a parent bar */
embedded?: boolean;
}
let { options, value, onChange, primaryColor = '#3b82f6', embedded = false }: Props = $props();
let containerRef = $state<HTMLDivElement | null>(null);
let indicatorStyle = $state('');
// Update indicator position when value changes
$effect(() => {
if (containerRef && value) {
tick().then(updateIndicator);
}
});
function updateIndicator() {
if (!containerRef) return;
const activeButton = containerRef.querySelector(`[data-id="${value}"]`) as HTMLButtonElement;
if (activeButton) {
const containerRect = containerRef.getBoundingClientRect();
const buttonRect = activeButton.getBoundingClientRect();
const left = buttonRect.left - containerRect.left;
const width = buttonRect.width;
indicatorStyle = `left: ${left}px; width: ${width}px;`;
}
}
function handleClick(optionId: string, disabled?: boolean) {
if (!disabled) {
onChange(optionId);
}
}
// Icon SVG paths
const icons: Record<string, string> = {
day: 'M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z',
week: 'M4 6h16M4 10h16M4 14h16M4 18h16',
month:
'M4 5a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM14 5a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1V5zM4 15a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1H5a1 1 0 01-1-1v-4zM14 15a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z',
year: 'M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2',
agenda:
'M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01',
list: 'M4 6h16M4 10h16M4 14h16M4 18h16',
grid: 'M4 5a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM14 5a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1V5zM4 15a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1H5a1 1 0 01-1-1v-4zM14 15a1 1 0 011-1h4a1 1 0 011 1v4a1 1 0 01-1 1h-4a1 1 0 01-1-1v-4z',
calendar:
'M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z',
};
function getIconPath(name: string): string {
return icons[name] || '';
}
</script>
<div
class="pill-view-switcher"
class:glass-pill={!embedded}
class:embedded-switcher={embedded}
style="--switcher-primary-color: {primaryColor}"
bind:this={containerRef}
>
<!-- Sliding indicator -->
<div class="sliding-indicator" style={indicatorStyle}></div>
<!-- Options -->
{#each options as option}
<button
data-id={option.id}
onclick={() => handleClick(option.id, option.disabled)}
class="switcher-btn"
class:active={value === option.id}
class:disabled={option.disabled}
title={option.title || option.label}
disabled={option.disabled}
>
{#if option.icon && getIconPath(option.icon)}
<svg class="switcher-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d={getIconPath(option.icon)}
/>
</svg>
{/if}
<span class="switcher-label">{option.label}</span>
</button>
{/each}
</div>
<style>
.pill-view-switcher {
position: relative;
display: inline-flex;
align-items: center;
padding: 0.1875rem;
border-radius: 9999px;
gap: 0.125rem;
}
.glass-pill {
background: rgba(255, 255, 255, 0.85);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(0, 0, 0, 0.1);
box-shadow:
0 4px 6px -1px rgba(0, 0, 0, 0.1),
0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
:global(.dark) .glass-pill {
background: rgba(255, 255, 255, 0.12);
border: 1px solid rgba(255, 255, 255, 0.15);
}
/* Embedded mode - no background/border */
.embedded-switcher {
background: transparent;
border: none;
box-shadow: none;
padding: 0;
gap: 0;
}
/* Sliding indicator */
.sliding-indicator {
position: absolute;
top: 0;
bottom: 0;
border-radius: 9999px;
background: color-mix(in srgb, var(--switcher-primary-color) 15%, white 85%);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
z-index: 0;
}
:global(.dark) .sliding-indicator {
background: color-mix(in srgb, var(--switcher-primary-color) 25%, transparent 75%);
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.switcher-btn {
position: relative;
z-index: 1;
display: flex;
align-items: center;
justify-content: center;
gap: 0.25rem;
padding: 0.5rem 0.875rem;
background: transparent;
border: none;
border-radius: 9999px;
cursor: pointer;
color: #6b7280;
font-size: 0.875rem;
font-weight: 500;
white-space: nowrap;
transition: color 0.15s ease;
}
:global(.dark) .switcher-btn {
color: #9ca3af;
}
.switcher-btn:hover:not(.disabled) {
color: #374151;
}
:global(.dark) .switcher-btn:hover:not(.disabled) {
color: #e5e7eb;
}
.switcher-btn.active {
color: var(--switcher-primary-color);
}
:global(.dark) .switcher-btn.active {
color: var(--switcher-primary-color);
}
.switcher-btn.disabled {
opacity: 0.4;
cursor: not-allowed;
}
.switcher-icon {
width: 1rem;
height: 1rem;
flex-shrink: 0;
}
.switcher-label {
line-height: 1;
}
</style>

View file

@ -5,6 +5,11 @@ export { default as SidebarSection } from './SidebarSection.svelte';
export { default as PillNavigation } from './PillNavigation.svelte';
export { default as PillDropdown } from './PillDropdown.svelte';
export { default as PillTabGroup } from './PillTabGroup.svelte';
export { default as PillTimeRangeSelector } from './PillTimeRangeSelector.svelte';
export { default as PillViewSwitcher } from './PillViewSwitcher.svelte';
export { default as PillToolbar } from './PillToolbar.svelte';
export { default as PillToolbarButton } from './PillToolbarButton.svelte';
export { default as PillToolbarDivider } from './PillToolbarDivider.svelte';
export type {
NavItem,
NavbarProps,