Files
VoelinClient/crates/voelin-ui/ui/components/badge.slint
T
Claude e40bce40e8 voelin-ui: design system, shells and view models for the new design
The single 1700-line app.slint becomes a design system and screens that
later waves can compose:

- theme.slint: colour, radius, spacing and type tokens (dark and light,
  a runtime font scale); icons.slint: Lucide icons as tintable images.
- components/: Button, IconButton, TextField, SearchBox, Select, Toggle,
  Slider, SegmentedTabs, Avatar, badges, Card, Meter, NavItem, ListItem,
  PopupMenu, Tooltip, Modal, Toast, ResizeHandle, Spinner, RichText and
  the EmojiPicker.
- shells/: the desktop frame (server rail, top bar, sidebar with the user
  card) and the phone frame with a bottom navigation, switched at a
  breakpoint from the settings.
- screens/: today's screens re-skinned (channels, chat, streams panel and
  viewer, settings page, home, dialogs, phone pages); all callbacks and
  properties keep their behaviour. Navigation state is the Nav global.

On the Rust side app.rs keeps setup and event glue; servers.rs, chat.rs,
settings_page.rs and appearance.rs hold the logic, vm/ the pure view
models, bind/ the callbacks, dev.rs the development switches. Models are
created once and updated row by row (vm::list::sync); each chat tab owns
its lines model, so a message appends one row. Emoji come from the
bundled Twemoji archive through a size-bounded image cache, split into
runs that wrap with the text. New settings ui.theme, ui.font_scale,
ui.narrow_breakpoint and ui.image_cache_mb apply live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-28 02:22:25 +00:00

95 lines
2.8 KiB
Plaintext

import { Theme } from "../theme.slint";
import { Icon } from "icon.slint";
// A red count bubble (unread, requests).
export component CountBadge inherits Rectangle {
in property <int> count;
in property <color> fill: Theme.live;
width: max(18px, label.preferred-width + 10px);
height: 18px;
border-radius: 9px;
background: fill;
accessible-role: AccessibleRole.text;
accessible-label: count;
HorizontalLayout {
padding-left: 5px;
padding-right: 5px;
label := Text {
text: root.count > 99 ? "99+" : root.count;
color: #ffffff;
font-size: Theme.font-xs;
font-weight: Theme.weight-bold;
horizontal-alignment: center;
vertical-alignment: center;
}
}
}
// The red LIVE tag.
export component LiveBadge inherits Rectangle {
in property <string> text: @tr("LIVE");
in property <bool> large;
height: large ? 26px : 18px;
width: label.preferred-width + (large ? 16px : 10px);
horizontal-stretch: 0;
vertical-stretch: 0;
border-radius: Theme.radius-xs;
background: Theme.live;
accessible-role: AccessibleRole.text;
accessible-label: text;
label := Text {
text: root.text;
color: #ffffff;
font-size: root.large ? Theme.font-body : Theme.font-xs;
font-weight: Theme.weight-bold;
horizontal-alignment: center;
vertical-alignment: center;
}
}
// A small rounded label: tags, stream facts ("1080p"), roles ("Moderator").
export component Chip inherits Rectangle {
in property <string> text;
in property <image> icon;
in property <color> tint: Theme.text-secondary;
in property <brush> fill: Theme.surface-3;
in property <bool> outlined;
height: 22px;
width: row.preferred-width;
horizontal-stretch: 0;
vertical-stretch: 0;
border-radius: Theme.radius-pill;
background: fill;
border-width: outlined ? 1px : 0px;
border-color: Theme.border-strong;
accessible-role: AccessibleRole.text;
accessible-label: text;
row := HorizontalLayout {
padding-left: Theme.space-3;
padding-right: Theme.space-3;
spacing: Theme.space-2;
if root.icon.width > 0: Icon {
source: root.icon;
size: 12px;
tint: root.tint;
y: (parent.height - self.height) / 2;
}
Text {
text: root.text;
color: root.tint;
font-size: Theme.font-xs;
font-weight: Theme.weight-medium;
vertical-alignment: center;
}
}
}
// A coloured dot (online, connection state).
export component Dot inherits Rectangle {
in property <length> size: 8px;
width: size;
height: size;
border-radius: size / 2;
background: Theme.success;
}