fix(widgets): increase short stat density
This commit is contained in:
1 parent
a7a6cb6e07
commit
e161c8c512
5 files changed
+21
-16
No files matched your search
@@ -58,8 +58,8 @@ const statLabelClassByLayout = {
|
|||||||
|
|
||||||
const statValueClassByLayout = {
|
const statValueClassByLayout = {
|
||||||
default: "",
|
default: "",
|
||||||
short: classes.statValueShort,
|
short: "",
|
||||||
narrowShort: `${classes.statValueShort} ${classes.statValueNarrowShort}`,
|
narrowShort: classes.statValueNarrowShort,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
const COMPACT_SINGLE_COLUMN_BREAKPOINT = 220;
|
const COMPACT_SINGLE_COLUMN_BREAKPOINT = 220;
|
||||||
|
|||||||
@@ -141,13 +141,9 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
.statValueShort {
|
|
||||||
font-size: calc(12px * var(--board-canvas-ui-scale, 1));
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.statValueNarrowShort {
|
.statValueNarrowShort {
|
||||||
font-size: calc(11px * var(--board-canvas-ui-scale, 1));
|
font-size: calc(11px * var(--board-canvas-ui-scale, 1));
|
||||||
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.emptyState {
|
.emptyState {
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
const SHORT_HEIGHT_BREAKPOINT = 120;
|
const SHORT_HEIGHT_BREAKPOINT = 120;
|
||||||
const NARROW_SHORT_WIDTH_BREAKPOINT = 120;
|
const NARROW_SHORT_WIDTH_BREAKPOINT = 120;
|
||||||
const SHORT_ICON_SIZE = 14;
|
|
||||||
const NARROW_SHORT_ICON_SIZE = 12;
|
const NARROW_SHORT_ICON_SIZE = 12;
|
||||||
|
const SHORT_GRID_HORIZONTAL_INSET = 8;
|
||||||
|
const SHORT_GRID_GAP = 2;
|
||||||
|
const SHORT_ICON_WIDTH_RATIO = 0.44;
|
||||||
|
const SHORT_ICON_SIZE_CAP = 40;
|
||||||
|
|
||||||
export type CompactStatLayoutState = "default" | "short" | "narrowShort";
|
export type CompactStatLayoutState = "default" | "short" | "narrowShort";
|
||||||
|
|
||||||
@@ -48,6 +51,16 @@ export function getCompactStatLayout({
|
|||||||
return {
|
return {
|
||||||
state: "short",
|
state: "short",
|
||||||
columns: Math.max(visibleCount, 1),
|
columns: Math.max(visibleCount, 1),
|
||||||
iconSize: SHORT_ICON_SIZE,
|
iconSize: getShortIconSize(width, visibleCount, defaultIconSize),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getShortIconSize(width: number, visibleCount: number, defaultIconSize: number): number {
|
||||||
|
const statCount = Math.max(visibleCount, 1);
|
||||||
|
const totalGridGap = Math.max(statCount - 1, 0) * SHORT_GRID_GAP;
|
||||||
|
const availableWidth = Math.max(width - SHORT_GRID_HORIZONTAL_INSET - totalGridGap, 0);
|
||||||
|
const availableWidthPerStat = availableWidth / statCount;
|
||||||
|
const proportionalIconSize = Math.round(availableWidthPerStat * SHORT_ICON_WIDTH_RATIO);
|
||||||
|
const cappedIconSize = Math.min(proportionalIconSize, SHORT_ICON_SIZE_CAP);
|
||||||
|
return Math.max(defaultIconSize, cappedIconSize);
|
||||||
|
}
|
||||||
@@ -173,13 +173,9 @@
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.statValueShort {
|
|
||||||
font-size: calc(12px * var(--board-canvas-ui-scale, 1));
|
|
||||||
line-height: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.statValueNarrowShort {
|
.statValueNarrowShort {
|
||||||
font-size: calc(11px * var(--board-canvas-ui-scale, 1));
|
font-size: calc(11px * var(--board-canvas-ui-scale, 1));
|
||||||
|
line-height: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.emptyState {
|
.emptyState {
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ const statLabelClassByLayout = {
|
|||||||
|
|
||||||
const statValueClassByLayout = {
|
const statValueClassByLayout = {
|
||||||
default: "",
|
default: "",
|
||||||
short: classes.statValueShort,
|
short: "",
|
||||||
narrowShort: `${classes.statValueShort} ${classes.statValueNarrowShort}`,
|
narrowShort: classes.statValueNarrowShort,
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
const ringSizeByWidth = [
|
const ringSizeByWidth = [
|
||||||
|
|||||||
Reference in new issue
Block a user