Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing customRootClass issue #619 #620 #648

Merged
merged 27 commits into from
Dec 15, 2024

Conversation

jindaljyoti
Copy link
Contributor

@jindaljyoti jindaljyoti commented Dec 15, 2024

Add the new format customRootClass for code component and fix the inconsistent use of class prefix in code.scss file.

Summary by CodeRabbit

  • New Features

    • Introduced a new optional property for custom styling in the Code component.
  • Style Updates

    • Updated the CSS class name for the code component to enhance styling consistency.

Copy link
Contributor

coderabbitai bot commented Dec 15, 2024

Walkthrough

The pull request introduces a new optional customRootClass property to the Code component, enhancing its styling flexibility. The changes modify both the TypeScript component in src/components/ui/Code/Code.tsx and the corresponding SCSS stylesheet in styles/themes/components/code.scss. The component now allows users to pass a custom class name, which is integrated using a dynamic class generation approach. The CSS class name is also updated from .rui-code-root to .rad-ui-code.

Changes

File Change Summary
src/components/ui/Code/Code.tsx - Added customRootClass optional prop to CodeProps type
- Updated component signature to include customRootClass with default empty string
- Implemented dynamic class generation using customClassSwitcher
styles/themes/components/code.scss - Renamed CSS class from .rui-code-root to .rad-ui-code
- Retained existing style properties

Possibly related issues

Possibly related PRs

  • Util classname 1 #616: Introduces clsx utility for class name management, which is conceptually similar to the class generation approach in this PR

Poem

🐰 A code component's style, now free to roam
With custom classes finding its new home
From rui to rad, a naming dance
Flexibility springs with just one glance
Rabbit's coding magic, smooth and bright! 🎨

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. This feature will be included in our Pro Plan when released.


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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/components/ui/Code/Code.tsx (2)

9-11: Add JSDoc documentation for the new prop.

Consider adding documentation to explain the purpose and usage of the customRootClass prop.

 export type CodeProps= {
     children: React.ReactNode;
+    /** Custom class name to override the root element's default class.
+     * @example 'my-custom-code-class'
+     */
     customRootClass?: string;
 }

13-13: Fix spacing around the assignment operator.

Address the ESLint error by adding spaces around the = operator.

-const Code = ({ children, customRootClass='' }: CodeProps) => {
+const Code = ({ children, customRootClass = '' }: CodeProps) => {
🧰 Tools
🪛 eslint

[error] 13-13: Operator '=' must be spaced.

(space-infix-ops)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0c3b53d and 2e19a5e.

📒 Files selected for processing (2)
  • src/components/ui/Code/Code.tsx (1 hunks)
  • styles/themes/components/code.scss (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • styles/themes/components/code.scss
🧰 Additional context used
🪛 eslint
src/components/ui/Code/Code.tsx

[error] 13-13: Operator '=' must be spaced.

(space-infix-ops)

🔇 Additional comments (2)
src/components/ui/Code/Code.tsx (2)

4-6: LGTM! Clean import and constant declaration.

The new import and constant follow good practices with proper naming conventions.


14-18: Verify customClassSwitcher implementation and usage.

The implementation looks correct, but let's verify the customClassSwitcher utility's behavior and its usage across the codebase.

✅ Verification successful

Let me gather more information about the usage patterns with a different approach.


Let me check the actual implementation of the customClassSwitcher function to complete the verification.


customClassSwitcher implementation and usage is correct

The utility is properly implemented and consistently used across the component library. It:

  • Returns custom class if provided
  • Falls back to generating a standardized class name with 'rad-ui' prefix
  • Has proper test coverage
  • Is used consistently in all UI components following the same pattern
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify customClassSwitcher implementation and usage pattern

# Check customClassSwitcher implementation
echo "Checking customClassSwitcher implementation:"
rg -A 5 "export.*customClassSwitcher"

# Check consistent usage pattern across components
echo "Checking usage pattern across components:"
ast-grep --pattern 'const $rootClass = customClassSwitcher($customClass, $componentName)'

Length of output: 803


Script:

#!/bin/bash
# Search for all customClassSwitcher usages in the codebase
echo "Checking all customClassSwitcher usages:"
rg "customClassSwitcher\(" -A 2

# Check if there are any test files for customClassSwitcher
echo -e "\nChecking for customClassSwitcher tests:"
fd -e test.ts -e test.tsx -e spec.ts -e spec.tsx | xargs rg "customClassSwitcher"

Length of output: 10886


Script:

#!/bin/bash
# Get the implementation of customClassSwitcher
echo "Checking customClassSwitcher implementation:"
cat src/core/customClassSwitcher/index.ts

Length of output: 773

@kotAPI kotAPI added the automerge A tag that tells kodiak bot to automerge PRs for us when tests and approval conditions are met label Dec 15, 2024
@kodiakhq kodiakhq bot merged commit a0efb52 into rad-ui:main Dec 15, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge A tag that tells kodiak bot to automerge PRs for us when tests and approval conditions are met
Projects
None yet
2 participants