Repository navigation
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
sdk | c9fa184 | Feb 05 2026, 04:48 AM |
There was a problem hiding this comment.
Pull request overview
This PR adjusts getChaiThemeCssVariables so it generates correct CSS variable strings instead of accidentally embedding boolean values when theme data is missing or optional flags are disabled.
Changes:
- Wrap font-family variable generation in a ternary so that when
fontVariablesis false ortheme.fontFamilyis absent, an empty string is emitted instead of a boolean. - Wrap color variable generation for both
:rootand.darkthemes in ternaries so missingchaiTheme.colorsno longer results infalse/undefinedbeing stringified into the CSS.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot add unit tests |
…comprehensive tests Co-authored-by: surajair <9153560+surajair@users.noreply.github.com>
fix: prevent undefined/false literals in CSS output from getChaiThemeCssVariables
…orrect-variables-code
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .join("\n ") | ||
| chaiTheme.colors | ||
| ? Object.entries(chaiTheme.colors) | ||
| .map(([key, value]) => `--${key}: ${hexToHSL(value[1])};`) |
There was a problem hiding this comment.
The implementation accesses value[1] to get the dark theme color, but there's no check to ensure that the second element exists in the color array. If a color tuple only contains one element (e.g., primary: ["#3b82f6"]), this would pass undefined to hexToHSL(), which would likely cause a runtime error.
Consider adding a check before accessing value[1], or falling back to value[0] if the dark theme color is not provided. For example: hexToHSL(value[1] || value[0]).
| .map(([key, value]) => `--${key}: ${hexToHSL(value[1])};`) | |
| .map(([key, value]) => `--${key}: ${hexToHSL(value[1] || value[0])};`) |
| it("should handle partial colors (missing dark theme) gracefully", () => { | ||
| const theme: ChaiTheme = { | ||
| colors: { | ||
| primary: ["#3b82f6", "#1d4ed8"], | ||
| }, | ||
| }; | ||
|
|
||
| const result = getChaiThemeCssVariables({ theme }); | ||
|
|
||
| // Should generate both light and dark sections | ||
| expect(result).toContain(":root"); | ||
| expect(result).toContain(".dark"); | ||
| // Should contain color variables in both sections | ||
| expect(result).toMatch(/--primary:\s*\d+\s+\d+%\s+\d+%;/); | ||
| }); |
There was a problem hiding this comment.
The test name says "partial colors (missing dark theme)" but the test data includes both light and dark colors in the tuple: primary: ["#3b82f6", "#1d4ed8"]. This test doesn't actually verify the behavior when the dark theme color is missing.
Consider either:
- Renaming the test to accurately reflect what it tests (e.g., "should handle theme with limited color palette")
- Modifying the test data to actually test the missing dark theme scenario (e.g.,
primary: ["#3b82f6"]), though this would likely expose the bug mentioned in the implementation wherevalue[1]is accessed without checking if it exists.
fix #673