Skip to content

Fix: CSS - Support for styles that return CSSRule#147

Merged
github-actions[bot] merged 1 commit intomainfrom
with-css-fn
Feb 8, 2025
Merged

Fix: CSS - Support for styles that return CSSRule#147
github-actions[bot] merged 1 commit intomainfrom
with-css-fn

Conversation

@black7375
Copy link
Contributor

@black7375 black7375 commented Feb 8, 2025

Description

Support for styles that return CSSRule

Related Issue

Summary by CodeRabbit

  • New Features

    • Enhanced style transformation now supports both direct and dynamically computed styling, enabling more flexible and advanced appearance options.
  • Refactor

    • Streamlined the logic for processing style values to ensure consistent and accurate application of styles.

Additional context

Checklist

@changeset-bot
Copy link

changeset-bot bot commented Feb 8, 2025

⚠️ No Changeset found

Latest commit: 4013f04

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Feb 8, 2025

Walkthrough

The pull request refactors the style transformation process by unifying the handling of style values using a single variable, styleValue. The transform function now checks if a style is a function, calls it if necessary, and then evaluates the result for class names. Corresponding test cases were updated to expect objects conforming to the new CSSRule type. Additionally, the type definitions in the style-rule module have been adjusted to allow functions to return either ClassNames or CSSRule, thereby enhancing type safety in CSS rule processing.

Changes

File(s) Change Summary
packages/transform-to-vanilla/src/transform.ts Refactored the transform function to evaluate styles using a unified styleValue (calls functions when necessary) and updated tests to validate objects conforming to CSSRule.
packages/transform-to-vanilla/src/types/.../style-rule.ts Updated type definitions: modified ComplexCSSItem to return ClassNames or CSSRule and adjusted ComplexCSSRule’s function signature to ensure returned objects satisfy CSSRule.

Sequence Diagram(s)

sequenceDiagram
    participant T as Transform Function
    participant S as Style Input
    participant F as Function Evaluator
    participant C as ClassName Checker

    T->>S: Receive style item
    alt Style is a function
        T->>F: Invoke style function
        F-->>T: Return evaluated style (CSSRule or ClassNames)
    else Style is not a function
        T-->>T: Use style value directly
    end
    T->>C: Check if styleValue is a class name
    C-->>T: Return processed result
    T-->>T: Output transformed style
Loading

Possibly related PRs

Poem

In a meadow of code I happily hop,
Debugging styles until the bugs stop.
With CSSRule and functions in a blend so neat,
Each line of code makes my heart skip a beat.
Hoppin' along the rabbit trail of transformation cheer,
I celebrate these changes with a joyful ear!
🐇🎶 Happy coding all around!

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

yarn install v1.22.22
[1/4] Resolving packages...
error Couldn't find any versions for "eslint-config-custom" that matches "workspace:^"
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f021bef and 4013f04.

📒 Files selected for processing (2)
  • packages/transform-to-vanilla/src/transform.ts (3 hunks)
  • packages/transform-to-vanilla/src/types/style-rule.ts (3 hunks)
🔇 Additional comments (5)
packages/transform-to-vanilla/src/transform.ts (3)

23-28: LGTM! Clean refactoring of style value handling.

The consolidation of style value handling into a single variable improves code clarity and properly supports both ClassNames and CSSRule returns.


77-79: LGTM! Good test coverage for CSSRule returns.

The test case properly validates the new functionality with essential CSS properties and type safety.


81-85: LGTM! Proper test assertions with type safety.

The assertions correctly validate the expected output and maintain type safety using the satisfies keyword.

packages/transform-to-vanilla/src/types/style-rule.ts (2)

31-31: LGTM! Type definition properly extended.

The ComplexCSSItem type now correctly supports both ClassNames and CSSRule return types while maintaining backward compatibility.


549-551: LGTM! Comprehensive test coverage for type definitions.

The test cases thoroughly validate the type definitions with proper type assertions and cover essential use cases.

Also applies to: 580-582

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2025

Triggered from #147 by @​black7375.

Checking if we can fast forward main (f021bef) to with-css-fn (4013f04).

Target branch (main):

commit f021bef2fac5f4ad4aabd6779d4632ae90f019da (HEAD -> main, origin/main, origin/HEAD)
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Sat Feb 8 16:56:55 2025 +0000

    Chore(deps): Bump nanoid from 3.3.7 to 3.3.8 in the npm_and_yarn group
    
    Bumps the npm_and_yarn group with 1 update: [nanoid](https://github.com/ai/nanoid).
    
    
    Updates `nanoid` from 3.3.7 to 3.3.8
    - [Release notes](https://github.com/ai/nanoid/releases)
    - [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/ai/nanoid/compare/3.3.7...3.3.8)
    
    ---
    updated-dependencies:
    - dependency-name: nanoid
      dependency-type: indirect
      dependency-group: npm_and_yarn
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>

Pull request (with-css-fn):

commit 4013f04f09ca4efd43d7272caf6565128b0501ed (pull_request/with-css-fn)
Author: alstjr7375 <alstjr7375@daum.net>
Date:   Sun Feb 9 06:58:35 2025 +0900

    Fix: CSS - Support for styles that return CSSRule #114

It is possible to fast forward main (f021bef) to with-css-fn (4013f04). If you have write access to the target repository, you can add a comment with /fast-forward to fast forward main to with-css-fn.

@black7375
Copy link
Contributor Author

/fast-forward

@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2025

Triggered from #147 (comment) by @​black7375.

Trying to fast forward main (f021bef) to with-css-fn (4013f04).

Target branch (main):

commit f021bef2fac5f4ad4aabd6779d4632ae90f019da (HEAD -> main, origin/main, origin/HEAD)
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Sat Feb 8 16:56:55 2025 +0000

    Chore(deps): Bump nanoid from 3.3.7 to 3.3.8 in the npm_and_yarn group
    
    Bumps the npm_and_yarn group with 1 update: [nanoid](https://github.com/ai/nanoid).
    
    
    Updates `nanoid` from 3.3.7 to 3.3.8
    - [Release notes](https://github.com/ai/nanoid/releases)
    - [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/ai/nanoid/compare/3.3.7...3.3.8)
    
    ---
    updated-dependencies:
    - dependency-name: nanoid
      dependency-type: indirect
      dependency-group: npm_and_yarn
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>

Pull request (with-css-fn):

commit 4013f04f09ca4efd43d7272caf6565128b0501ed (pull_request/with-css-fn)
Author: alstjr7375 <alstjr7375@daum.net>
Date:   Sun Feb 9 06:58:35 2025 +0900

    Fix: CSS - Support for styles that return CSSRule #114

Fast forwarding main (f021bef) to with-css-fn (4013f04).

$ git push origin 4013f04f09ca4efd43d7272caf6565128b0501ed:main
To https://github.com/mincho-js/mincho.git
   f021bef..4013f04  4013f04f09ca4efd43d7272caf6565128b0501ed -> main

@github-actions github-actions bot merged commit 4013f04 into main Feb 8, 2025
7 checks passed
@github-actions github-actions bot deleted the with-css-fn branch February 8, 2025 22:07
@black7375 black7375 linked an issue Feb 8, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

With css()

1 participant