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