Use ha-font-smoothing typography css tokens (#25364)

This commit is contained in:
Wendelin 2025-05-08 16:32:48 +02:00 committed by GitHub
parent b8026ccf46
commit 498f158253
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 47 additions and 17 deletions

View File

@ -1,4 +1,8 @@
import { haFontFamilyBody } from "../../src/resources/theme/typography.globals";
import {
haFontFamilyBody,
haFontSmoothing,
haMozOsxFontSmoothing,
} from "../../src/resources/theme/typography.globals";
import "./hassio-main";
import("../../src/resources/append-ha-style");
@ -7,8 +11,8 @@ const styleEl = document.createElement("style");
styleEl.textContent = `
body {
font-family: ${haFontFamilyBody};
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: ${haMozOsxFontSmoothing};
-webkit-font-smoothing: ${haFontSmoothing};
font-weight: 400;
margin: 0;
padding: 0;

View File

@ -14,6 +14,7 @@ export const hassioStyle = css`
margin-bottom: 8px;
font-family: var(--ha-font-family-body);
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
font-size: var(--ha-font-size-2xl);
font-weight: var(--ha-font-weight-normal);
line-height: var(--ha-line-height-condensed);

View File

@ -929,8 +929,8 @@ export class HaDataTable extends LitElement {
}
.mdc-data-table__content {
font-family: var(--ha-font-family-body);
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
-webkit-font-smoothing: var(--ha-font-smoothing);
font-size: 0.875rem;
line-height: 1.25rem;
font-weight: 400;
@ -1049,8 +1049,8 @@ export class HaDataTable extends LitElement {
.mdc-data-table__cell {
font-family: var(--ha-font-family-body);
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
-webkit-font-smoothing: var(--ha-font-smoothing);
font-size: 0.875rem;
line-height: 1.25rem;
font-weight: 400;
@ -1171,8 +1171,8 @@ export class HaDataTable extends LitElement {
.mdc-data-table__header-cell {
font-family: var(--ha-font-family-body);
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
-webkit-font-smoothing: var(--ha-font-smoothing);
font-size: 0.875rem;
line-height: 1.375rem;
font-weight: 500;

View File

@ -381,8 +381,8 @@ export class HaBaseTimeInput extends LitElement {
border-bottom-width: 1px;
}
label {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
-webkit-font-smoothing: var(--ha-font-smoothing);
font-family: var(
--mdc-typography-body2-font-family,
var(--mdc-typography-font-family, var(--ha-font-family-body))

View File

@ -68,7 +68,8 @@ export class HaSettingsRow extends LitElement {
--mdc-typography-body2-font-family,
var(--mdc-typography-font-family, var(--ha-font-family-body))
);
-webkit-font-smoothing: antialiased;
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
font-size: var(--mdc-typography-body2-font-size, 0.875rem);
font-weight: var(--mdc-typography-body2-font-weight, 400);
line-height: normal;

View File

@ -8,8 +8,8 @@ export const configFlowContentStyles = css`
padding: 0 24px;
padding-inline-start: 24px;
padding-inline-end: 24px;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
-webkit-font-smoothing: var(--ha-font-smoothing);
font-family: var(
--mdc-typography-headline6-font-family,
var(--mdc-typography-font-family, var(--ha-font-family-body))

View File

@ -27,6 +27,7 @@ export class HuiNotificationItemTemplate extends LitElement {
ha-card .header {
font-family: var(--ha-font-family-body);
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
font-size: var(--ha-font-size-2xl);
font-weight: var(--ha-font-weight-normal);
line-height: var(--ha-line-height-condensed);

View File

@ -1543,6 +1543,7 @@ export class HaConfigDevicePage extends LitElement {
margin: 0;
font-family: var(--ha-font-family-body);
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
font-size: var(--ha-font-size-2xl);
font-weight: var(--ha-font-weight-normal);
line-height: var(--ha-line-height-condensed);

View File

@ -63,6 +63,7 @@ export class HaConfigSection extends LitElement {
.header {
font-family: var(--ha-font-family-body);
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
font-size: var(--ha-font-size-2xl);
font-weight: var(--ha-font-weight-normal);
line-height: var(--ha-line-height-condensed);
@ -76,6 +77,7 @@ export class HaConfigSection extends LitElement {
.intro {
font-family: var(--ha-font-family-body);
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
font-weight: var(--ha-font-weight-normal);
line-height: var(--ha-line-height-normal);
width: 100%;

View File

@ -168,6 +168,7 @@ export class ZHAAddGroupPage extends LitElement {
.header {
font-family: var(--ha-font-family-body);
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
font-size: var(--ha-font-size-4xl);
font-weight: var(--ha-font-weight-normal);
line-height: var(--ha-line-height-condensed);

View File

@ -295,6 +295,7 @@ export class ZHAGroupPage extends LitElement {
.header {
font-family: var(--ha-font-family-body);
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
font-size: var(--ha-font-size-4xl);
font-weight: var(--ha-font-weight-normal);
line-height: var(--ha-line-height-condensed);

View File

@ -196,7 +196,8 @@ class DialogExposeEntity extends LitElement {
.header {
margin: 0;
pointer-events: auto;
-webkit-font-smoothing: antialiased;
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
font-weight: inherit;
font-size: inherit;
box-sizing: border-box;

View File

@ -323,7 +323,8 @@ ${type === "object"
.rendered {
font-family: var(--ha-font-family-code);
-webkit-font-smoothing: antialiased;
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
clear: both;
white-space: pre-wrap;
background-color: var(--secondary-background-color);

View File

@ -180,6 +180,7 @@ class HuiPlantStatusCard extends LitElement implements LovelaceCard {
.header {
font-family: var(--ha-font-family-body);
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
font-size: var(--ha-font-size-2xl);
font-weight: var(--ha-font-weight-normal);
line-height: var(--ha-line-height-condensed);

View File

@ -18,6 +18,7 @@ export const haStyle = css`
:host {
font-family: var(--ha-font-family-body);
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
font-size: var(--ha-font-size-m);
font-weight: var(--ha-font-weight-normal);
line-height: var(--ha-line-height-normal);
@ -36,6 +37,7 @@ export const haStyle = css`
h1 {
font-family: var(--ha-font-family-heading);
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
font-size: var(--ha-font-size-2xl);
font-weight: var(--ha-font-weight-normal);
line-height: var(--ha-line-height-condensed);
@ -44,6 +46,7 @@ export const haStyle = css`
h2 {
font-family: var(--ha-font-family-body);
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@ -55,6 +58,7 @@ export const haStyle = css`
h3 {
font-family: var(--ha-font-family-body);
-webkit-font-smoothing: var(--ha-font-smoothing);
-moz-osx-font-smoothing: var(--ha-moz-osx-font-smoothing);
font-size: var(--ha-font-size-l);
font-weight: var(--ha-font-weight-normal);
line-height: var(--ha-line-height-normal);

View File

@ -37,6 +37,7 @@ export const typographyStyles = css`
--ha-line-height-expanded: 2;
--ha-font-smoothing: antialiased;
--ha-moz-osx-font-smoothing: grayscale;
}
`;
@ -44,5 +45,15 @@ export const typographyDerivedVariables = extractDerivedVars(typographyStyles);
export const haFontFamilyBody = extractVar(
typographyStyles,
"font-family-body"
"ha-font-family-body"
);
export const haFontSmoothing = extractVar(
typographyStyles,
"ha-font-smoothing"
);
export const haMozOsxFontSmoothing = extractVar(
typographyStyles,
"ha-moz-osx-font-smoothing"
);