import { Theme } from "../theme.slint"; import { Icons } from "../icons.slint"; import { Icon } from "icon.slint"; // A navigation entry: icon, title, optional subtitle and count; the // selected one filled with the accent and ringed (settings navigation, // sidebar links). export component NavItem inherits Rectangle { in property icon; in property text; in property subtitle; in property selected; in property badge; // Show a chevron at the right (mobile lists). in property chevron; callback clicked(); min-height: subtitle != "" ? 52px * Theme.font-scale : 40px * Theme.font-scale; border-radius: Theme.radius-md; background: selected ? Theme.accent-soft : touch.has-hover ? Theme.surface-3 : transparent; border-width: selected ? 1px : 0px; border-color: Theme.accent; animate background { duration: Theme.fast; } accessible-role: AccessibleRole.list-item; accessible-label: text; accessible-description: subtitle; accessible-item-selectable: true; accessible-item-selected: selected; accessible-action-default => { clicked(); } touch := TouchArea { mouse-cursor: MouseCursor.pointer; clicked => { root.clicked(); } } HorizontalLayout { padding-left: Theme.space-4; padding-right: Theme.space-3; spacing: Theme.space-4; if root.icon.width > 0: Icon { source: root.icon; size: root.subtitle != "" ? Theme.icon-lg : Theme.icon-md; tint: root.selected ? Theme.text : Theme.icon; y: (parent.height - self.height) / 2; } VerticalLayout { alignment: center; horizontal-stretch: 1; Text { text: root.text; color: root.selected ? Theme.text : Theme.text; font-weight: root.selected ? Theme.weight-semibold : Theme.weight-medium; font-size: Theme.font-body; overflow: elide; } if root.subtitle != "": Text { text: root.subtitle; color: root.selected ? Theme.text-secondary : Theme.text-muted; font-size: Theme.font-sm; overflow: elide; } } if root.badge > 0: VerticalLayout { alignment: center; Rectangle { min-width: 18px; height: 18px; border-radius: 9px; background: Theme.live; HorizontalLayout { padding-left: 5px; padding-right: 5px; Text { text: root.badge > 99 ? "99+" : root.badge; color: #ffffff; font-size: Theme.font-xs; font-weight: Theme.weight-bold; horizontal-alignment: center; vertical-alignment: center; } } } } if root.chevron: Icon { source: Icons.chevron-right; size: Theme.icon-sm; tint: Theme.text-muted; y: (parent.height - self.height) / 2; } } } // A list row: a leading slot (@children, e.g. an Avatar), title and // subtitle, and trailing text. For lists of people, conversations, sources. export component ListItem inherits Rectangle { in property title; in property subtitle; in property title-color: Theme.text; in property subtitle-color: Theme.text-muted; in property trailing; in property selected; in property interactive: true; in property leading-width: 36px; callback clicked(); callback double-clicked(); min-height: 44px * Theme.font-scale; border-radius: Theme.radius-md; background: selected ? Theme.accent-soft : touch.has-hover && interactive ? Theme.surface-3 : transparent; border-width: selected ? 1px : 0px; border-color: Theme.accent; accessible-role: AccessibleRole.list-item; accessible-label: title; accessible-description: subtitle; accessible-item-selectable: interactive; accessible-item-selected: selected; accessible-action-default => { clicked(); } touch := TouchArea { enabled: root.interactive; mouse-cursor: MouseCursor.pointer; clicked => { root.clicked(); } double-clicked => { root.double-clicked(); } } HorizontalLayout { padding-left: Theme.space-3; padding-right: Theme.space-3; padding-top: Theme.space-2; padding-bottom: Theme.space-2; spacing: Theme.space-4; VerticalLayout { alignment: center; width: root.leading-width; @children } VerticalLayout { alignment: center; horizontal-stretch: 1; Text { text: root.title; color: root.title-color; font-weight: Theme.weight-medium; overflow: elide; } if root.subtitle != "": Text { text: root.subtitle; color: root.subtitle-color; font-size: Theme.font-sm; overflow: elide; } } if root.trailing != "": Text { text: root.trailing; color: Theme.text-muted; font-size: Theme.font-xs; vertical-alignment: center; } } }