Skip to content

Commit e1e539f

Browse files
committed
fix: add metricValueFontSize/Weight to StreamlitTheme and extraction
- Add properties to StreamlitTheme interface (component-v2-lib) - Add extraction in extractComponentsV2Theme for Components V2 support - Add mock values to theme.test.ts - Add negative value tests for metricValueFontSize validation
1 parent a940689 commit e1e539f

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

frontend/component-v2-lib/src/theme.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ export interface StreamlitTheme {
107107
greenTextColor: string
108108
violetTextColor: string
109109
grayTextColor: string
110+
111+
// Metric value styling
112+
metricValueFontSize: number | null
113+
metricValueFontWeight: number | null
110114
}
111115

112116
/**

frontend/lib/src/components/widgets/BidiComponent/utils/theme.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ describe("BidiComponent/utils/theme", () => {
101101
greenTextColor: "#00ff00",
102102
violetTextColor: "#aa00ff",
103103
grayTextColor: "#888888",
104+
105+
metricValueFontSize: null,
106+
metricValueFontWeight: null,
104107
...overrides,
105108
})
106109

frontend/lib/src/components/widgets/BidiComponent/utils/theme.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,8 @@ export const extractComponentsV2Theme = (
179179
greenTextColor: theme.colors.greenTextColor,
180180
violetTextColor: theme.colors.violetTextColor,
181181
grayTextColor: theme.colors.grayTextColor,
182+
183+
metricValueFontSize: theme.metricValueFontSize ?? null,
184+
metricValueFontWeight: theme.metricValueFontWeight ?? null,
182185
}
183186
}

frontend/lib/src/theme/utils.test.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3175,15 +3175,18 @@ describe("createEmotionTheme", () => {
31753175
expect(theme.metricValueFontSize).toBeUndefined()
31763176
})
31773177

3178-
it("does not set metricValueFontSize if value is not > 0", () => {
3179-
const themeInput: Partial<CustomThemeConfig> = {
3180-
metricValueFontSize: 0,
3181-
}
3178+
it.each([0, -10, -100])(
3179+
"does not set metricValueFontSize if value is not > 0: %s",
3180+
metricValueFontSize => {
3181+
const themeInput: Partial<CustomThemeConfig> = {
3182+
metricValueFontSize,
3183+
}
31823184

3183-
const theme = createEmotionTheme(themeInput)
3185+
const theme = createEmotionTheme(themeInput)
31843186

3185-
expect(theme.metricValueFontSize).toBeUndefined()
3186-
})
3187+
expect(theme.metricValueFontSize).toBeUndefined()
3188+
}
3189+
)
31873190

31883191
it("uses metricValueFontWeight when configured", () => {
31893192
const themeInput: Partial<CustomThemeConfig> = {

0 commit comments

Comments
 (0)