Repository: streamlit/streamlit
File: frontend/lib/src/theme/utils.ts (TypeScript)

Code before:
    shadows,
    ...(() => {
      if (!metricValueFontSize) return {}

      // Use parseFontSize for format validation
      const parsedSize = parseFontSize(
        "metricValueFontSize",
        metricValueFontSize,
        inSidebar
      )
      if (!parsedSize) return {}

      // Additional validation: must be greater than 0
      const numericValue = parseFloat(parsedSize)
      if (numericValue <= 0) {
        LOG.warn(
          `Invalid metricValueFontSize: ${metricValueFontSize} in theme. The metricValueFontSize must be greater than 0. Falling back to default metricValueFontSize.`
        )
        return {}
      }

      return { metricValueFontSize: parsedSize }
    })(),
    ...(metricValueFontWeight &&
    metricValueFontWeight >= 100 &&
    metricValueFontWeight <= 900
      ? { metricValueFontWeight }
      : {}),
  }
}

export const toThemeInput = (
  theme: EmotionTheme
): Partial<CustomThemeConfig> => {
  const { colors } = theme
  return {
    primaryColor: colors.primary,
    backgroundColor: colors.bgColor,
    secondaryBackgroundColor: colors.secondaryBg,
    textColor: colors.bodyText,
    bodyFont: theme.genericFonts.bodyFont,
  }
}

export type ExportedTheme = {
  base: string
  primaryColor: string
  backgroundColor: string
  secondaryBackgroundColor: string
  textColor: string
  bodyFont: string

Review comment (suggestion):
I think there is a good suggestion in the AI review, to make this add a log statement similar to `metricValueFontSize` above. 

```
...(metricValueFontWeight
  ? metricValueFontWeight >= 100 && metricValueFontWeight <= 900
    ? { metricValueFontWeight }
    : (LOG.warn(`Invalid metricValueFontWeight: ${metricValueFontWeight}. Must be between 100 and 900.`), {})
  : {}),
```

Code after:
    shadows,
    ...(() => {
      if (!metricValueFontSize) return {}

      // Use parseFontSize for format validation
      const parsedSize = parseFontSize(
        "metricValueFontSize",
        metricValueFontSize,
        inSidebar
      )
      if (!parsedSize) return {}

      // Additional validation: must be greater than 0
      const numericValue = parseFloat(parsedSize)
      if (numericValue <= 0) {
        LOG.warn(
          `Invalid metricValueFontSize: ${metricValueFontSize} in theme. The metricValueFontSize must be greater than 0. Falling back to default metricValueFontSize.`
        )
        return {}
      }

      return { metricValueFontSize: parsedSize }
    })(),
    ...(metricValueFontWeight
      ? metricValueFontWeight >= 100 && metricValueFontWeight <= 900
        ? { metricValueFontWeight }
        : (LOG.warn(
            `Invalid metricValueFontWeight: ${metricValueFontWeight}. Must be between 100 and 900.`
          ),
          {})
      : {}),
  }
}

export const toThemeInput = (
  theme: EmotionTheme
): Partial<CustomThemeConfig> => {
  const { colors } = theme
  return {
    primaryColor: colors.primary,
    backgroundColor: colors.bgColor,
    secondaryBackgroundColor: colors.secondaryBg,
    textColor: colors.bodyText,
    bodyFont: theme.genericFonts.bodyFont,
  }
}

export type ExportedTheme = {
  base: string
  primaryColor: string
  backgroundColor: string