Improve: stable highlight height, equation display format, responsive font sizes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
60
src/app.css
60
src/app.css
@@ -79,38 +79,52 @@
|
|||||||
|
|
||||||
/* ── Highlighted result (above grid) ──────────────────────────────────────── */
|
/* ── Highlighted result (above grid) ──────────────────────────────────────── */
|
||||||
.highlighted-result {
|
.highlighted-result {
|
||||||
text-align: center;
|
/* Fixed height that never changes whether populated or empty */
|
||||||
padding: 2rem 1rem;
|
height: 10rem;
|
||||||
margin-bottom: 1.5rem;
|
margin-bottom: 1.5rem;
|
||||||
border-radius: var(--pico-border-radius, 0.25rem);
|
border-radius: var(--pico-border-radius, 0.25rem);
|
||||||
background-color: var(--pico-card-background-color);
|
background-color: var(--pico-card-background-color);
|
||||||
border: 2px solid var(--pico-primary);
|
border: 2px solid transparent; /* always present, color changes */
|
||||||
box-shadow: var(--shadow-medium);
|
box-shadow: var(--shadow-medium);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.4rem;
|
justify-content: center;
|
||||||
|
gap: 0.3rem;
|
||||||
position: relative;
|
position: relative;
|
||||||
min-height: 8rem;
|
overflow: hidden;
|
||||||
|
transition: border-color 0.2s ease;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlighted-value {
|
.highlighted-result.has-highlight {
|
||||||
font-size: 2.5rem;
|
border-color: var(--pico-primary);
|
||||||
font-weight: 700;
|
}
|
||||||
|
|
||||||
|
.highlighted-equation-from {
|
||||||
|
font-size: clamp(0.85rem, 2vw, 1.1rem);
|
||||||
|
color: var(--color-text-muted, #888880);
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
line-height: 1.1;
|
|
||||||
word-break: break-all;
|
|
||||||
color: var(--pico-color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlighted-label {
|
.highlighted-equation-equals {
|
||||||
font-size: 1.25rem;
|
font-size: clamp(1.2rem, 3.5vw, 2rem);
|
||||||
color: var(--pico-color);
|
font-weight: 700;
|
||||||
|
color: var(--pico-primary);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
word-break: break-all;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlighted-symbol {
|
.highlighted-symbol {
|
||||||
|
font-size: clamp(0.75rem, 1.5vw, 0.9rem);
|
||||||
|
color: var(--pico-muted-color, #888880);
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlighted-placeholder {
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
color: var(--pico-muted-color, #666);
|
color: var(--pico-muted-color, #888880);
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,22 +156,18 @@
|
|||||||
/* ── Highlight dismiss button ──────────────────────────────────────────────── */
|
/* ── Highlight dismiss button ──────────────────────────────────────────────── */
|
||||||
.highlight-dismiss {
|
.highlight-dismiss {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0.5rem;
|
top: 0.4rem;
|
||||||
right: 0.75rem;
|
right: 0.6rem;
|
||||||
background: none;
|
background: none;
|
||||||
border: none;
|
border: none;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
color: var(--pico-muted-color, #888880);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
font-size: 1rem;
|
padding: 0.2rem 0.4rem;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
color: var(--pico-muted-color, #888);
|
|
||||||
padding: 0.15rem 0.3rem;
|
|
||||||
border-radius: 0.2rem;
|
|
||||||
transition: color 0.15s ease, background-color 0.15s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.highlight-dismiss:hover {
|
.highlight-dismiss:hover {
|
||||||
color: var(--pico-color);
|
color: var(--pico-color, #2C2C2C);
|
||||||
background-color: rgba(0, 0, 0, 0.06);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Hotkey hint ───────────────────────────────────────────────────────────── */
|
/* ── Hotkey hint ───────────────────────────────────────────────────────────── */
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import { convertById } from '$lib/convert';
|
import { convertById } from '$lib/convert';
|
||||||
import { FRACTIONAL_DIGITS } from '$lib/config';
|
import { FRACTIONAL_DIGITS } from '$lib/config';
|
||||||
import { formatBig } from '$lib/format';
|
import { formatBig } from '$lib/format';
|
||||||
import type { Big } from 'big.js';
|
import Big from 'big.js';
|
||||||
import type { Unit, ResultItem } from '$lib/types';
|
import type { Unit, ResultItem } from '$lib/types';
|
||||||
import ConverterCard from '../components/ConverterCard.svelte';
|
import ConverterCard from '../components/ConverterCard.svelte';
|
||||||
|
|
||||||
@@ -60,6 +60,8 @@
|
|||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let fromUnit = $derived(units.find(u => u.id === fromUnitId) ?? units[0]);
|
||||||
|
|
||||||
// ── URL sync: update URL only when serialized params actually change ────────
|
// ── URL sync: update URL only when serialized params actually change ────────
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (!browser) return;
|
if (!browser) return;
|
||||||
@@ -107,16 +109,14 @@
|
|||||||
<title>Humor Units — Converter</title>
|
<title>Humor Units — Converter</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class="highlighted-result" aria-live="polite">
|
<div class="highlighted-result" class:has-highlight={highlightedResult !== null} aria-live="polite">
|
||||||
{#if highlightedResult !== null}
|
{#if highlightedResult !== null}
|
||||||
<button
|
<button class="highlight-dismiss" onclick={() => (highlightedUnitId = null)} aria-label="Remove highlight">×</button>
|
||||||
class="highlight-dismiss"
|
<span class="highlighted-equation-from">{formatBig(new Big(inputValue))} {fromUnit.labelPlural}</span>
|
||||||
aria-label="Remove highlight"
|
<span class="highlighted-equation-equals">= {formatBig(highlightedResult.convertedValue)} {highlightedResult.unit.labelPlural}</span>
|
||||||
onclick={() => (highlightedUnitId = null)}
|
|
||||||
>×</button>
|
|
||||||
<span class="highlighted-value">{formatBig(highlightedResult.convertedValue)}</span>
|
|
||||||
<span class="highlighted-label">{highlightedResult.unit.labelPlural}</span>
|
|
||||||
<span class="highlighted-symbol">{highlightedResult.unit.symbol}</span>
|
<span class="highlighted-symbol">{highlightedResult.unit.symbol}</span>
|
||||||
|
{:else}
|
||||||
|
<span class="highlighted-placeholder">Click a result to highlight it</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user