chore(ui): normalise text size and spacing (#1656)

This commit is contained in:
Alex
2026-06-07 08:46:25 +01:00
committed by GitHub
parent 2675c4a04a
commit 349f046062
180 changed files with 4555 additions and 4466 deletions
@@ -11,19 +11,19 @@
left: 0;
right: 0;
box-sizing: border-box;
height: 3.5rem;
height: 3.0625rem;
z-index: 100;
background-color: var(--color-app);
color: var(--color-text);
border-bottom: 1px solid var(--color-border);
padding:
0
calc(0.75rem + env(safe-area-inset-right))
calc(0.6563rem + env(safe-area-inset-right))
0
calc(0.75rem + env(safe-area-inset-left));
calc(0.6563rem + env(safe-area-inset-left));
align-items: center;
justify-content: space-between;
gap: 0.5rem;
gap: 0.4375rem;
}
.mobile-topbar-brand {
@@ -32,18 +32,18 @@
justify-content: center;
flex: 1 1 auto;
min-width: 0;
gap: 0.4rem;
gap: 0.35rem;
}
.mobile-topbar-brand-icon {
width: auto;
height: 1.75rem;
height: 1.5313rem;
flex-shrink: 0;
transform: translateY(1px);
}
.mobile-topbar-brand-text {
font-size: 1.25rem;
font-size: 1.0938rem;
font-weight: 600;
line-height: 1;
white-space: nowrap;
@@ -57,8 +57,8 @@
display: inline-flex;
align-items: center;
justify-content: center;
width: 2.5rem;
height: 2.5rem;
width: 2.1875rem;
height: 2.1875rem;
padding: 0;
border: 0;
background: none;
@@ -76,7 +76,7 @@
}
i {
font-size: 1.25rem;
font-size: 1.0938rem;
}
}
@@ -95,7 +95,7 @@ a.sidebar-item-link.active-route {
}
.sidebar-item-chevron {
font-size: var(--text-sm);
font-size: var(--app-text-sm);
color: var(--color-text-secondary);
padding-right: var(--space-3);
transition: color var(--transition-fast);
@@ -111,7 +111,7 @@ a.sidebar-item-link.active-route {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
font-size: var(--text-base);
font-size: var(--app-text-base);
}
.sidebar-item-label {
@@ -150,8 +150,8 @@ a.sidebar-item-link.active-route {
display: flex;
align-items: center;
justify-content: center;
min-width: 2rem;
height: 1.875rem;
min-width: 1.75rem;
height: 1.6406rem;
padding: 0 var(--space-2);
border: 0;
border-radius: var(--radius-pill);
@@ -159,7 +159,7 @@ a.sidebar-item-link.active-route {
color: var(--color-text-secondary);
cursor: pointer;
font: inherit;
font-size: var(--text-sm);
font-size: var(--app-text-sm);
transition: color var(--transition-base);
}
@@ -198,7 +198,7 @@ a.sidebar-item-link.active-route {
.book-count {
color: var(--color-text-secondary);
font-size: var(--text-sm);
font-size: var(--app-text-sm);
font-variant-numeric: tabular-nums;
}
@@ -269,7 +269,7 @@ a.sidebar-item-link.active-route {
}
.entity-menu-button {
margin-right: -0.25rem;
margin-right: -0.2188rem;
}
}
@@ -109,13 +109,13 @@
@media #{variables.$mobile-shell-media-query} {
.expand-icon-button {
opacity: 1;
width: 2rem;
height: 2rem;
margin-right: -0.25rem;
width: 1.75rem;
height: 1.75rem;
margin-right: -0.2188rem;
}
.expand-icon {
font-size: 1.125rem;
font-size: var(--app-text-lg);
color: var(--color-text-secondary);
}
}
@@ -415,9 +415,9 @@
>
<i class="pi pi-palette" aria-hidden="true"></i>
<span>{{ 'layout.theme.appearance' | transloco }}</span>
<span class="ml-auto mr-2 min-w-0 max-w-[5.5rem] overflow-hidden text-ellipsis whitespace-nowrap text-xs text-text-secondary">{{ selectedAppearanceLabel() }}</span>
<span class="ml-auto mr-1.5 min-w-0 max-w-[4.75rem] overflow-hidden text-ellipsis whitespace-nowrap text-xs text-text-secondary">{{ selectedAppearanceLabel() }}</span>
<i
class="pi pi-chevron-down size-3 shrink-0 text-[0.6875rem] text-text-secondary! transition-transform duration-150"
class="pi pi-chevron-down size-2.5 shrink-0 text-[0.6875rem] text-text-secondary! transition-transform duration-150"
[class.rotate-180]="appearanceMenuOpen()"
aria-hidden="true">
</i>
@@ -425,14 +425,14 @@
<div
id="user-account-appearance-menu"
class="pointer-events-none grid origin-bottom grid-rows-[0fr] translate-y-1 opacity-0 transition-[grid-template-rows,opacity,transform] duration-150 ease-out data-[open=true]:pointer-events-auto data-[open=true]:mt-1 data-[open=true]:border-t data-[open=true]:border-border data-[open=true]:pt-1 data-[open=true]:grid-rows-[1fr] data-[open=true]:translate-y-0 data-[open=true]:opacity-100 motion-reduce:transition-none"
class="pointer-events-none grid origin-bottom grid-rows-[0fr] translate-y-0.5 opacity-0 transition-[grid-template-rows,opacity,transform] duration-150 ease-out data-[open=true]:pointer-events-auto data-[open=true]:mt-0.5 data-[open=true]:border-t data-[open=true]:border-border data-[open=true]:pt-0.5 data-[open=true]:grid-rows-[1fr] data-[open=true]:translate-y-0 data-[open=true]:opacity-100 motion-reduce:transition-none"
[attr.aria-label]="'layout.theme.appearance' | transloco"
[attr.aria-hidden]="!appearanceMenuOpen()"
[attr.data-open]="appearanceMenuOpen()"
[attr.inert]="appearanceMenuOpen() ? null : ''"
>
<div class="min-h-0 overflow-hidden">
<div class="flex flex-col gap-0.5 pb-1 pl-[calc(var(--control-icon-size)+var(--menu-item-gap))]">
<div class="flex flex-col gap-0.5 pb-0.5 pl-[calc(var(--control-icon-size)+var(--menu-item-gap))]">
@for (option of appearanceOptions; track option.value) {
<button
type="button"
@@ -24,7 +24,7 @@
/* Shared rendered-height for both SVGs — derived from wordmark's width × aspect
at default sidebar width. Keeps the wordmark and G-only mark the same pixel
size so they visually align across the collapse/expand toggle. */
--brand-content-height: calc((225px - 2.5rem) * 350 / 2500);
--brand-content-height: calc((225px - 2.1875rem) * 350 / 2500);
--sidebar-brand-optical-nudge: -1px;
display: grid;
@@ -80,7 +80,7 @@
expand animation. Width = min(default-sidebar-content, stored-content): fills
exactly at default 225px, scales down when the user resizes narrower. Height
is pinned alongside width so the wordmark and G-only icon are the same size. */
--wordmark-width: calc(min(225px, var(--sidebar-stored-width, 225px)) - 2.5rem);
--wordmark-width: calc(min(225px, var(--sidebar-stored-width, 225px)) - 2.1875rem);
display: block;
width: var(--wordmark-width);
@@ -144,7 +144,7 @@
}
i {
font-size: var(--text-base);
font-size: var(--app-text-base);
}
}
@@ -164,17 +164,17 @@
.sidebar-notification-badge {
position: absolute;
top: -0.3rem;
right: -0.35rem;
min-width: 1rem;
height: 1rem;
padding: 0 0.25rem;
top: -0.2625rem;
right: -0.3063rem;
min-width: 0.875rem;
height: 0.875rem;
padding: 0 0.2188rem;
border-radius: var(--radius-pill);
background: var(--color-primary);
color: var(--color-primary-contrast);
font-size: 0.65rem;
font-size: 0.5687rem;
font-weight: 700;
line-height: 1rem;
line-height: 0.875rem;
text-align: center;
pointer-events: none;
z-index: 1;
@@ -220,7 +220,7 @@
border-radius: var(--sidebar-row-radius);
color: var(--color-text);
font: inherit;
font-size: var(--text-base);
font-size: var(--app-text-base);
text-align: left;
text-decoration: none;
cursor: pointer;
@@ -243,7 +243,7 @@
i {
width: var(--sidebar-row-icon-size);
height: var(--sidebar-row-icon-size);
font-size: var(--text-base);
font-size: var(--app-text-base);
display: inline-flex;
align-items: center;
justify-content: center;
@@ -269,8 +269,8 @@
flex: 1 1 0;
width: auto;
min-width: 0;
height: calc(var(--sidebar-row-min-height) + 0.25rem);
min-height: calc(var(--sidebar-row-min-height) + 0.25rem);
height: calc(var(--sidebar-row-min-height) + 0.2188rem);
min-height: calc(var(--sidebar-row-min-height) + 0.2188rem);
justify-content: center;
padding-left: 0;
padding-right: 0;
@@ -305,7 +305,7 @@
margin-left: auto;
color: var(--color-text-secondary);
font-family: inherit;
font-size: var(--text-xs);
font-size: var(--app-text-xs);
line-height: 1;
white-space: nowrap;
flex-shrink: 0;
@@ -318,8 +318,8 @@
gap: var(--sidebar-row-gap);
width: 100%;
min-width: 0;
height: 2.75rem;
min-height: 2.75rem;
height: 2.4063rem;
min-height: 2.4063rem;
padding: 0 var(--sidebar-row-padding-inline-end) 0 var(--sidebar-row-padding-inline-start);
border: 0;
background: none;
@@ -346,8 +346,8 @@
}
.sidebar-collapse-button {
width: 2.75rem;
height: 2.75rem;
width: 2.4063rem;
height: 2.4063rem;
margin-left: auto;
}
@@ -356,12 +356,12 @@
align-items: center;
justify-content: center;
flex-shrink: 0;
width: 1.75rem;
height: 1.75rem;
width: 1.5313rem;
height: 1.5313rem;
border-radius: var(--radius-pill);
background-color: color-mix(in srgb, var(--color-primary) 18%, transparent);
color: var(--color-primary);
font-size: var(--text-xs);
font-size: var(--app-text-xs);
font-weight: 600;
letter-spacing: 0.02em;
line-height: 1;
@@ -370,7 +370,7 @@
/* Align the circle's center with the sidebar icon column (18px icons vs 28px avatar). */
.sidebar-user-trigger .sidebar-user-avatar {
margin-left: calc((var(--sidebar-row-icon-size) - 1.75rem) / 2);
margin-left: calc((var(--sidebar-row-icon-size) - 1.5313rem) / 2);
}
.sidebar-user-meta {
@@ -382,7 +382,7 @@
}
.sidebar-user-name {
font-size: var(--text-base);
font-size: var(--app-text-base);
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
@@ -390,7 +390,7 @@
}
.sidebar-user-handle {
font-size: var(--text-xs);
font-size: var(--app-text-xs);
color: var(--color-text-secondary);
overflow: hidden;
text-overflow: ellipsis;
@@ -401,9 +401,9 @@
.sidebar-header {
box-sizing: border-box;
align-items: center;
min-height: 3.5rem;
height: 3.5rem;
gap: 0.5rem;
min-height: 3.0625rem;
height: 3.0625rem;
gap: 0.4375rem;
padding:
0
calc(var(--sidebar-shell-padding-inline-end) + env(safe-area-inset-right))
@@ -419,15 +419,15 @@
.sidebar-brand {
width: auto;
flex: 1 1 auto;
min-height: 3.5rem;
min-height: 3.0625rem;
padding: 0 var(--space-3);
align-self: stretch;
}
.sidebar-icon-button.sidebar-mobile-close-button {
display: inline-flex;
width: 2.5rem;
height: 2.5rem;
width: 2.1875rem;
height: 2.1875rem;
border-radius: var(--radius-pill);
background-color: var(--color-card);
color: var(--color-text);
@@ -471,9 +471,9 @@
.sidebar-footer-action {
container-type: inline-size;
flex-direction: column;
gap: 0.35rem;
gap: 0.3063rem;
height: auto;
min-height: 4.75rem;
min-height: 4.1563rem;
padding: var(--space-2) var(--space-1);
border-radius: var(--radius-lg);
background-color: var(--color-card);
@@ -486,7 +486,7 @@
.sidebar-footer-action .sidebar-footer-action-label {
display: inline-flex;
margin-left: 0;
font-size: var(--text-sm);
font-size: var(--app-text-sm);
line-height: 1.15;
white-space: normal;
text-align: center;
@@ -497,12 +497,12 @@
@container (width <= 6.25rem) {
.sidebar-footer-action span {
font-size: var(--text-xs);
font-size: var(--app-text-xs);
}
}
.sidebar-footer-action i {
font-size: 1.125rem;
font-size: var(--app-text-lg);
}
.sidebar-collapse-button {
@@ -511,9 +511,9 @@
@media (orientation: landscape) {
.sidebar-header {
gap: 0.5rem;
min-height: 4rem;
height: 4rem;
gap: 0.4375rem;
min-height: 3.5rem;
height: 3.5rem;
padding:
var(--space-2)
var(--sidebar-shell-padding-inline-end)
@@ -529,7 +529,7 @@
.sidebar-brand {
flex: 0 0 auto;
grid-template-columns: var(--sidebar-row-icon-size);
min-height: 4rem;
min-height: 3.5rem;
}
.sidebar-brand-mark {
@@ -553,8 +553,8 @@
}
.sidebar-icon-button.sidebar-mobile-close-button {
width: 3rem;
height: 3rem;
width: 2.625rem;
height: 2.625rem;
background: none;
&:hover {
@@ -564,8 +564,8 @@
.sidebar-icon-button.sidebar-mobile-user-button {
display: inline-flex;
width: 3rem;
height: 3rem;
width: 2.625rem;
height: 2.625rem;
border-radius: var(--radius-pill);
background: none;
@@ -578,17 +578,17 @@
}
.sidebar-user-avatar {
width: 2rem;
height: 2rem;
width: 1.75rem;
height: 1.75rem;
margin-left: 0;
font-size: var(--text-sm);
font-size: var(--app-text-sm);
}
}
.sidebar-icon-button.sidebar-mobile-landscape-action {
display: inline-flex;
width: 3rem;
height: 3rem;
width: 2.625rem;
height: 2.625rem;
border-radius: var(--radius-pill);
background: none;
color: var(--color-text);
@@ -11,7 +11,7 @@
}
.dialog-content {
padding: 1.5rem;
padding: 1.3125rem;
background: var(--card-background);
border: 1px solid var(--border-color);
border-top: none;
@@ -23,7 +23,7 @@
.loading-state,
.empty-state {
padding: 1rem;
padding: 0.875rem;
text-align: center;
color: var(--text-secondary-color);
}
@@ -31,11 +31,11 @@
.changelog-list {
display: flex;
flex-direction: column;
gap: 1.5rem;
gap: 1.3125rem;
}
.release-item {
padding-bottom: 1rem;
padding-bottom: 0.875rem;
border-bottom: 1px solid var(--border-color);
&:last-child {
@@ -45,8 +45,8 @@
.release-title {
font-weight: 700;
font-size: 1.25rem;
padding-bottom: 0.5rem;
font-size: 1.0938rem;
padding-bottom: 0.4375rem;
margin: 0;
}
@@ -67,8 +67,8 @@
:host ::ng-deep & {
h1, h2, h3, h4, h5, h6 {
margin-top: 1.5rem;
margin-bottom: 0.75rem;
margin-top: 1.3125rem;
margin-bottom: 0.6563rem;
font-weight: 600;
line-height: 1.25;
color: var(--text-color);
@@ -80,38 +80,38 @@
h3 {
margin-top: 0;
font-size: 1.125rem;
font-size: var(--app-text-lg);
}
p {
margin-top: 0.75rem;
margin-bottom: 0.75rem;
margin-top: 0.6563rem;
margin-bottom: 0.6563rem;
}
ul, ol {
margin-top: 0.75rem;
margin-bottom: 0.75rem;
padding-left: 1.5rem;
margin-top: 0.6563rem;
margin-bottom: 0.6563rem;
padding-left: 1.3125rem;
}
li {
margin-top: 0.25rem;
margin-bottom: 0.25rem;
margin-top: 0.2188rem;
margin-bottom: 0.2188rem;
}
code {
font-size: 0.875em;
background: var(--ground-background);
padding: 0.125rem 0.375rem;
border-radius: 0.25rem;
padding: 0.1094rem 0.3281rem;
border-radius: 0.2188rem;
}
pre {
margin-top: 1rem;
margin-bottom: 1rem;
padding: 1rem;
margin-top: 0.875rem;
margin-bottom: 0.875rem;
padding: 0.875rem;
background: var(--ground-background);
border-radius: 0.5rem;
border-radius: 0.4375rem;
overflow-x: auto;
code {
@@ -130,8 +130,8 @@
}
blockquote {
margin: 1rem 0;
padding-left: 1rem;
margin: 0.875rem 0;
padding-left: 0.875rem;
border-left: 3px solid var(--border-color);
color: var(--text-secondary-color);
}
@@ -117,13 +117,6 @@ describe('LayoutService', () => {
expect(service.mobileDrawerOpen()).toBe(false);
});
it('updates the document root font size when the scale changes', () => {
service.scale.set(18);
TestBed.flushEffects();
expect(document.documentElement.style.fontSize).toBe('18px');
});
it('persists the collapsed state when toggled', () => {
expect(service.sidebarCollapsed()).toBe(false);
@@ -45,7 +45,6 @@ export class LayoutService {
private readonly router = inject(Router);
private readonly destroyRef = inject(DestroyRef);
readonly scale = signal(14);
readonly currentPath = signal(this.router.url.split('?')[0]);
readonly sidebarVisible = signal(true);
readonly mobileDrawerOpen = signal(false);
@@ -67,10 +66,6 @@ export class LayoutService {
private sidebarTransitionTimeoutId: ReturnType<typeof setTimeout> | undefined;
constructor() {
effect(() => {
this.changeScale(this.scale());
});
effect(() => {
const settings = this.userService?.currentUser()?.userSettings;
this._librarySort.set(normalizeSortPref(settings?.sidebarLibrarySorting, DEFAULT_LIBRARY_SORT));
@@ -187,10 +182,6 @@ export class LayoutService {
}, SIDEBAR_TRANSITION_MS);
}
private changeScale(value: number): void {
this.document.documentElement.style.fontSize = `${value}px`;
}
private updateSidebarSort(
target: WritableSignal<SortPref>,
key: SidebarSortPreferenceKey,
@@ -74,6 +74,99 @@ const overlaySurface = {
color: 'var(--color-text)',
};
const compactPrimeFontCss = `
.p-button:not(.p-button-sm):not(.p-button-lg),
.p-inputtext:not(.p-inputtext-sm):not(.p-inputtext-lg),
.p-textarea:not(.p-textarea-sm):not(.p-textarea-lg),
.p-select:not(.p-select-sm):not(.p-select-lg) .p-select-label,
.p-multiselect:not(.p-multiselect-sm):not(.p-multiselect-lg) .p-multiselect-label,
.p-cascadeselect:not(.p-cascadeselect-sm):not(.p-cascadeselect-lg) .p-cascadeselect-label,
.p-treeselect:not(.p-treeselect-sm):not(.p-treeselect-lg) .p-treeselect-label,
.p-autocomplete-input,
.p-autocomplete-input-multiple,
.p-togglebutton:not(.p-togglebutton-sm):not(.p-togglebutton-lg),
.p-inputchips-input-item input,
.p-terminal-prompt-value,
.p-datepicker-day-view,
.p-datepicker-time-picker span {
font-size: var(--app-text-base);
}
`;
const PRIME_REM_SCALE = 0.875;
function isDigit(value: string): boolean {
return value >= '0' && value <= '9';
}
function findRemNumberStart(value: string, remIndex: number): number | undefined {
let start = remIndex;
let digitCount = 0;
while (start > 0 && isDigit(value[start - 1])) {
start -= 1;
digitCount += 1;
}
if (start > 0 && value[start - 1] === '.') {
start -= 1;
while (start > 0 && isDigit(value[start - 1])) {
start -= 1;
digitCount += 1;
}
}
if (start > 0 && value[start - 1] === '-') {
start -= 1;
}
return digitCount > 0 ? start : undefined;
}
function scaleRemString(value: string): string {
let result = '';
let cursor = 0;
while (cursor < value.length) {
const remIndex = value.indexOf('rem', cursor);
if (remIndex === -1) {
return result + value.slice(cursor);
}
const numberStart = findRemNumberStart(value, remIndex);
if (numberStart === undefined) {
result += value.slice(cursor, remIndex + 3);
cursor = remIndex + 3;
continue;
}
const scaled = Number.parseFloat(
(Number(value.slice(numberStart, remIndex)) * PRIME_REM_SCALE).toFixed(4)
).toString();
result += `${value.slice(cursor, numberStart)}${scaled}rem`;
cursor = remIndex + 3;
}
return result;
}
function scalePrimeRems<T>(value: T): T {
if (typeof value === 'string') {
return scaleRemString(value) as T;
}
if (Array.isArray(value)) {
return value.map(scalePrimeRems) as T;
}
if (value && typeof value === 'object') {
return Object.fromEntries(
Object.entries(value).map(([key, entry]) => [key, scalePrimeRems(entry)])
) as T;
}
return value;
}
const AppPrimeBasePreset = scalePrimeRems(Aura);
function buildAppTokenPalette(prefix: 'primary' | 'surface', stops: readonly string[]): ColorPalette {
return Object.fromEntries(
stops.map((stop) => [stop, `var(--color-${prefix}-${stop})`])
@@ -107,7 +200,8 @@ function buildPrimePalettePreset(theme: ResolvedThemePalettes): object {
};
}
const AppPrimePreset = definePreset(Aura, {
const AppPrimePreset = definePreset(AppPrimeBasePreset, {
css: compactPrimeFontCss,
semantic: {
colorScheme: {
light: {