Skip to content

feat: getCSSVariable function to get css variable outside of react#521

Merged
Brentlok merged 1 commit into
mainfrom
getCSSVariable-outside-react
Apr 28, 2026
Merged

feat: getCSSVariable function to get css variable outside of react#521
Brentlok merged 1 commit into
mainfrom
getCSSVariable-outside-react

Conversation

@Brentlok

@Brentlok Brentlok commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

#406

Summary by CodeRabbit

  • New Features

    • Introduced a getCSSVariable API for direct programmatic access to CSS variables through the Uniwind configuration.
  • Improvements

    • Centralized CSS variable resolution logic and error handling for improved consistency across the library.

@coderabbitai

coderabbitai Bot commented Apr 28, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 981224c4-dbe7-472f-bcb9-18a0e39082c6

📥 Commits

Reviewing files that changed from the base of the PR and between 54ce71b and 6aa428a.

📒 Files selected for processing (4)
  • packages/uniwind/src/core/config/config.common.ts
  • packages/uniwind/src/hooks/useCSSVariable/index.ts
  • packages/uniwind/src/hooks/useCSSVariable/useCSSVariable.ts
  • packages/uniwind/tests/type-test/getCSSVariable.ts

📝 Walkthrough

Walkthrough

A new getCSSVariable API is extracted from the useCSSVariable hook and exposed both as a method on UniwindConfigBuilder and as a standalone function export. The hook is refactored to delegate variable resolution and warning behavior to this centralized helper, consolidating the logic that handles both single variable names and arrays of names.

Changes

Cohort / File(s) Summary
Config API Exposure
packages/uniwind/src/core/config/config.common.ts
Adds getCSSVariable property to UniwindConfigBuilder, exposing the newly extracted helper as a public API with scopedTheme: null.
Hook Refactoring & Exports
packages/uniwind/src/hooks/useCSSVariable/index.ts, packages/uniwind/src/hooks/useCSSVariable/useCSSVariable.ts
Extracts variable resolution logic into new getCSSVariable function; updates hook to call this helper for state initialization and updates; replaces non-exported UseCSSVariable type with exported GetCSSVariable type; restricts barrel export to only useCSSVariable named export.
Type Tests
packages/uniwind/tests/type-test/getCSSVariable.ts
Adds type-test module validating GetCSSVariable return types for single string, inline array, and variable array inputs against expected `string

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • fix: updateCSSVariable inside scoped theme #502: Modifies the same useCSSVariable module by refactoring array equality into a shared utility that the hook uses, creating code-level overlap with this PR's hook delegation changes.
  • feat: scoped theme #393: Introduces context-aware getVariable/getWebVariable logic and propagates UniwindContext through useCSSVariable, directly overlapping with this PR's extraction and delegation of variable retrieval.

Poem

🐰 A helper springs forth, clean and spry,
getCSSVariable takes its cry!
From hook extracted, now it's free,
A public API for all to see—
Refactored logic, types that gleam! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing a getCSSVariable function that enables retrieving CSS variables outside of React components, which is the core feature added across the modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch getCSSVariable-outside-react

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Brentlok Brentlok merged commit 0cbe527 into main Apr 28, 2026
2 checks passed
@Brentlok Brentlok deleted the getCSSVariable-outside-react branch April 28, 2026 09:13
@coderabbitai coderabbitai Bot mentioned this pull request May 5, 2026
@github-actions

github-actions Bot commented May 5, 2026

Copy link
Copy Markdown
Contributor

🚀 This pull request is included in v1.6.4. See Release v1.6.4 for release notes.

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.

1 participant