Skip to content

add variant and size for blockquote#922

Merged
kodiakhq[bot] merged 1 commit intorad-ui:mainfrom
jindaljyoti:blockquote_variant_size
Mar 8, 2025
Merged

add variant and size for blockquote#922
kodiakhq[bot] merged 1 commit intorad-ui:mainfrom
jindaljyoti:blockquote_variant_size

Conversation

@jindaljyoti
Copy link
Copy Markdown
Contributor

@jindaljyoti jindaljyoti commented Mar 6, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced the BlockQuote component by adding customization options for variant and size.
    • Introduced interactive examples showcasing different block quote configurations such as color, sizes, and variants.
  • Documentation

    • Updated the documentation pages to include new code usage examples that demonstrate the expanded BlockQuote capabilities.
    • Added sections that display real-time examples with adjustable properties for improved clarity.
  • Style

    • Refined styling rules to support various block quote sizes for a more tailored appearance.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 6, 2025

Walkthrough

This pull request introduces new documentation and example files for the BlockQuote component. Three new usage files asynchronously load example source code and export a structured code object. Corresponding React examples—demonstrating color, size, and variant implementations—are added. The main BlockQuote component has been updated to accept new optional properties (variant and size), with logic to include corresponding data attributes. The documentation page is enhanced to display the new examples, and Storybook now includes dedicated stories for size and variant usages. Additionally, new SCSS rules support the various block quote sizes.

Changes

File(s) Summary
docs/app/docs/components/blockquote/docs/colorCodeUsage.js, .../sizeCodeUsage.js, .../variantCodeUsage.js New files that asynchronously retrieve example source code using getSourceCodeFromPath and export a code object with a javascript property.
docs/app/docs/components/blockquote/examples/BlockQuoteColor.tsx, .../BlockQuoteSizes.tsx, .../BlockQuoteVariants.tsx New React components demonstrating BlockQuote variations for color, sizes, and variants.
docs/app/docs/components/blockquote/page.mdx Updated to import new code usage files and display examples for variants, sizes, and colors.
src/components/ui/BlockQuote/BlockQuote.tsx Updated to support new optional variant and size props by conditionally adding corresponding data attributes.
src/components/ui/BlockQuote/stories/BlockQuote.stories.tsx Added new Storybook stories for BlockQuote (Size and Variant) along with related constants for demonstration.
styles/themes/components/blockquote.scss Added CSS rules for size variants, defining unique font-size and consistent padding for each variant.

Sequence Diagram(s)

sequenceDiagram
    participant DocUsage as Documentation Usage File
    participant Util as getSourceCodeFromPath
    participant Example as Example Component Source
    participant Export as Code Object Export

    DocUsage->>Util: Call getSourceCodeFromPath(example path)
    Util-->>DocUsage: Return source code asynchronously
    DocUsage->>Export: Structure and export code object with retrieved source
Loading
sequenceDiagram
    participant Parent as Parent Component/Story
    participant BlockQuote as BlockQuote Component
    participant DOM as Rendered Element

    Parent->>BlockQuote: Render with props (variant, size, etc.)
    BlockQuote->>BlockQuote: Check for new props and conditionally add data attributes
    BlockQuote->>DOM: Render element with additional data attributes
Loading

Possibly related PRs

Suggested labels

automerge

Suggested reviewers

  • GoldGroove06

Poem

I'm a little rabbit with a hop and a code beat,
Skipping through files with every change neat.
New examples and props make my heart race,
As docs and stories fall perfectly into place.
With whiskers twitching at each code delight,
I celebrate these changes under the moonlit night.
🐇✨ Happy coding and carrots in sight!

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.

docs/app/docs/components/blockquote/docs/variantCodeUsage.js

Oops! Something went wrong! :(

ESLint: 8.56.0

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/docs/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

docs/app/docs/components/blockquote/docs/sizeCodeUsage.js

Oops! Something went wrong! :(

ESLint: 8.56.0

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/docs/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

docs/app/docs/components/blockquote/docs/colorCodeUsage.js

Oops! Something went wrong! :(

ESLint: 8.56.0

ESLint couldn't find the config "next/core-web-vitals" to extend from. Please check that the name of the config is correct.

The config "next/core-web-vitals" was referenced from the config file in "/docs/.eslintrc.json".

If you still have problems, please stop by https://eslint.org/chat/help to chat with the team.

  • 3 others
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 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.
  • @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
Copy Markdown
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: 2

🧹 Nitpick comments (13)
styles/themes/components/blockquote.scss (3)

6-6: Remove or update the TODO comment since variants are being implemented

The TODO comment about BlockQuote variants should be removed or updated since this PR is implementing variants for the component.

-    // BlockQuote Variants - TODO
+    // BlockQuote Variants

9-31: Consider varying padding proportionally with different sizes

Currently, all size variants use the same padding (4px 10px) regardless of font size. It would be more consistent with design patterns to have proportionally larger padding for larger font sizes.

Also, there are several unnecessary blank lines that could be removed for better code consistency.

 /** BlockQuote Sizes */
 &[data-block-quote-size="small"]{
     font-size: small;
     padding: 4px 10px;
-      
 }

 &[data-block-quote-size="medium"]{
     font-size: medium;
     padding: 4px 10px;
-    
 }

 &[data-block-quote-size="large"]{
     font-size: large;
-    padding: 4px 10px;
-    
+    padding: 6px 12px;
 }

 &[data-block-quote-size="x-large"]{
     font-size: x-large;
-    padding: 4px 10px;
-       
+    padding: 8px 14px;
 }

33-34: Remove unnecessary blank lines

There are extra blank lines at the end of the file that should be removed.

docs/app/docs/components/blockquote/examples/BlockQuoteColor.tsx (1)

7-11: Consider using size as key instead of index

Since the sizes array contains unique string values, it would be more appropriate to use the size value as the key rather than the array index.

-                {sizes.map((size, index) => {
-                    return <BlockQuote key={index} size={size} color='pink'>
+                {sizes.map((size) => {
+                    return <BlockQuote key={size} size={size} color='pink'>
docs/app/docs/components/blockquote/examples/BlockQuoteSizes.tsx (4)

8-12: Consider using size as key instead of index

Since the sizes array contains unique string values, it would be more appropriate to use the size value as the key rather than the array index.

-                {sizes.map((size, index) => {
-                    return <BlockQuote key={index} size={size} >
+                {sizes.map((size) => {
+                    return <BlockQuote key={size} size={size} >

6-13: Fix indentation and whitespace

There are some inconsistent indentation and extra whitespace in the JSX. Consider cleaning up the formatting:

-    return <div className='flex flex-col gap-4'>
-         
-                {sizes.map((size, index) => {
-                    return <BlockQuote key={index} size={size} >
-                        <span>"Behind every great man is a woman rolling her eyes." — Jim Carrey</span>
-                        </BlockQuote>
-                })}
-            </div>
+    return <div className='flex flex-col gap-4'>
+        {sizes.map((size, index) => {
+            return <BlockQuote key={index} size={size}>
+                <span>"Behind every great man is a woman rolling her eyes." — Jim Carrey</span>
+            </BlockQuote>
+        })}
+    </div>

10-11: Ensure consistency with other examples

In BlockQuoteColor.tsx, the quote text is directly inside the BlockQuote, but here it's wrapped in a span. Consider being consistent across examples:

-                        <span>"Behind every great man is a woman rolling her eyes." — Jim Carrey</span>
+                        "Behind every great man is a woman rolling her eyes." — Jim Carrey

Alternatively, ensure that all examples consistently use a span or other wrapper if there's a specific reason for it.


14-15: Remove extra whitespace

There's unnecessary whitespace at line 14 that should be removed for cleaner code.

-    
+
src/components/ui/BlockQuote/stories/BlockQuote.stories.tsx (2)

14-15: Consider removing unused array or implement Variants

The Variants array is defined but not used in the code. Either:

  1. Remove it until it's needed
  2. Implement it with the intended variant values
  3. Add a more descriptive TODO comment explaining what variants will be used
-const Variants = []; // TODO
+// TODO: Define variant options once finalized

67-79: Enhance the TODO comment for Variant implementation

The Variant story has a TODO comment but doesn't provide much context. Consider adding a more descriptive comment about what variants will be implemented:

        <div className='flex flex-col gap-3'>
-            {/* TODO */}
+            {/* TODO: Implement different variant examples once variants are finalized */}
            <BlockQuote>
                <div>{BLOCKQUOTE_TEXT}</div>
            </BlockQuote>
       </div>

Also, add a newline at the end of the file to fix the ESLint error:

};
+
🧰 Tools
🪛 ESLint

[error] 79-79: Newline required at end of file but not found.

(eol-last)

src/components/ui/BlockQuote/BlockQuote.tsx (3)

12-14: Clear addition of new props to enhance BlockQuote customization.

The addition of variant and size props expands the component's flexibility while maintaining the existing API. Consider improving type safety by using union types (e.g., variant?: 'bordered' | 'filled') if there are specific predefined variants and sizes.


30-33: Remove extra empty line.

There's an unnecessary blank line before the color check conditional.

-

 if (color) {
🧰 Tools
🪛 ESLint

[error] 30-31: More than 1 blank line not allowed.

(no-multiple-empty-lines)


34-34: Remove trailing whitespace.

There's trailing whitespace at the end of line 34.

-    
+
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 07ced7f and da40276.

📒 Files selected for processing (10)
  • docs/app/docs/components/blockquote/docs/colorCodeUsage.js (1 hunks)
  • docs/app/docs/components/blockquote/docs/sizeCodeUsage.js (1 hunks)
  • docs/app/docs/components/blockquote/docs/variantCodeUsage.js (1 hunks)
  • docs/app/docs/components/blockquote/examples/BlockQuoteColor.tsx (1 hunks)
  • docs/app/docs/components/blockquote/examples/BlockQuoteSizes.tsx (1 hunks)
  • docs/app/docs/components/blockquote/examples/BlockQuoteVariants.tsx (1 hunks)
  • docs/app/docs/components/blockquote/page.mdx (2 hunks)
  • src/components/ui/BlockQuote/BlockQuote.tsx (1 hunks)
  • src/components/ui/BlockQuote/stories/BlockQuote.stories.tsx (2 hunks)
  • styles/themes/components/blockquote.scss (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • docs/app/docs/components/blockquote/examples/BlockQuoteVariants.tsx
🧰 Additional context used
🪛 ESLint
src/components/ui/BlockQuote/BlockQuote.tsx

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

(space-infix-ops)


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

(space-infix-ops)


[error] 30-31: More than 1 blank line not allowed.

(no-multiple-empty-lines)

src/components/ui/BlockQuote/stories/BlockQuote.stories.tsx

[error] 79-79: Newline required at end of file but not found.

(eol-last)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (9)
docs/app/docs/components/blockquote/docs/sizeCodeUsage.js (1)

1-9: LGTM! Documentation file well structured.

The file correctly imports the source code parsing utility and exports the code in the expected format for documentation purposes.

docs/app/docs/components/blockquote/docs/variantCodeUsage.js (1)

1-9: LGTM! Documentation file well structured.

The file correctly imports the source code parsing utility and exports the code in the expected format for documentation purposes.

docs/app/docs/components/blockquote/docs/colorCodeUsage.js (1)

1-9: LGTM! Documentation file well structured.

The file correctly imports the source code parsing utility and exports the code in the expected format for documentation purposes.

docs/app/docs/components/blockquote/examples/BlockQuoteColor.tsx (1)

1-15: Clean and well-structured example component

The component is well-organized and clearly demonstrates the different size options for the BlockQuote component with color.

docs/app/docs/components/blockquote/page.mdx (2)

4-9: Clean organization of imports

The imports are well-organized and follow a logical structure, with code usages and their corresponding component examples grouped together.


24-35: Well-structured documentation sections

The new ComponentHero sections for Variants, Sizes, and Color are clearly organized and consistent with the existing documentation pattern. Each section appropriately combines the code examples with the visual representation.

src/components/ui/BlockQuote/stories/BlockQuote.stories.tsx (1)

46-65: Well-implemented Size story

The Size story is well-structured and effectively demonstrates the different size options for the BlockQuote component.

src/components/ui/BlockQuote/BlockQuote.tsx (2)

22-24: Well-implemented variant attribute handling.

The implementation correctly sets the data attribute only when a variant is provided, following the established pattern used for the color attribute.


26-28: Well-implemented size attribute handling.

The implementation correctly sets the data attribute only when a size is provided, following the established pattern used for the color attribute.

</BlockQuote>
</div>
</SandboxEditor>;
}; No newline at end of file
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.

⚠️ Potential issue

Add newline at end of file

Add a newline at the end of the file to fix the ESLint error "Newline required at end of file but not found."

};
+
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
};
};
🧰 Tools
🪛 ESLint

[error] 79-79: Newline required at end of file but not found.

(eol-last)

props?: Record<string, any>[]
}
const BlockQuote = ({ children, customRootClass = '', className = '', color = '', ...props }: BlockQuoteProps) => {
const BlockQuote = ({ children, customRootClass = '', className = '', color = '', variant= '', size= '', ...props }: BlockQuoteProps) => {
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.

⚠️ Potential issue

Fix spacing around assignment operators.

There are spacing issues with the default value assignments for variant and size.

-const BlockQuote = ({ children, customRootClass = '', className = '', color = '', variant= '', size= '', ...props }: BlockQuoteProps) => {
+const BlockQuote = ({ children, customRootClass = '', className = '', color = '', variant = '', size = '', ...props }: BlockQuoteProps) => {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const BlockQuote = ({ children, customRootClass = '', className = '', color = '', variant= '', size= '', ...props }: BlockQuoteProps) => {
const BlockQuote = ({ children, customRootClass = '', className = '', color = '', variant = '', size = '', ...props }: BlockQuoteProps) => {
🧰 Tools
🪛 ESLint

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

(space-infix-ops)


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

(space-infix-ops)

@kotAPI kotAPI added the automerge A tag that tells kodiak bot to automerge PRs for us when tests and approval conditions are met label Mar 8, 2025
@kodiakhq kodiakhq Bot merged commit 2cb51d0 into rad-ui:main Mar 8, 2025
This was referenced Mar 20, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Dec 20, 2025
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

Development

Successfully merging this pull request may close these issues.

2 participants