mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Align font sizes with production baseline
Signed-off-by: kenny lopez <klopez4212@gmail.com>
This commit is contained in:
@@ -32,7 +32,7 @@ test("persists and applies the selected font size across the app", () => {
|
||||
assert.equal(preference.getFontSize(), "smaller");
|
||||
assert.equal(values.get(preference.FONT_SIZE_STORAGE_KEY), "smaller");
|
||||
assert.equal(attributes.get("data-font-size"), "smaller");
|
||||
assert.equal(style.fontSize, "15px");
|
||||
assert.equal(style.fontSize, "16px");
|
||||
});
|
||||
|
||||
test("previews a font size without changing the saved preference", () => {
|
||||
@@ -42,11 +42,11 @@ test("previews a font size without changing the saved preference", () => {
|
||||
assert.equal(preference.getFontSize(), "smaller");
|
||||
assert.equal(values.get(preference.FONT_SIZE_STORAGE_KEY), "smaller");
|
||||
assert.equal(attributes.get("data-font-size"), "larger");
|
||||
assert.equal(style.fontSize, "18.7px");
|
||||
assert.equal(style.fontSize, "20.114286px");
|
||||
|
||||
preference.previewFontSize(null);
|
||||
assert.equal(attributes.get("data-font-size"), "smaller");
|
||||
assert.equal(style.fontSize, "16.5px");
|
||||
assert.equal(style.fontSize, "17.6px");
|
||||
});
|
||||
|
||||
test("initializes from the stored font size", () => {
|
||||
@@ -55,5 +55,5 @@ test("initializes from the stored font size", () => {
|
||||
preference.initializeFontSizePreference();
|
||||
assert.equal(preference.getFontSize(), "larger");
|
||||
assert.equal(attributes.get("data-font-size"), "larger");
|
||||
assert.equal(style.fontSize, "17px");
|
||||
assert.equal(style.fontSize, "18.285714px");
|
||||
});
|
||||
|
||||
@@ -6,10 +6,14 @@ export type FontSize = "smaller" | "default" | "larger";
|
||||
export const FONT_SIZE_STORAGE_KEY = "buzz.appearance.fontSize";
|
||||
export const DEFAULT_FONT_SIZE: FontSize = "default";
|
||||
|
||||
/**
|
||||
* Root sizes that map Tailwind's production `text-sm` size (0.875rem) to the
|
||||
* three app-wide 14px, 15px, and 16px steps.
|
||||
*/
|
||||
const BASE_FONT_SIZE_PX: Record<FontSize, number> = {
|
||||
smaller: 15,
|
||||
default: 16,
|
||||
larger: 17,
|
||||
smaller: 14 / 0.875,
|
||||
default: 15 / 0.875,
|
||||
larger: 16 / 0.875,
|
||||
};
|
||||
|
||||
const listeners = new Set<() => void>();
|
||||
@@ -33,7 +37,9 @@ function readStoredFontSize(): FontSize {
|
||||
}
|
||||
|
||||
function rootFontSizePx(size: FontSize): number {
|
||||
return Math.round(BASE_FONT_SIZE_PX[size] * textZoomFactor * 1_000) / 1_000;
|
||||
return (
|
||||
Math.round(BASE_FONT_SIZE_PX[size] * textZoomFactor * 1_000_000) / 1_000_000
|
||||
);
|
||||
}
|
||||
|
||||
function applyFontSize(size: FontSize): void {
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
* Inbox, and the composer. The app-wide Font size preference and Cmd +/-
|
||||
* scale these rem values; Conversation density overrides only spacing.
|
||||
*/
|
||||
--conversation-message-font-size: 0.9375rem;
|
||||
--conversation-message-font-size: 0.875rem;
|
||||
--conversation-message-line-height: 1.25rem;
|
||||
--conversation-author-line-height: 1.0625rem;
|
||||
--conversation-author-line-height: 1rem;
|
||||
--conversation-body-gap: 0.125rem;
|
||||
--conversation-row-padding-block: 0.375rem;
|
||||
--conversation-paragraph-gap: 0.5rem;
|
||||
--conversation-list-item-gap: 0.375rem;
|
||||
--conversation-timestamp-font-size: 0.6875rem;
|
||||
--conversation-timestamp-font-size: 0.75rem;
|
||||
--conversation-timestamp-line-height: 1rem;
|
||||
--background: 220 23.08% 94.9%;
|
||||
--foreground: 234 16.02% 35.49%;
|
||||
|
||||
Reference in New Issue
Block a user