From 440caf4de0ca3466e443773d50d3e20f7a98bd2a Mon Sep 17 00:00:00 2001 From: Vixalie Date: Thu, 20 Mar 2025 11:20:14 +0800 Subject: [PATCH] refactor UI font size. --- src/Layout.module.css | 5 ++ src/Layout.tsx | 2 +- src/components.css | 52 +++++++------ src/components/PatternPreview.tsx | 2 +- .../pattern-editor/PatternHeader.tsx | 2 +- .../pattern-editor/PatternOverview.module.css | 5 +- src/theme.css | 6 +- src/utilities.css | 4 +- src/variables.css | 75 ++++++++++++++++++- 9 files changed, 121 insertions(+), 32 deletions(-) diff --git a/src/Layout.module.css b/src/Layout.module.css index b8999d9..a7b64c5 100644 --- a/src/Layout.module.css +++ b/src/Layout.module.css @@ -69,6 +69,11 @@ border-radius: calc(var(--border-radius) * 2); padding-block: calc(var(--spacing)); } + &.name { + font-size: var(--label-small-font-size); + line-height: var(--label-small-line-height); + font-weight: var(--label-small-font-weight); + } } &.inactive { color: var(--color-on-surface-variant); diff --git a/src/Layout.tsx b/src/Layout.tsx index 88d8980..73602cf 100644 --- a/src/Layout.tsx +++ b/src/Layout.tsx @@ -24,7 +24,7 @@ const FunctionLink: FC = ({ name, url, end, children }) => { } end={end}>
{children}
-
{name}
+
{name}
); }; diff --git a/src/components.css b/src/components.css index 08a6732..9252bad 100644 --- a/src/components.css +++ b/src/components.css @@ -23,33 +23,40 @@ } } - :is(h1, h2, h3, h4, h5, h6) { - font-weight: bold; - line-height: 1.2em; - } - h1 { - font-size: 2.6em; + font-size: 2rem; + line-height: 2.5rem; + font-weight: 400; } h2 { - font-size: 2em; + font-size: 1.75rem; + line-height: 2.25rem; + font-weight: 400; } h3 { - font-size: 1.8em; + font-size: 1.5rem; + line-height: 2rem; + font-weight: 400; } h4 { - font-size: 1.5em; + font-size: 1.375rem; + line-height: 1.75rem; + font-weight: 500; } h5 { - font-size: 1.2em; + font-size: 1rem; + line-height: 1.5rem; + font-weight: 500; } h6 { - font-size: 1em; + font-size: 0.875rem; + line-height: 1.25rem; + font-weight: 500; } .center { @@ -112,23 +119,22 @@ justify-content: center; align-items: center; gap: calc(var(--spacing) * 2); - font-size: calc(var(--font-size) * 1.2); - line-height: 1.3em; + font-size: var(--label-medium-font-size); + line-height: var(--label-medium-line-height); + font-weight: var(--label-medium-font-weight); color: var(--button-text); background-color: var(--button-surface); box-shadow: var(--elevation-0); cursor: pointer; - &.smaller { - font-size: calc(var(--font-size) * 0.8); - } &.small { - font-size: calc(var(--font-size) * 1); + font-size: var(--label-small-font-size); + line-height: var(--label-small-line-height); + font-weight: var(--label-small-font-weight); } &.large { - font-size: calc(var(--font-size) * 1.4); - } - &.larger { - font-size: calc(var(--font-size) * 1.6); + font-size: var(--label-large-font-size); + line-height: var(--label-large-line-height); + font-weight: var(--label-large-font-weight); } &:hover:not(:disabled) { color: var(--button-surface); @@ -456,7 +462,9 @@ border-top-left-radius: calc(var(--border-radius) * 2); border-top-right-radius: calc(var(--border-radius) * 2); padding: calc(var(--spacing)) calc(var(--spacing) * 2); - line-height: 1.5em; + font-size: var(--body-small-font-size); + line-height: var(--body-small-line-height); + font-weight: var(--body-small-font-weight); color: var(--color-on-surface); background-color: var(--color-surface-container-highest); &.error { diff --git a/src/components/PatternPreview.tsx b/src/components/PatternPreview.tsx index b0598ca..332c789 100644 --- a/src/components/PatternPreview.tsx +++ b/src/components/PatternPreview.tsx @@ -64,7 +64,7 @@ const PatternPreview: FC = () => { return (
-

Pattern Preview

+
Pattern Preview
diff --git a/src/page-components/pattern-editor/PatternHeader.tsx b/src/page-components/pattern-editor/PatternHeader.tsx index 8895b94..31d555b 100644 --- a/src/page-components/pattern-editor/PatternHeader.tsx +++ b/src/page-components/pattern-editor/PatternHeader.tsx @@ -18,7 +18,7 @@ const PatternHeader: FC = () => { return (