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

Improve tabs in UI kit #1022

Merged
merged 4 commits into from
Jan 24, 2025
Merged

Improve tabs in UI kit #1022

merged 4 commits into from
Jan 24, 2025

Conversation

almsh
Copy link
Contributor

@almsh almsh commented Jan 24, 2025

Summary by CodeRabbit

Release Notes

  • Documentation

    • Updated README.md to include UI Kit entry with UI Components Documentation link for the Website.
  • UI Improvements

    • Modified TabsTrigger component styling.
      • Updated active state background and text colors.
      • Refined background and text color classes.
  • Storybook Enhancement

    • Improved Tabs component documentation in Storybook.
    • Added icon support and more configurable tab stories.
    • Updated story interfaces for better component representation.

Copy link

vercel bot commented Jan 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
public ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 24, 2025 6:03pm

Copy link

coderabbitai bot commented Jan 24, 2025

📝 Walkthrough

Walkthrough

This pull request introduces updates to documentation and UI component styling. The README.md now features a new entry for the UI Kit, including a link to the UI Components Documentation. The tabs.tsx component has undergone styling class modifications to enhance the appearance of tab triggers. Additionally, the tabs.stories.tsx file has been significantly improved with new imports, enhanced type definitions, and more detailed Storybook documentation.

Changes

File Change Summary
README.md Added UI Kit row with Website UI Components Documentation link
ui/src/components/tabs.tsx Updated TabsTrigger component styling classes
ui/src/stories/tabs.stories.tsx Enhanced Storybook stories with new imports, improved type definitions, and more detailed documentation

Possibly related PRs

  • Update badge component #1019: The changes in the main PR regarding the addition of the UI Kit in the README.md file may relate to the updates in the Badge component's properties and styling, as both involve enhancements to the UI components and their documentation.

Suggested Reviewers

  • socialincome-dev
  • mkue
  • ssandino

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

@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)
ui/src/stories/tabs.stories.tsx (2)

99-106: Flexible rendering approach.
Using a destructured render function for story-specific props keeps the code well-structured. Consider adding quick comment docs for future maintainers.


208-239: Interactive icons within tabs.
Including HeroIcons with customizable size demonstrates real-world usage. Inline styles are fine for small demos but consider using a common utility class for icon styling as a next step.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 240ace7 and be1a715.

📒 Files selected for processing (3)
  • README.md (1 hunks)
  • ui/src/components/tabs.tsx (1 hunks)
  • ui/src/stories/tabs.stories.tsx (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • README.md
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Prettify
  • GitHub Check: Security checks (typescript)
🔇 Additional comments (13)
ui/src/components/tabs.tsx (1)

31-31: Check accessibility for color changes.
Using a primary background with white text can reduce readability if contrast is insufficient. Ensure that the updated theme maintains adequate contrast, especially for users with impaired vision.

ui/src/stories/tabs.stories.tsx (12)

3-3: Good import usage for icons.
Importing icons from @heroicons/react/24/outline is an effective way to keep them consistent and well-maintained.


9-25: Clear documentation structure.
The expanded docs parameters and story description provide better user guidance. This helps in Storybook’s discoverability and clarifies the component’s usage.


26-55: Comprehensive argTypes definition.
Defining controls and describing props ensure an improved developer experience. Hiding irrelevant props like dir, asChild, and orientation keeps the Storybook interface uncluttered.


60-66: Smart separation of interfaces.
Defining BasicStoryProps clarifies what custom props the story supports. This is a tidy approach that enhances code readability and organization.


68-98: Appropriate usage example.
Showcasing the Basic story with dynamic labels and content is a great introduction to the component’s core functionality.


111-115: Interface for styling customization.
Enabling style props at story level promotes a clear demonstration of theming and extends usage possibilities.


118-162: Clear demonstration of optional classes.
Exhibiting how to pass custom classes via props helps teams adopt consistent styling practices across different UI scenarios.


167-169: Nice approach to layout props.
Accepting a gap prop for spacing between tabs is a flexible solution for design variations.


171-199: Effective example for full-width usage.
Explicitly rendering tabs in a full-width layout with optional gap showcases advanced alignment patterns.


204-206: Icon sizing prop.
Providing a dedicated iconSize prop is a convenient approach, ensuring consistent sizing across various stories.


244-244: Rich content story is well separated.
The separate export for WithRichContent keeps the code organized.


246-280: Demonstrating advanced content.
Showcasing form elements and textual content in tabs is a strong plus, illustrating the component’s flexibility and user flow.

Copy link

@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 (2)
ui/src/stories/tabs.stories.tsx (2)

60-113: Consider using array-based implementation for better scalability.

The current implementation with tab1/tab2 props could be refactored to use an array-based approach for better maintainability.

-interface BasicStoryProps extends React.ComponentProps<typeof Tabs> {
-  tab1Label?: string;
-  tab2Label?: string;
-  tab1Content?: string;
-  tab2Content?: string;
+interface Tab {
+  label: string;
+  content: string;
+  value: string;
+}
+
+interface BasicStoryProps extends React.ComponentProps<typeof Tabs> {
+  tabs?: Tab[];
}

 export const Basic: StoryObj<BasicStoryProps> = {
   args: {
     defaultValue: 'tab1',
-    tab1Label: 'Tab 1',
-    tab2Label: 'Tab 2',
+    tabs: [
+      { label: 'Tab 1', content: 'Content for Tab 1', value: 'tab1' },
+      { label: 'Tab 2', content: 'Content for Tab 2', value: 'tab2' },
+    ],
   },
   // ...
   render: ({
-    tab1Label = 'Tab 1',
-    tab2Label = 'Tab 2',
-    tab1Content = 'Content for Tab 1',
-    tab2Content = 'Content for Tab 2',
+    tabs = [
+      { label: 'Tab 1', content: 'Content for Tab 1', value: 'tab1' },
+      { label: 'Tab 2', content: 'Content for Tab 2', value: 'tab2' },
+    ],
     ...args
   }) => (
     <Tabs {...args}>
       <TabsList>
-        <TabsTrigger value="tab1">{tab1Label}</TabsTrigger>
-        <TabsTrigger value="tab2">{tab2Label}</TabsTrigger>
+        {tabs.map(tab => (
+          <TabsTrigger key={tab.value} value={tab.value}>
+            {tab.label}
+          </TabsTrigger>
+        ))}
       </TabsList>
-      <TabsContent value="tab1">{tab1Content}</TabsContent>
-      <TabsContent value="tab2">{tab2Content}</TabsContent>
+      {tabs.map(tab => (
+        <TabsContent key={tab.value} value={tab.value}>
+          {tab.content}
+        </TabsContent>
+      ))}
     </Tabs>
   ),

117-174: Consider using a class name utility for better class management.

The custom class names could benefit from using a utility like clsx or tailwind-merge to handle conditional and merged classes.

+import { cn } from '../lib/utils';  // Add utility import

 render: ({ listClassName, triggerClassName, contentClassName, ...args }) => (
   <Tabs {...args}>
-    <TabsList className={listClassName}>
+    <TabsList className={cn('bg-gray-100 p-2 rounded-lg', listClassName)}>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between be1a715 and 82fc02f.

📒 Files selected for processing (3)
  • README.md (1 hunks)
  • ui/src/components/tabs.tsx (1 hunks)
  • ui/src/stories/tabs.stories.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • ui/src/components/tabs.tsx
  • README.md
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Prettify
🔇 Additional comments (2)
ui/src/stories/tabs.stories.tsx (2)

1-57: Well-structured meta configuration and documentation!

The meta configuration provides clear documentation and appropriate controls configuration.


220-257: Well-implemented icon integration!

The HeroIcons integration and dynamic sizing are implemented correctly.

Comment on lines +277 to 288
<TabsContent value="profile" className={`space-y-4`}>
<h3 className="text-lg font-medium">Profile Settings</h3>
<p className="text-muted-foreground text-sm">Update your profile information and preferences.</p>
<input type="text" placeholder="Display Name" className="flex h-10 w-full rounded-md border px-3" />
</TabsContent>
<TabsContent value="tab2" className="space-y-4">
<div className="space-y-2">
<h3 className="text-lg font-medium">Preferences</h3>
<p className="text-muted-foreground text-sm">Customize your application preferences.</p>
</div>
<div className="grid gap-2">
<label className="flex items-center space-x-2">
<input type="checkbox" />
<span>Enable notifications</span>
</label>
<TabsContent value="notifications" className={`space-y-4`}>
<h3 className="text-lg font-medium">Notification Settings</h3>
<p className="text-muted-foreground text-sm">Choose how you want to be notified.</p>
<div className="flex items-center space-x-2">
<input type="checkbox" id="emailNotifications" />
<label htmlFor="emailNotifications">Email notifications</label>
</div>
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add accessibility attributes to form elements.

The form elements should include proper accessibility attributes.

-<input type="text" placeholder="Display Name" className="flex h-10 w-full rounded-md border px-3" />
+<input
+  type="text"
+  placeholder="Display Name"
+  className="flex h-10 w-full rounded-md border px-3"
+  aria-label="Display Name"
+  required
+/>

-<input type="checkbox" id="emailNotifications" />
+<input
+  type="checkbox"
+  id="emailNotifications"
+  aria-describedby="emailNotifications-description"
+/>
 <label htmlFor="emailNotifications">Email notifications</label>
+<p id="emailNotifications-description" className="sr-only">
+  Toggle email notifications for your account
+</p>
📝 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
<TabsContent value="profile" className={`space-y-4`}>
<h3 className="text-lg font-medium">Profile Settings</h3>
<p className="text-muted-foreground text-sm">Update your profile information and preferences.</p>
<input type="text" placeholder="Display Name" className="flex h-10 w-full rounded-md border px-3" />
</TabsContent>
<TabsContent value="tab2" className="space-y-4">
<div className="space-y-2">
<h3 className="text-lg font-medium">Preferences</h3>
<p className="text-muted-foreground text-sm">Customize your application preferences.</p>
</div>
<div className="grid gap-2">
<label className="flex items-center space-x-2">
<input type="checkbox" />
<span>Enable notifications</span>
</label>
<TabsContent value="notifications" className={`space-y-4`}>
<h3 className="text-lg font-medium">Notification Settings</h3>
<p className="text-muted-foreground text-sm">Choose how you want to be notified.</p>
<div className="flex items-center space-x-2">
<input type="checkbox" id="emailNotifications" />
<label htmlFor="emailNotifications">Email notifications</label>
</div>
<TabsContent value="profile" className={`space-y-4`}>
<h3 className="text-lg font-medium">Profile Settings</h3>
<p className="text-muted-foreground text-sm">Update your profile information and preferences.</p>
<input
type="text"
placeholder="Display Name"
className="flex h-10 w-full rounded-md border px-3"
aria-label="Display Name"
required
/>
</TabsContent>
<TabsContent value="notifications" className={`space-y-4`}>
<h3 className="text-lg font-medium">Notification Settings</h3>
<p className="text-muted-foreground text-sm">Choose how you want to be notified.</p>
<div className="flex items-center space-x-2">
<input
type="checkbox"
id="emailNotifications"
aria-describedby="emailNotifications-description"
/>
<label htmlFor="emailNotifications">Email notifications</label>
<p id="emailNotifications-description" className="sr-only">
Toggle email notifications for your account
</p>
</div>

},
render: ({ gap = 2, ...args }) => (
<Tabs {...args}>
<TabsList className={`flex w-full justify-between gap-${gap}`}>
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix dynamic Tailwind class generation.

Using template literals for Tailwind classes (gap-${gap}) won't work in production as Tailwind needs to statically analyze class names.

-<TabsList className={`flex w-full justify-between gap-${gap}`}>
+<TabsList className={cn('flex w-full justify-between', {
+  'gap-0': gap === 0,
+  'gap-1': gap === 1,
+  'gap-2': gap === 2,
+  'gap-3': gap === 3,
+  'gap-4': gap === 4,
+  'gap-5': gap === 5,
+  'gap-6': gap === 6,
+  'gap-7': gap === 7,
+  'gap-8': gap === 8,
+})}>
📝 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
<TabsList className={`flex w-full justify-between gap-${gap}`}>
<TabsList className={cn('flex w-full justify-between', {
'gap-0': gap === 0,
'gap-1': gap === 1,
'gap-2': gap === 2,
'gap-3': gap === 3,
'gap-4': gap === 4,
'gap-5': gap === 5,
'gap-6': gap === 6,
'gap-7': gap === 7,
'gap-8': gap === 8,
})}>

Copy link

Visit the preview URL for this PR (updated for commit 75259e3):

https://si-admin-staging--pr1022-almsh-impove-tabs-brkeosuw.web.app

(expires Fri, 31 Jan 2025 18:01:23 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: b7b0969384059dce6ea8fad1ee1d1737e54e6676

@almsh almsh merged commit cfbf9b0 into main Jan 24, 2025
19 checks passed
@almsh almsh deleted the almsh/impove-tabs branch January 24, 2025 18:07
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.

None yet

2 participants