Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mayagbarnes
Copy link
Collaborator

@mayagbarnes mayagbarnes commented Jun 4, 2025

Describe your changes

Adding a config option codeFontSize for both [theme] & [theme.sidebar] that controls the font size for code - displayed with st.code, st.json, st.help, and inline.

  • Note: inline code will continue to be set to default of "0.75em" and not adjusted based on the provided codeFontSize
  • The st.help member's table styling was also updated in this PR (default from theme.fontSizes.twoSm - 12px to theme.fontSizes.sm - 14px) thus why all st.help snaps updated

Testing Plan

  • Unit Tests (JS and/or Python): ✅ Added
  • E2E Tests: ✅ Added
  • Manual Testing: ✅

@mayagbarnes mayagbarnes added security-assessment-completed Security assessment has been completed for PR change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Jun 4, 2025
@snyk-io
Copy link
Contributor

snyk-io bot commented Jun 4, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions
Copy link
Contributor

github-actions bot commented Jun 4, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-11508/streamlit-1.45.1-py3-none-any.whl
🕹️ Preview app pr-11508.streamlit.app (☁️ Deploy here if not accessible)

@github-actions
Copy link
Contributor

github-actions bot commented Jun 4, 2025

📈 Frontend coverage change detected

The frontend unit test (vitest) coverage has increased by 0.0100%

  • Current PR: 85.7800% (42714 lines, 6070 missed)
  • Latest develop: 85.7700% (42663 lines, 6070 missed)

✅ Coverage change is within normal range.

📊 View detailed coverage comparison

@mayagbarnes mayagbarnes marked this pull request as ready for review June 6, 2025 10:55
@mayagbarnes mayagbarnes requested a review from a team as a code owner June 6, 2025 10:55
@lukasmasuch lukasmasuch requested a review from Copilot June 7, 2025 08:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new theming configuration option, codeFontSize, to control the font size of code blocks and inline code across various components. Key changes include:

  • Adding the codeFontSize field in backend proto definitions and configuration options.
  • Updating tests, theme utilities, and styled-components to apply the new codeFontSize.
  • Enhancing the parsing and calculation functions to convert codeFontSize values for inline code scaling.

Reviewed Changes

Copilot reviewed 44 out of 44 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
proto/streamlit/proto/NewSession.proto Added new optional string field for code_font_size and updated next ID.
lib/tests/streamlit/runtime/app_session_test.py Updated test mocks to include the new codeFontSize option.
lib/tests/streamlit/proto_compatibility_test.py Included code_font_size in proto compatibility tests.
lib/tests/streamlit/config_test.py Added tests for theme.codeFontSize and theme.sidebar.codeFontSize options.
lib/streamlit/config.py Registers codeFontSize via _create_theme_options with a description.
frontend/lib/src/theme/utils.ts Added parseFontSize, calculateInlineCodeFontSize, and integration in createEmotionTheme.
frontend/lib/src/theme/primitives/typography.ts Set default typography values for codeFontSize and inlineCodeFontSize.
Various styled-components and e2e tests Updated components and tests to use codeFontSize for code styling.
Comments suppressed due to low confidence (1)

lib/streamlit/config.py:1177

  • [nitpick] The description for codeFontSize states that the value is in pixels, yet the default typography value uses rem. It would be helpful to clarify whether codeFontSize is expected as a pixel or rem value to avoid unit inconsistencies.
_create_theme_options("codeFontSize", categories=["theme", CustomThemeCategories.SIDEBAR],

Copy link
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 but wondering if we also should also make the inline code size 15% smaller as it's done in the default theme (0.875rem vs 0.75em). But probably depends if it still looks good by using the same calculated value

@mayagbarnes
Copy link
Collaborator Author

Per product, keeping the inline code as "0.75em" instead of adjusting based on codeFontSize

@mayagbarnes mayagbarnes merged commit 6f3de0d into develop Jun 17, 2025
39 of 40 checks passed
@mayagbarnes mayagbarnes deleted the codeFontSize branch June 17, 2025 06:56
lukasmasuch pushed a commit that referenced this pull request Jun 17, 2025
Adding a config option `codeFontSize` for both `[theme]` & `[theme.sidebar]` that controls the font size for code - displayed with `st.code`, `st.json`, `st.help`, and inline.
* **Note: inline code will continue to be set to default of `"0.75em"`** and not adjusted based on the provided `codeFontSize`
* The `st.help` member's table styling was also updated in this PR (default from `theme.fontSizes.twoSm` - `12px` to `theme.fontSizes.sm` -`14px`) thus why all `st.help` snaps updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants