feat(ui): add native control CSS system + button/text/tab examples (#1267)

This commit is contained in:
Alex
2026-05-12 22:05:47 +01:00
committed by GitHub
parent 82704a26ae
commit a0a710079b
28 changed files with 771 additions and 87 deletions
@@ -6,7 +6,7 @@
box-sizing: border-box;
height: 100%;
overflow: hidden;
background: var(--page-background);
background: var(--surface-page);
@media #{variables.$mobile-shell-media-query} {
padding: var(--space-4);
@@ -267,7 +267,7 @@
.command-palette {
max-height: 100dvh;
background: var(--app-background);
background: var(--surface-app);
border: none;
border-radius: 0;
box-shadow: none;
@@ -277,7 +277,7 @@
box-sizing: border-box;
flex-shrink: 0;
height: 3.5rem;
background: var(--app-background);
background: var(--surface-app);
border-bottom: 1px solid var(--border-color);
&:has(+ .command-palette-results) .command-palette-input-row {
@@ -314,7 +314,7 @@
.command-palette-results,
.command-palette-empty {
background: var(--page-background);
background: var(--surface-page);
}
.command-palette-empty {
@@ -0,0 +1,10 @@
import {Directive} from '@angular/core';
@Directive({
selector: '[appButtonGroup]',
standalone: true,
host: {
class: 'app-control-group app-control-group-inline',
},
})
export class AppButtonGroupDirective {}
@@ -0,0 +1,21 @@
import {booleanAttribute, Directive, input} from '@angular/core';
export type AppButtonVariant = 'neutral' | 'primary' | 'danger';
export type AppButtonSize = 'sm' | 'md';
@Directive({
selector: 'button[appButton], a[appButton]',
standalone: true,
host: {
class: 'app-button',
'[class.app-button-primary]': 'variant() === "primary"',
'[class.app-button-danger]': 'variant() === "danger"',
'[class.app-button-sm]': 'size() === "sm"',
'[class.app-button-icon]': 'iconOnly()',
},
})
export class AppButtonDirective {
readonly variant = input<AppButtonVariant>('neutral');
readonly size = input<AppButtonSize>('md');
readonly iconOnly = input(false, {transform: booleanAttribute});
}
@@ -0,0 +1,33 @@
@if (tabs().length) {
<div ngTabs class="app-tabs-root">
<div
ngTabList
class="app-tabs"
[class.is-measured]="indicatorVisible()"
[class.is-animated]="indicatorAnimated()"
[(selectedTab)]="selectedTabId"
[attr.aria-label]="ariaLabel()"
>
<span
class="app-tabs-indicator"
aria-hidden="true"
[style.transform]="'translateX(' + indicatorLeft() + 'px)'"
[style.width.px]="indicatorWidth()"
></span>
@for (tab of tabs(); track tab.id) {
<button
ngTab
type="button"
[id]="tab.id"
[value]="tab.id"
class="app-tab"
>
@if (tab.icon) {
<i [class]="'app-tab-icon ' + tab.icon" aria-hidden="true"></i>
}
<span class="app-tab-label">{{ tab.label }}</span>
</button>
}
</div>
</div>
}
@@ -0,0 +1,129 @@
import {
afterRenderEffect,
ChangeDetectionStrategy,
Component,
DestroyRef,
computed,
inject,
input,
model,
signal,
viewChildren,
} from '@angular/core';
import {Tab as NgTab, TabList, Tabs} from '@angular/aria/tabs';
export interface TabItem {
id: string;
label: string;
icon?: string;
}
export type TabsVariant = 'underline' | 'segmented';
export type TabsPlacement = 'inline' | 'below';
@Component({
selector: 'app-tabs',
standalone: true,
imports: [Tabs, TabList, NgTab],
templateUrl: './app-tabs.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
'[class.variant-underline]': 'variant() === "underline"',
'[class.variant-segmented]': 'variant() === "segmented"',
'[class.placement-inline]': 'placement() === "inline"',
'[class.placement-below]': 'placement() === "below"',
},
})
export class AppTabsComponent {
readonly tabs = input.required<TabItem[]>();
readonly variant = input<TabsVariant>('underline');
readonly placement = input<TabsPlacement>('below');
readonly ariaLabel = input.required<string>();
readonly selectedTabId = model<string | undefined>(undefined);
private readonly destroyRef = inject(DestroyRef);
private readonly tabDirectives = viewChildren(NgTab);
protected readonly activeTabId = computed(() => this.selectedTabId() ?? this.tabs()[0]?.id);
protected readonly indicatorLeft = signal(0);
protected readonly indicatorWidth = signal(0);
protected readonly indicatorVisible = signal(false);
protected readonly indicatorAnimated = signal(false);
private pendingAnimationFrame: number | null = null;
private initialRevealScheduled = false;
constructor() {
let resizeObserver: ResizeObserver | null = null;
afterRenderEffect(() => {
this.tabs();
this.variant();
this.placement();
this.activeTabId();
this.scheduleMeasure();
const tabs = this.tabDirectives();
if (tabs.length && typeof ResizeObserver !== 'undefined') {
resizeObserver ??= new ResizeObserver(() => this.scheduleMeasure());
resizeObserver.disconnect();
for (const tab of tabs) {
resizeObserver.observe(tab.element);
}
}
});
this.destroyRef.onDestroy(() => {
resizeObserver?.disconnect();
if (this.pendingAnimationFrame !== null) {
cancelAnimationFrame(this.pendingAnimationFrame);
}
});
}
private measure(): void {
const activeTabId = this.activeTabId();
const active = this.tabDirectives().find(tab => tab.value() === activeTabId);
if (!active) {
this.indicatorVisible.set(false);
return;
}
this.indicatorLeft.set(active.element.offsetLeft);
this.indicatorWidth.set(active.element.offsetWidth);
if (!this.indicatorVisible()) {
this.scheduleInitialReveal();
return;
}
this.indicatorAnimated.set(true);
}
private scheduleMeasure(): void {
if (this.pendingAnimationFrame !== null) {
cancelAnimationFrame(this.pendingAnimationFrame);
}
this.pendingAnimationFrame = requestAnimationFrame(() => {
this.pendingAnimationFrame = null;
this.measure();
});
}
private scheduleInitialReveal(): void {
if (this.initialRevealScheduled) return;
this.initialRevealScheduled = true;
void document.fonts.ready.then(() => {
if (this.pendingAnimationFrame !== null) {
cancelAnimationFrame(this.pendingAnimationFrame);
}
this.pendingAnimationFrame = requestAnimationFrame(() => {
this.measure();
this.indicatorVisible.set(true);
this.pendingAnimationFrame = requestAnimationFrame(() => {
this.pendingAnimationFrame = null;
this.indicatorAnimated.set(true);
});
});
});
}
}
@@ -0,0 +1,10 @@
import {Directive} from '@angular/core';
@Directive({
selector: 'input[appTextField]',
standalone: true,
host: {
class: 'app-text-field',
},
})
export class AppTextFieldDirective {}
@@ -13,7 +13,7 @@
box-sizing: border-box;
height: 3.5rem;
z-index: 100;
background-color: var(--app-background);
background-color: var(--surface-app);
border-bottom: 1px solid var(--content-border-color);
padding:
0
@@ -289,14 +289,14 @@
(overlayKeydown)="onUserPopoverKeydown($event)"
>
<section
class="user-account-popover"
class="user-account-popover surface-page"
role="dialog"
aria-modal="true"
cdkTrapFocus
cdkTrapFocusAutoCapture
[attr.aria-label]="'settingsProfile.title' | transloco"
>
<header class="user-account-popover-header">
<header class="user-account-popover-header surface-card">
<div class="user-account-popover-title-row">
<h2>Grimmory <span>{{ appVersionLabel() }}</span></h2>
<button
@@ -312,8 +312,8 @@
<div class="user-account-popover-header-actions">
<button
appButton
type="button"
class="user-account-popover-settings"
(click)="openSettings()"
>
<i class="pi pi-cog" aria-hidden="true"></i>
@@ -322,8 +322,9 @@
@if (updateAvailable()) {
<button
appButton
variant="primary"
type="button"
class="user-account-popover-update"
(click)="openChangelogDialog()"
>
<i class="pi pi-arrow-up-right" aria-hidden="true"></i>
@@ -7,6 +7,7 @@ import { CdkTrapFocus } from '@angular/cdk/a11y';
import { CdkConnectedOverlay, CdkOverlayOrigin } from '@angular/cdk/overlay';
import { BookDialogHelperService } from '../../../features/book/components/book-browser/book-dialog-helper.service';
import { UnifiedNotificationBoxComponent } from '../../components/unified-notification-popover/unified-notification-popover-component';
import { AppButtonDirective } from '../../components/button/app-button.directive';
import { MenuComponent } from '../../components/menu/menu.component';
import { MenuEntry } from '../../components/menu/menu-item.model';
import {
@@ -89,6 +90,7 @@ function isNewerVersion(latest: string | undefined, current: string | undefined)
selector: 'app-sidebar',
imports: [
AppSidebarSectionComponent,
AppButtonDirective,
Popover,
UnifiedNotificationBoxComponent,
MenuComponent,
@@ -31,7 +31,7 @@ describe('theme-palette-extend', () => {
expect(auraPrimitive['skyBlue']['700']).toBe('#2e88e6');
expect(auraPrimitive['dustyNeutral']['950']).toBe('#2f2821');
expect(preset.primitive?.['coralSunset']['500']).toBe('#ef7550');
expect(preset.semantic?.colorScheme?.light?.content?.background).toBe('var(--page-background)');
expect(preset.semantic?.colorScheme?.dark?.content?.background).toBe('var(--page-background)');
expect(preset.semantic?.colorScheme?.light?.content?.background).toBe('var(--surface-page)');
expect(preset.semantic?.colorScheme?.dark?.content?.background).toBe('var(--surface-page)');
});
});
@@ -232,8 +232,8 @@ Object.assign(Aura.primitive, customPalettes);
const AppPrimePreset = definePreset(Aura, {
semantic: {
colorScheme: {
light: { content: { background: 'var(--page-background)' } },
dark: { content: { background: 'var(--page-background)' } }
light: { content: { background: 'var(--surface-page)' } },
dark: { content: { background: 'var(--surface-page)' } }
}
}
});
@@ -56,10 +56,10 @@ describe('AppConfigService', () => {
expect(rootStyle.getPropertyValue('--primary-400')).toBe('#fb923c');
expect(rootStyle.getPropertyValue('--primary-500')).toBe('#f97316');
expect(rootStyle.getPropertyValue('--primary-color')).toBe('#fb923c');
expect(rootStyle.getPropertyValue('--app-background')).toBe('#0d1012');
expect(rootStyle.getPropertyValue('--page-background')).toBe('color-mix(in srgb, #1a1e21 82%, #0d1012)');
expect(rootStyle.getPropertyValue('--surface-app')).toBe('#0d1012');
expect(rootStyle.getPropertyValue('--surface-page')).toBe('color-mix(in srgb, #1a1e21 82%, #0d1012)');
expect(rootStyle.getPropertyValue('--surface-content')).toBe('#1a1e21');
expect(rootStyle.getPropertyValue('--ground-background')).toBe('var(--app-background)');
expect(rootStyle.getPropertyValue('--ground-background')).toBe('var(--surface-app)');
expect(rootStyle.getPropertyValue('--content-border-color')).toBe('var(--border-subtle)');
expect(faviconServiceMock.updateFavicon).toHaveBeenCalledWith('#fdba74', '#f97316');
});
@@ -76,9 +76,9 @@ describe('AppConfigService', () => {
expect(rootStyle.getPropertyValue('--primary-300')).toBe('#f9be9e');
expect(rootStyle.getPropertyValue('--primary-500')).toBe('#ef7550');
expect(rootStyle.getPropertyValue('--primary-color-rgb')).toBe('239, 117, 80');
expect(rootStyle.getPropertyValue('--app-background')).toBe('#121518');
expect(rootStyle.getPropertyValue('--page-background')).toBe('color-mix(in srgb, #1f252c 82%, #121518)');
expect(rootStyle.getPropertyValue('--ground-background')).toBe('var(--app-background)');
expect(rootStyle.getPropertyValue('--surface-app')).toBe('#121518');
expect(rootStyle.getPropertyValue('--surface-page')).toBe('color-mix(in srgb, #1f252c 82%, #121518)');
expect(rootStyle.getPropertyValue('--ground-background')).toBe('var(--surface-app)');
expect(rootStyle.getPropertyValue('--surface-card')).toBe('color-mix(in srgb, #1f252c 62%, #38424d)');
expect(rootStyle.getPropertyValue('--card-background')).toBe('var(--surface-card)');
expect(faviconServiceMock.updateFavicon).toHaveBeenLastCalledWith('#f9be9e', '#ef7550');
@@ -502,8 +502,8 @@ export class AppConfigService {
style.setProperty('--primary-text-color', primary400 ?? '#fb923c');
style.setProperty('--primary-text-color-dark', theme.isNoir ? (theme.surface['950'] ?? '#0d1012') : (theme.primary['900'] ?? '#9a3412'));
style.setProperty('--app-background', appBackground);
style.setProperty('--page-background', pageBackground);
style.setProperty('--surface-app', appBackground);
style.setProperty('--surface-page', pageBackground);
style.setProperty('--surface-content', surfaceContent);
style.setProperty('--surface-card', surfaceCard);
style.setProperty('--surface-toolbar', `color-mix(in srgb, ${appBackground} 70%, ${surfaceContent})`);
@@ -513,7 +513,7 @@ export class AppConfigService {
style.setProperty('--state-hover', 'color-mix(in srgb, var(--surface-400) 12%, transparent)');
style.setProperty('--state-active', 'color-mix(in srgb, var(--primary-color) 8%, transparent)');
style.setProperty('--ground-background', 'var(--app-background)');
style.setProperty('--ground-background', 'var(--surface-app)');
style.setProperty('--overlay-background', 'var(--surface-overlay)');
style.setProperty('--card-background', 'var(--surface-card)');
style.setProperty('--content-background', 'var(--surface-content)');
@@ -7,7 +7,7 @@
min-height: 0;
height: 100dvh;
overflow: hidden;
background-color: var(--page-background);
background-color: var(--surface-page);
}
.layout-main > router-outlet + * {
@@ -7,6 +7,6 @@
min-height: 100dvh;
overflow: hidden;
scroll-behavior: smooth;
background-color: var(--app-background);
background-color: var(--surface-app);
transition: grid-template-columns variables.$transition-duration;
}
@@ -23,7 +23,7 @@
.layout-wrapper {
display: block;
background-color: var(--page-background);
background-color: var(--surface-page);
.layout-main {
--mobile-topbar-height: 3.5rem;
@@ -41,7 +41,7 @@
user-select: none;
transition: transform var(--transition-base),
width var(--transition-base);
background-color: var(--app-background);
background-color: var(--surface-app);
border-right: 1px solid var(--border-color);
padding: var(--space-3) var(--sidebar-shell-padding-inline-end) var(--space-3) var(--sidebar-shell-padding-inline-start);
}
+2 -2
View File
@@ -21,7 +21,7 @@ body {
min-height: 100%;
margin: 0;
padding: 0;
background-color: var(--app-background);
background-color: var(--surface-app);
color: var(--text-color);
font-family: var(--font-family), serif;
-webkit-font-smoothing: antialiased;
@@ -35,7 +35,7 @@ body {
html,
body {
background-color: var(--page-background);
background-color: var(--surface-page);
}
}
+136
View File
@@ -0,0 +1,136 @@
.app-button {
--app-button-height: var(--control-height);
--app-button-padding-x: var(--control-padding-x);
--app-button-radius: var(--control-radius);
--app-button-icon-size: var(--control-icon-size);
--app-button-color: var(--text-color);
--app-button-bg: var(--control-bg);
--app-button-bg-hover: var(--control-bg-hover);
--app-button-border: var(--control-border);
--app-button-border-hover: var(--control-border-hover);
display: inline-flex;
position: relative;
align-items: center;
justify-content: center;
flex-shrink: 0;
gap: var(--control-gap);
box-sizing: border-box;
min-width: var(--app-button-height);
height: var(--app-button-height);
padding: 0 var(--app-button-padding-x);
border: 1px solid var(--app-button-border);
border-radius: var(--app-button-radius);
background: var(--app-button-bg);
background-clip: padding-box;
color: var(--app-button-color);
font: inherit;
font-size: var(--text-base);
font-weight: 500;
line-height: 1;
text-decoration: none;
white-space: nowrap;
cursor: pointer;
transition:
background var(--transition-fast),
border-color var(--transition-fast),
color var(--transition-fast),
transform var(--transition-fast);
&:hover {
background: var(--app-button-bg-hover);
border-color: var(--app-button-border-hover);
}
&:active {
transform: translateY(1px);
}
&:focus-visible {
outline: 2px solid var(--primary-color);
outline-offset: 2px;
}
&:disabled,
&[aria-disabled="true"] {
pointer-events: none;
opacity: var(--control-disabled-opacity);
}
.pi {
position: relative;
z-index: 1;
flex-shrink: 0;
font-size: var(--app-button-icon-size);
line-height: 1;
transition: transform var(--transition-fast);
}
span {
position: relative;
z-index: 1;
transition: transform var(--transition-fast);
}
}
.app-button-primary {
--app-button-bg: var(--control-primary-bg);
--app-button-bg-hover: var(--control-primary-bg-hover);
--app-button-border: var(--control-primary-border);
--app-button-border-hover: var(--control-primary-border-hover);
--app-button-color: var(--primary-color);
}
.app-button-danger {
--app-button-border: var(--danger-color);
--app-button-border-hover: var(--danger-hover-color);
}
.app-button-sm {
--app-button-height: var(--control-height-sm);
--app-button-padding-x: var(--control-padding-x-sm);
--app-button-icon-size: var(--control-icon-size-sm);
font-size: var(--text-sm);
}
.app-button-icon {
width: var(--app-button-height);
padding: 0;
background: transparent;
border: 0;
&::before {
content: "";
position: absolute;
inset: 0;
z-index: 0;
box-sizing: border-box;
border: 1px solid var(--app-button-border);
border-radius: inherit;
background: var(--app-button-bg);
background-clip: padding-box;
transition:
background var(--transition-fast),
border-color var(--transition-fast),
transform var(--transition-fast);
}
&:hover {
background: transparent;
&::before {
background: var(--app-button-bg-hover);
border-color: var(--app-button-border-hover);
}
}
&:active {
transform: none;
&::before,
.pi {
transform: translateY(1px);
}
}
}
@@ -0,0 +1,55 @@
.app-control-group {
--app-control-group-radius: var(--control-radius);
display: flex;
align-items: stretch;
width: 100%;
> * {
border-radius: 0;
}
> .app-text-field {
flex: 1 1 auto;
min-width: 0;
}
> * + * {
margin-left: -1px;
}
> :first-child {
border-top-left-radius: var(--app-control-group-radius);
border-bottom-left-radius: var(--app-control-group-radius);
}
> :last-child {
border-top-right-radius: var(--app-control-group-radius);
border-bottom-right-radius: var(--app-control-group-radius);
}
> .app-button {
--app-button-padding-x: 1rem;
}
> .app-button-icon {
width: calc(var(--app-button-height) + 0.375rem);
}
> .app-button-primary {
z-index: 1;
}
> .app-text-field:hover,
> .app-text-field:focus,
> .app-button:hover,
> .app-button:focus-visible,
> .app-button:active {
z-index: 2;
}
}
.app-control-group-inline {
display: inline-flex;
width: auto;
}
+11 -54
View File
@@ -24,16 +24,16 @@
.menu-panel,
.user-account-popover {
--menu-panel-padding: 4px;
--menu-panel-padding: var(--space-1);
--menu-panel-gap: 1px;
--menu-panel-min-width: 12rem;
--menu-panel-radius: 8px;
--menu-item-padding-block: 4px;
--menu-item-padding-inline: 10px;
--menu-item-min-height: 28px;
--menu-item-gap: 8px;
--menu-item-gap: var(--control-gap);
--menu-item-radius: 5px;
--menu-item-icon-size: 16px;
--menu-item-focus-ring: var(--control-focus-ring-color);
--menu-item-danger-bg-hover: color-mix(in srgb, var(--p-red-500) 12%, transparent);
}
.menu-panel {
@@ -42,9 +42,9 @@
gap: var(--menu-panel-gap);
min-width: var(--menu-panel-min-width);
padding: var(--menu-panel-padding);
background: var(--page-background);
background: var(--surface-page);
border: 1px solid var(--border-color);
border-radius: var(--menu-panel-radius);
border-radius: var(--control-radius);
box-shadow: 0 8px 24px rgb(0 0 0 / 18%);
color: var(--text-color);
font: inherit;
@@ -78,7 +78,7 @@
.menu-panel .menu-item:focus-visible,
.user-account-popover .menu-item:focus-visible {
background-color: var(--surface-hover);
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary-color) 50%, transparent);
box-shadow: inset 0 0 0 1px var(--menu-item-focus-ring);
outline: none;
}
@@ -95,8 +95,8 @@
align-items: center;
justify-content: center;
flex-shrink: 0;
width: var(--menu-item-icon-size);
height: var(--menu-item-icon-size);
width: var(--control-icon-size);
height: var(--control-icon-size);
font-size: var(--text-base);
color: var(--surface-500);
}
@@ -127,9 +127,8 @@
flex-direction: column;
width: min(17.5rem, calc(100vw - 1rem));
overflow: hidden;
background: var(--page-background);
border: 1px solid var(--border-color);
border-radius: var(--menu-panel-radius);
border-radius: var(--control-radius);
box-shadow:
0 18px 48px rgb(0 0 0 / 28%),
0 4px 16px rgb(0 0 0 / 18%);
@@ -144,7 +143,6 @@
box-sizing: border-box;
width: 100%;
padding: 0.75rem;
background: color-mix(in srgb, var(--surface-hover), var(--page-background) 35%);
border-bottom: 1px solid var(--border-color);
}
@@ -207,45 +205,6 @@
gap: 0.5rem;
}
.user-account-popover .user-account-popover-settings,
.user-account-popover .user-account-popover-update {
display: inline-flex;
align-items: center;
justify-content: center;
align-self: flex-start;
gap: var(--menu-item-gap);
min-height: var(--menu-item-min-height);
padding: var(--menu-item-padding-block) var(--menu-item-padding-inline);
border: 1px solid var(--border-color);
border-radius: var(--menu-item-radius);
background: transparent;
color: var(--text-color);
font: inherit;
font-weight: 600;
text-decoration: none;
cursor: pointer;
}
.user-account-popover .user-account-popover-settings:hover,
.user-account-popover .user-account-popover-settings:focus-visible {
background: var(--surface-hover);
color: var(--text-color);
outline: none;
}
.user-account-popover .user-account-popover-update {
border-color: color-mix(in srgb, var(--primary-color) 30%, transparent);
background: color-mix(in srgb, var(--primary-color) 18%, transparent);
color: var(--primary-color);
}
.user-account-popover .user-account-popover-update:hover,
.user-account-popover .user-account-popover-update:focus-visible {
background: color-mix(in srgb, var(--primary-color) 26%, transparent);
color: var(--primary-color);
outline: none;
}
.user-account-popover-body {
display: flex;
flex-direction: column;
@@ -268,14 +227,12 @@
color: var(--p-red-400);
}
.user-account-popover .user-account-popover-settings i,
.user-account-popover .user-account-popover-update i,
.user-account-popover .user-account-popover-logout i {
color: currentcolor;
}
.user-account-popover .user-account-popover-logout:hover,
.user-account-popover .user-account-popover-logout:focus-visible {
background: color-mix(in srgb, var(--p-red-500) 12%, transparent);
background: var(--menu-item-danger-bg-hover);
outline: none;
}
+1 -1
View File
@@ -13,7 +13,7 @@
min-height: 100%;
padding: var(--page-gutter-block) var(--page-gutter-inline);
overflow: auto;
background-color: var(--page-background);
background-color: var(--surface-page);
color: var(--text-color);
}
+218
View File
@@ -0,0 +1,218 @@
app-tabs {
display: block;
}
.app-tabs-root {
display: contents;
}
.app-tabs {
position: relative;
display: flex;
align-items: center;
min-width: 0;
}
.app-tabs-indicator {
position: absolute;
left: 0;
pointer-events: none;
width: 0;
opacity: 0;
}
.app-tabs.is-measured .app-tabs-indicator {
opacity: 1;
}
.app-tabs.is-animated .app-tabs-indicator {
transition:
transform 220ms cubic-bezier(0.4, 0, 0.2, 1),
width 220ms cubic-bezier(0.4, 0, 0.2, 1);
}
.app-tab {
position: relative;
display: inline-flex;
align-items: center;
justify-content: center;
gap: var(--control-gap);
box-sizing: border-box;
border: 0;
background: none;
color: var(--text-color-secondary);
font-size: 0.9375rem;
font-weight: 500;
line-height: 1;
white-space: nowrap;
text-align: center;
cursor: pointer;
transition:
color var(--transition-fast),
background-color var(--transition-fast),
transform var(--transition-fast);
&:hover {
color: var(--text-color);
}
&:active {
transform: translateY(1px);
}
&:focus-visible {
outline: 2px solid var(--primary-color);
outline-offset: 2px;
}
&[aria-selected="true"]:focus-visible {
outline: none;
}
}
.app-tab-icon {
font-size: 0.875em;
line-height: 1;
flex-shrink: 0;
}
.app-tab-label {
line-height: 1;
}
app-tabs.placement-below {
display: flex;
align-items: flex-start;
height: var(--app-tabs-row-height, 3.5rem);
padding: 0.25rem 2rem 0;
@media (width <= 767px) {
padding: 0.25rem 1rem 0;
}
}
app-tabs.variant-underline {
--app-tabs-divider: color-mix(in srgb, var(--surface-border) 70%, transparent);
padding: 0;
.app-tabs {
align-items: stretch;
width: 100%;
height: 100%;
gap: 1.5rem;
padding: 0 2rem;
&::after {
content: "";
position: absolute;
right: 2rem;
bottom: 0;
left: 2rem;
height: 1px;
background: var(--app-tabs-divider);
pointer-events: none;
}
@media (width <= 767px) {
gap: 1rem;
padding: 0 1rem;
overflow-x: auto;
scrollbar-width: none;
&::after {
right: 1rem;
left: 1rem;
}
&::-webkit-scrollbar {
display: none;
}
}
}
.app-tab {
min-width: 5rem;
padding: 0 1rem;
@media (width <= 767px) {
flex: 1 1 0;
min-width: 4rem;
padding: 0 0.875rem;
}
&[aria-selected="true"] {
color: var(--text-color);
&::before {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 2px;
background: var(--primary-color);
border-radius: 2px 2px 0 0;
z-index: 1;
}
}
}
.app-tabs.is-measured .app-tab[aria-selected="true"]::before {
display: none;
}
.app-tabs-indicator {
bottom: 0;
height: 2px;
background: var(--primary-color);
border-radius: 2px 2px 0 0;
z-index: 1;
}
}
app-tabs.variant-segmented {
.app-tabs {
gap: 0.125rem;
padding: var(--space-1);
border-radius: var(--radius-lg);
background: var(--control-bg);
@media (width <= 767px) {
overflow-x: auto;
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
}
}
.app-tab {
height: 2rem;
padding: 0 1rem;
border-radius: var(--control-radius);
&:hover:not([aria-selected="true"]) {
background: var(--surface-hover);
color: var(--text-color);
}
&[aria-selected="true"] {
color: var(--primary-color);
}
}
.app-tabs.is-measured .app-tab[aria-selected="true"] {
background: transparent;
}
.app-tabs-indicator {
top: var(--space-1);
bottom: var(--space-1);
box-sizing: border-box;
background: var(--control-primary-bg);
border-radius: var(--control-radius);
box-shadow: 0 0 0 1px var(--control-primary-border);
}
}
@@ -0,0 +1,47 @@
.app-text-field {
--app-text-field-height: var(--control-height);
--app-text-field-padding-x: var(--control-padding-x);
--app-text-field-radius: var(--control-radius);
--app-text-field-color: var(--text-color);
--app-text-field-bg: var(--control-bg);
--app-text-field-border: var(--control-border);
--app-text-field-border-hover: var(--control-border-hover);
--app-text-field-border-focus: var(--control-focus-border);
appearance: none;
display: block;
box-sizing: border-box;
width: 100%;
min-width: 0;
height: var(--app-text-field-height);
padding: 0 var(--app-text-field-padding-x);
border: 1px solid var(--app-text-field-border);
border-radius: var(--app-text-field-radius);
background: var(--app-text-field-bg);
background-clip: padding-box;
color: var(--app-text-field-color);
font: inherit;
font-size: var(--text-base);
line-height: 1.5;
transition:
background var(--transition-fast),
border-color var(--transition-fast);
&::placeholder {
color: var(--text-muted-color);
}
&:hover:not(:focus) {
border-color: var(--app-text-field-border-hover);
}
&:focus {
border-color: var(--app-text-field-border-focus);
outline: none;
}
&:disabled {
pointer-events: none;
opacity: var(--control-disabled-opacity);
}
}
+38 -4
View File
@@ -55,6 +55,8 @@
--primary-hover-color: var(--primary-300);
--primary-text-color: var(--primary-400);
--primary-text-color-dark: var(--primary-900);
--danger-color: #ef4444;
--danger-hover-color: #f87171;
/* Text */
--text-color: #ffffff;
@@ -64,13 +66,45 @@
--high-contrast-text-color: #ffffff;
/* App surfaces */
--app-background: #0d1012;
--page-background: color-mix(in srgb, var(--surface-900) 82%, var(--surface-950));
--surface-app: #0d1012;
--surface-page: color-mix(in srgb, var(--surface-900) 82%, var(--surface-950));
--surface-content: #1a1e21;
--surface-card: color-mix(in srgb, var(--surface-900) 62%, var(--surface-800));
--surface-toolbar: color-mix(in srgb, var(--app-background) 70%, var(--surface-content));
--surface-toolbar: color-mix(in srgb, var(--surface-app) 70%, var(--surface-content));
--surface-overlay: #1a1e21;
--primary-bg: color-mix(in srgb, var(--primary-color) 15%, var(--surface-card));
--control-bg: color-mix(in srgb, #fff 6%, var(--surface-app));
--control-primary-bg: var(--primary-bg);
--control-bg-hover-mix: 6%;
--control-border-mix: 12%;
--control-border-hover-mix: 18%;
--control-primary-bg-hover-mix: 12%;
--control-primary-border-mix: 25%;
--control-primary-border-hover-mix: 45%;
--control-focus-mix: 50%;
--control-bg-hover: color-mix(in srgb, #fff var(--control-bg-hover-mix), var(--control-bg));
--control-border: color-mix(in srgb, #fff var(--control-border-mix), var(--control-bg));
--control-border-hover: color-mix(in srgb, #fff var(--control-border-hover-mix), var(--control-bg));
--control-primary-bg-hover: color-mix(in srgb, var(--primary-color) var(--control-primary-bg-hover-mix), var(--control-primary-bg));
--control-primary-border: color-mix(in srgb, var(--primary-color) var(--control-primary-border-mix), var(--control-primary-bg));
--control-primary-border-hover: color-mix(in srgb, var(--primary-color) var(--control-primary-border-hover-mix), var(--control-primary-bg));
--control-focus-border: color-mix(in srgb, var(--primary-color) var(--control-focus-mix), var(--control-bg));
--control-focus-ring-color: color-mix(in srgb, var(--primary-color) var(--control-focus-mix), transparent);
--control-height: 2.625rem;
--control-height-sm: 2.25rem;
--control-padding-x: 0.75rem;
--control-padding-x-sm: 0.875rem;
--control-icon-size: 1rem;
--control-icon-size-sm: 0.875rem;
--control-gap: 0.5rem;
--control-radius: var(--radius-md);
--control-disabled-opacity: 0.5;
/* Borders */
--border-subtle: #34393e;
--border-strong: #464f56;
@@ -128,7 +162,7 @@
* Existing app styles still use these names. Prefer the canonical semantic
* tokens above for new native layout and page CSS.
*/
--ground-background: var(--app-background);
--ground-background: var(--surface-app);
--overlay-background: var(--surface-overlay);
--card-background: var(--surface-card);
--content-background: var(--surface-content);
+27
View File
@@ -9,6 +9,33 @@
display: none;
}
.surface-app,
.surface-page,
.surface-card {
--control-bg-hover: color-mix(in srgb, #fff var(--control-bg-hover-mix), var(--control-bg));
--control-border: color-mix(in srgb, #fff var(--control-border-mix), var(--control-bg));
--control-border-hover: color-mix(in srgb, #fff var(--control-border-hover-mix), var(--control-bg));
--control-focus-border: color-mix(in srgb, var(--primary-color) var(--control-focus-mix), var(--control-bg));
}
.surface-app {
--control-bg: color-mix(in srgb, #fff 6%, var(--surface-app));
background: var(--surface-app);
}
.surface-page {
--control-bg: color-mix(in srgb, #fff 6%, var(--surface-page));
background: var(--surface-page);
}
.surface-card {
--control-bg: color-mix(in srgb, #fff 6%, var(--surface-card));
background: var(--surface-card);
}
.gradient-divider {
flex-shrink: 0;
height: 1px;
+4
View File
@@ -4,6 +4,10 @@
@include meta.load-css("assets/styles/tokens.css");
@include meta.load-css("assets/styles/reset");
@include meta.load-css("assets/styles/base");
@include meta.load-css("assets/styles/buttons");
@include meta.load-css("assets/styles/text-fields");
@include meta.load-css("assets/styles/control-groups");
@include meta.load-css("assets/styles/tabs");
@include meta.load-css("assets/styles/page");
@include meta.load-css("assets/styles/layout");
@include meta.load-css("assets/styles/overlays");