Skip to content

refactor: add fontVariables flag to control font CSS variable generation - #669

Merged
surajair merged 2 commits into
devfrom
make-font-settings-via-flag
Feb 4, 2026
Merged

surajair merged 2 commits into
devfrom
make-font-settings-via-flag

Conversation

@surajair

@surajair surajair commented Feb 4, 2026

Copy link
Copy Markdown
Collaborator

fix #668 668

  • Add optional fontVariables parameter to ChaiPageStyles component (defaults to false)
  • Update getChaiThemeCssVariables to accept object with theme and fontVariables flag
  • Add fontsInTheme feature flag to ChaiBuilderEditorProps
  • Conditionally render Typography section in ThemeConfigPanel based on fontsInTheme flag
  • Use dangerouslySetInnerHTML consistently for style tags
  • Update type imports to use ChaiTheme instead of ChaiBuilderThemeValues

- Add optional fontVariables parameter to ChaiPageStyles component (defaults to false)
- Update getChaiThemeCssVariables to accept object with theme and fontVariables flag
- Add fontsInTheme feature flag to ChaiBuilderEditorProps
- Conditionally render Typography section in ThemeConfigPanel based on fontsInTheme flag
- Use dangerouslySetInnerHTML consistently for style tags
- Update type imports to use ChaiTheme instead of ChaiBuilderThemeValues
Copilot AI review requested due to automatic review settings February 4, 2026 09:45
@vercel

vercel Bot commented Feb 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sdk Ready Ready Preview, Comment Feb 4, 2026 10:00am

Request Review

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Feb 4, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
sdk 4912ba6 Feb 04 2026, 10:01 AM

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 implements a feature flag system to control font CSS variable generation in theme configuration. The primary goal is to make font configuration opt-in (defaulting to false) to give users control over whether font CSS variables are included in the generated output.

Changes:

  • Added fontsInTheme flag to ChaiBuilderEditorProps to control font configuration UI visibility
  • Modified getChaiThemeCssVariables to accept an object parameter with theme and fontVariables properties
  • Updated type imports to use ChaiTheme instead of the deprecated ChaiBuilderThemeValues alias
  • Conditionally render Typography section in ThemeConfigPanel based on the fontsInTheme flag
  • Applied consistent use of dangerouslySetInnerHTML for style tag rendering

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/types/chaibuilder-editor-props.ts Adds fontsInTheme optional boolean flag to feature flags interface
src/routes/page-preview.tsx Updates to use new API signature with object parameter, passes fontVariables: true
src/routes/builder.tsx Enables fontsInTheme: true flag in demo builder configuration
src/core/components/sidepanels/panels/theme-configuration/ThemeConfigPanel.tsx Conditionally renders Typography section based on fontsInTheme flag
src/core/components/css-theme-var.tsx Updates type imports and hardcodes fontVariables: true when calling theme function
src/core/components/chaibuilder-editor.tsx Updates type import from ChaiBuilderThemeValues to ChaiTheme
src/core/components/canvas/static/chai-theme-helpers.ts Refactors getChaiThemeCssVariables to accept object with theme and fontVariables parameters
frameworks/nextjs/package/rsc/chai-page-styles.tsx Adds optional fontVariables parameter (defaults to false), updates to use new API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/routes/page-preview.tsx Resolved
Comment thread src/core/components/css-theme-var.tsx Resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 4, 2026 09:59
@surajair
surajair merged commit 20ae0ba into dev Feb 4, 2026
5 of 6 checks passed
@surajair
surajair deleted the make-font-settings-via-flag branch February 4, 2026 10:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +83 to 87
fontVariables &&
theme.fontFamily &&
Object.entries(theme.fontFamily)
.map(([key, value]) => `--font-${key}: ${getFontFamily(value)};`)
.join("\n ")

Copilot AI Feb 4, 2026

Copy link

Choose a reason for hiding this comment

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

When fontVariables is false, the expression will evaluate to false and be converted to the string "false" in the template literal, resulting in invalid CSS containing the literal text "false". The expression should return an empty string when the condition is not met. Consider using a ternary operator: fontVariables && theme.fontFamily ? Object.entries(theme.fontFamily).map(...).join(...) : ""

Suggested change
fontVariables &&
theme.fontFamily &&
Object.entries(theme.fontFamily)
.map(([key, value]) => `--font-${key}: ${getFontFamily(value)};`)
.join("\n ")
fontVariables && theme.fontFamily
? Object.entries(theme.fontFamily)
.map(([key, value]) => `--font-${key}: ${getFontFamily(value)};`)
.join("\n ")
: ""

Copilot uses AI. Check for mistakes.
theme: ChaiTheme;
fontVariables?: boolean;
}) => {
const chaiTheme = theme;

Copilot AI Feb 4, 2026

Copy link

Choose a reason for hiding this comment

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

The variable chaiTheme is assigned from theme parameter but serves no purpose. Consider removing this redundant assignment and using theme directly throughout the function.

Copilot uses AI. Check for mistakes.

This branch was successfully deployed

1 active deployment
Preview — 4912ba62 Deployed Feb 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make fonts config available via flag. Default to false

2 participants