diff --git a/.changeset/configurable-content-font-size.md b/.changeset/configurable-content-font-size.md new file mode 100644 index 0000000000..6e12a975bb --- /dev/null +++ b/.changeset/configurable-content-font-size.md @@ -0,0 +1,11 @@ +--- +'@hyperdx/app': minor +--- + +feat: add a content font size preference + +Small text in the log/trace table was not adjustable without browser zoom, which +also shrinks the surrounding chrome. User preferences now carry a **Content font +size** setting (small / medium / large) that scales the search results table, +data tables, expanded row JSON, and chart axes, legends, and tooltips. Small is +the default and matches the previous sizes, so nothing changes until you opt in. diff --git a/packages/app/pages/_app.tsx b/packages/app/pages/_app.tsx index fb64f6fd68..3e6d401f32 100644 --- a/packages/app/pages/_app.tsx +++ b/packages/app/pages/_app.tsx @@ -33,6 +33,7 @@ import { NextApiConfigResponseData } from '@/types'; import { ConfirmProvider } from '@/useConfirm'; import { SystemColorSchemeScript, + useContentFontSize, useResolvedColorScheme, useUserPreferences, } from '@/useUserPreferences'; @@ -98,6 +99,8 @@ function AppContent({ const { userPreferences } = useUserPreferences(); const resolvedColorScheme = useResolvedColorScheme(); const { themeName } = useAppTheme(); + const { base: contentFontSize, compact: compactContentFontSize } = + useContentFontSize(); // ClickStack theme always uses Inter font - user preference is ignored // HyperDX theme allows user to select font preference @@ -115,6 +118,21 @@ function AppContent({ } }, [effectiveFont]); + useEffect(() => { + // Single write point for the content font size preference; tables and + // chart CSS read these vars (see styles/app.scss for the defaults). + if (typeof document !== 'undefined') { + document.documentElement.style.setProperty( + '--hdx-content-font-size', + `${contentFontSize}px`, + ); + document.documentElement.style.setProperty( + '--hdx-content-font-size-compact', + `${compactContentFontSize}px`, + ); + } + }, [contentFontSize, compactContentFontSize]); + const getLayout = Component.getLayout ?? (page => page); return ( diff --git a/packages/app/src/HDXMultiSeriesTableChart.module.scss b/packages/app/src/HDXMultiSeriesTableChart.module.scss index bd8559a884..f5e3eecc6f 100644 --- a/packages/app/src/HDXMultiSeriesTableChart.module.scss +++ b/packages/app/src/HDXMultiSeriesTableChart.module.scss @@ -4,6 +4,10 @@ // .rowButtons pattern from LogTable.module.scss (lines 156-172), // scoped down to a single icon. See HDX-4405. +.tableWrapper { + font-size: var(--hdx-content-font-size); +} + .tableHeader { // Always-on 1px separator between the sticky header and the rows. An // inset box-shadow rather than a border because the table sets diff --git a/packages/app/src/HDXMultiSeriesTableChart.tsx b/packages/app/src/HDXMultiSeriesTableChart.tsx index fb035d76ea..8211f473b7 100644 --- a/packages/app/src/HDXMultiSeriesTableChart.tsx +++ b/packages/app/src/HDXMultiSeriesTableChart.tsx @@ -408,7 +408,7 @@ export const Table = ({ return (
= 0.005 from 0. const MAX_AXIS_MANTISSA = 2; -/** Base width ceiling for a bare signed number - see MAX_AXIS_MANTISSA's comment. */ +/** + * Base width ceiling for a bare signed number - see MAX_AXIS_MANTISSA's + * comment. A character budget rather than a pixel one, which is why + * Y_AXIS_WIDTH scales with the content font size preference: the gutter has to + * grow with the tick font for this to keep holding at every setting. + */ const AXIS_CHAR_BUDGET = 5; // Flat, not suffix-length-scaled - IBM Plex Mono is monospace, so a longer @@ -1351,6 +1357,12 @@ export const MemoChart = memo(function MemoChart({ const _id = useId(); const id = _id.replace(/:/g, ''); + // The y-axis width budget is expressed in characters (see MAX_AXIS_MANTISSA), + // so it has to grow with the tick font or the widest labels clip. + const { compact: axisTickFontSize, scale: contentFontScale } = + useContentFontSize(); + const yAxisWidth = Math.round(Y_AXIS_WIDTH * contentFontScale); + // recharts sync group, scoped via context (see chartSync). const syncId = useChartSyncId(); @@ -1585,14 +1597,14 @@ export const MemoChart = memo(function MemoChart({ if (graphResults.length !== 1) return undefined; const drawableWidth = Math.max( 0, - containerWidth - Y_AXIS_WIDTH - SINGLE_POINT_BAR_RIGHT_PADDING, + containerWidth - yAxisWidth - SINGLE_POINT_BAR_RIGHT_PADDING, ); if (drawableWidth <= 0) return undefined; return Math.max( 1, Math.floor(drawableWidth * SINGLE_POINT_BAR_WIDTH_RATIO), ); - }, [displayType, graphResults.length, containerWidth]); + }, [displayType, graphResults.length, containerWidth, yAxisWidth]); const formatTime = useFormatTime(); const xTickFormatter = useCallback( @@ -1932,9 +1944,9 @@ export const MemoChart = memo(function MemoChart({ } return layoutAnnotations(coloredAnnotations, { domain: xAxisDomain, - plotWidth: Math.max(0, containerWidth - Y_AXIS_WIDTH), + plotWidth: Math.max(0, containerWidth - yAxisWidth), }); - }, [coloredAnnotations, xAxisDomain, containerWidth]); + }, [coloredAnnotations, xAxisDomain, containerWidth, yAxisWidth]); const [hoveredAnnotation, setHoveredAnnotation] = useState(null); @@ -1948,9 +1960,9 @@ export const MemoChart = memo(function MemoChart({ // Drawable width, so markers too close together share one label. Zero on // the first paint (before ResponsiveContainer measures), which the // renderer treats as "label everything". - plotWidth: Math.max(0, containerWidth - Y_AXIS_WIDTH), + plotWidth: Math.max(0, containerWidth - yAxisWidth), }); - }, [coloredAnnotations, xAxisDomain, containerWidth]); + }, [coloredAnnotations, xAxisDomain, containerWidth, yAxisWidth]); return (
diff --git a/packages/app/src/UserPreferencesModal.tsx b/packages/app/src/UserPreferencesModal.tsx index 1bb8e79674..e65df5d2f0 100644 --- a/packages/app/src/UserPreferencesModal.tsx +++ b/packages/app/src/UserPreferencesModal.tsx @@ -13,12 +13,17 @@ import { } from '@mantine/core'; import { IconFlask } from '@tabler/icons-react'; -import { OPTIONS_FONTS } from './config/fonts'; +import { + isContentFontSize, + OPTIONS_CONTENT_FONT_SIZE, + OPTIONS_FONTS, +} from './config/fonts'; import { useAppTheme } from './theme/ThemeProvider'; import { isValidThemeName, themes } from './theme'; import { DEFAULT_ROW_CLICK_ACTION, RowClickAction, + useContentFontSize, UserPreferences, useUserPreferences, } from './useUserPreferences'; @@ -72,6 +77,7 @@ export const UserPreferencesModal = ({ onClose: () => void; }) => { const { userPreferences, setUserPreference } = useUserPreferences(); + const { contentFontSize } = useContentFontSize(); const { themeName, setTheme, isDev } = useAppTheme(); return ( @@ -168,6 +174,23 @@ export const UserPreferencesModal = ({ /> + +