Files
llama.cpp/ui/apps/chat/tests/stories/introduction/Principles.svelte
T
Aleksander Grygier b81aa847c2 ui: slim the design tokens and set all text through type roles (#32615)
* ui: drop component tokens that only alias a semantic token

A component token now exists only for what a component decides itself:
a value no semantic token has, or one that only this component changes
between themes. Components that take a semantic token as it is read it
directly, so 88 of the 118 component tokens go, with no change to what
is drawn.

Also drops semantic tokens that repeat another one (status-* is fill-*,
elevation-tooltip is elevation-surface), the unused info lamp tokens and
14 primitives nothing reads, and adds fg-soft for the label of an option
that is not the picked one (tabs, toggle group).

Assisted-by: Claude (Opus 5.5 Medium)

* ui: add a short summary on top of DESIGN.md

The rules most changes need, in one screen: components, colour, type,
shape, sizes, surfaces, tokens and no arbitrary values. The sections
below keep the detail.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: derive design tokens by rule and drop the alias layers

Semantic tokens are either a pick (a primitive per theme) or a derivation,
mixed from another semantic token by a fixed rule and declared once: hover
fills, status surfaces and lines, dark shadows (--elevation-strength), the
middle of a matte edge, a lamp's rim and glyph.

Primitives keep colours only. shadcn's colour names stay as Tailwind
utilities and no longer exist as variables; neutral semantic utilities that
duplicated them are gone.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: set all text through type roles and move off-scale values onto the scale

Tailwind's text sizes and bracketed sizes become the type roles, with a new
text-caption-sm (10px) for tags and counts. Body and caption roles no longer
set a weight, and line heights are written as Tailwind writes its own, so the
swap from text-sm and text-xs changes no pixel. A unit test keeps old sizes
from coming back.

Arbitrary values with a scale equivalent use it (z-20, max-w-4/5, min-w-32),
and the two easing curves repeated across the app are ease-out-quint and
ease-sheet. DESIGN.md is updated and regenerated.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: bump @ggml-org/llama-ui to 0.5.0

Removed and renamed tokens are breaking for an app that reads them.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: add a display type role for the biggest headline

The greeting on a new chat keeps its 30px from md up, now as text-display
instead of a Tailwind size.

Assisted-by: Claude (Opus 5.5 Medium)

* ui: one corner scale, one set of shadows and three more derived tokens

Six corner roles named values Tailwind's rounded-md to rounded-4xl
already have, and components used the Tailwind names nine times out of
ten. The roles are gone; the whole scale is computed from --radius.

Tailwind's shadow sizes were restated next to the elevation tokens and
did not follow the theme, so they were five times fainter in dark. The
five uses take elevation tokens and a unit test keeps both from coming
back.

A button group's seam is the button's own text colour at 25%, the dark
status text is the dark status fill, and the pressed shadow scales with
--elevation-strength like the inset one.

Assisted-by: Claude (Opus 5.5 Medium)
2026-11-20 11:26:26 +01:00

229 lines
4.4 KiB
Svelte

<!--
How we think, as five tiles, each with a small picture of the idea made from the real system: the devices a model
runs on, the first run's recommendation, the three places the character lives, a control on its grid, and one
decision through the three token tiers.
-->
<script lang="ts">
import { PATHS, SIZE } from '../brand/logo-showcase/lib/logo';
import { Badge } from '@ggml-org/llama-ui/ui/badge';
import { Button } from '@ggml-org/llama-ui/ui/button';
import { Laptop, Lock, Monitor, Smartphone, UserX, WifiOff } from '@lucide/svelte';
</script>
<div class="principles">
<section class="principle wide card-surface rounded-xl">
<div class="picture">
<div class="devices">
<Smartphone aria-hidden="true" size={28} />
<Laptop aria-hidden="true" size={36} />
<Monitor aria-hidden="true" size={36} />
</div>
<div class="chips">
<Badge variant="outline"><WifiOff aria-hidden="true" />Offline</Badge>
<Badge variant="outline"><UserX aria-hidden="true" />No account</Badge>
<Badge variant="outline"><Lock aria-hidden="true" />Stays on the device</Badge>
</div>
</div>
<h3>Personal, on hardware you already have</h3>
<p>Private by default, and open to everyone.</p>
</section>
<section class="principle card-surface rounded-xl">
<div class="picture">
<div class="pick rounded-lg bg-(--surface-lifted) elevated-control">
<Badge>Recommended</Badge>
<span class="pick-note">Reads, sees and hears</span>
<Button size="sm">Download</Button>
</div>
</div>
<h3>Simple by default</h3>
<p>Choices made for you to start; every setting when you want it.</p>
</section>
<section class="principle card-surface rounded-xl">
<div class="picture character">
<svg aria-hidden="true" class="icon" viewBox="0 0 {SIZE} {SIZE}">
{#each PATHS as d (d)}<path {d} />{/each}
</svg>
<span class="aa">Aa</span>
<span aria-hidden="true" class="cinder"></span>
</div>
<h3>Recognisable, easy to change</h3>
<p>The icon, the type, one accent. The rest is neutral.</p>
</section>
<section class="principle card-surface rounded-xl">
<div class="picture grid-bg rounded-lg">
<Button size="sm" variant="outline">Run</Button>
</div>
<h3>Function first</h3>
<p>Every element has a job and a reason for its size.</p>
</section>
<section class="principle card-surface rounded-xl">
<div class="picture chain">
<code>--neutral-900</code>
<span aria-hidden="true">↓</span>
<code>--action-primary</code>
<span aria-hidden="true">↓</span>
<code>--button-primary-edge</code>
</div>
<h3>Design lives in code</h3>
<p>Change a primitive and the rest follows.</p>
</section>
</div>
<style>
.principles {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 8px;
}
.principle {
display: grid;
grid-template-rows: auto auto 1fr;
gap: 6px;
padding: 16px;
}
.wide {
grid-column: span 2;
}
.picture {
display: grid;
place-items: center;
min-height: 112px;
margin-bottom: 8px;
}
.devices {
display: flex;
align-items: end;
gap: 20px;
color: var(--fg-default);
}
.wide .picture {
gap: 14px;
}
.chips {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 6px;
}
.pick {
display: grid;
justify-items: start;
gap: 8px;
padding: 12px 14px;
}
.pick-note {
color: var(--figure-muted);
font-size: 12px;
}
.character {
display: flex;
align-items: center;
justify-content: center;
gap: 16px;
}
.icon {
width: 40px;
height: 40px;
fill: currentColor;
}
.aa {
font-size: 40px;
font-weight: 600;
line-height: 1;
}
.cinder {
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--art-cinder);
}
.grid-bg {
background-image:
linear-gradient(
color-mix(in oklab, var(--line-default) 50%, transparent) 1px,
transparent 1px
),
linear-gradient(
90deg,
color-mix(in oklab, var(--line-default) 50%, transparent) 1px,
transparent 1px
);
background-position: center;
background-size: 8px 8px;
}
.chain {
gap: 2px;
color: var(--figure-muted);
font-size: 12px;
}
.chain code {
color: var(--fg-default);
font: 500 12px var(--mono);
}
h3 {
margin: 0;
font-size: 16px;
font-weight: 600;
}
p {
margin: 0;
color: var(--figure-muted);
font-size: 13px;
line-height: 1.45;
}
@media (width < 640px) {
.principles {
grid-template-columns: minmax(0, 1fr);
}
.wide {
grid-column: auto;
}
}
</style>