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

[WEB-3128] improvement: made tab list items modular for independent use and added few icons #6387

Merged
merged 2 commits into from
Jan 13, 2025

Conversation

prateekshourya29
Copy link
Member

@prateekshourya29 prateekshourya29 commented Jan 13, 2025

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

Test Scenarios

References

WEB-3128

Summary by CodeRabbit

  • New Features

    • Added two new icons: BarIcon and TreeMapIcon
    • Introduced a new TabList component for creating customizable tab interfaces
    • Enhanced tab management with improved type definitions and component structure
  • Documentation

    • Updated icon and tab module exports to improve component accessibility

Copy link
Contributor

coderabbitai bot commented Jan 13, 2025

Walkthrough

This pull request introduces new UI components and icons to the packages/ui directory. It includes the addition of two new icon components, BarIcon and TreeMapIcon, in the icons module. A new TabList component has been developed in the tabs module, and the existing Tabs component has been updated to utilize this new TabList. The changes aim to enhance the UI component library by providing more modular and flexible icon and tab rendering capabilities.

Changes

File Change Summary
packages/ui/src/icons/bar-icon.tsx Added new BarIcon React component with SVG rendering
packages/ui/src/icons/tree-map-icon.tsx Added new TreeMapIcon React component with SVG rendering
packages/ui/src/icons/index.ts Added exports for bar-icon and tree-map-icon
packages/ui/src/tabs/index.ts Added export for tab-list module
packages/ui/src/tabs/tab-list.tsx Introduced new TabList component with advanced tab rendering logic
packages/ui/src/tabs/tabs.tsx Updated TabItem type and refactored Tabs component to use TabList

Possibly related PRs

Suggested labels

🌐frontend, 🧹chore

Suggested reviewers

  • rahulramesha
  • sriramveeraghanta
  • SatishGandham

Poem

🐰 Hop, hop, icons take flight!
Tabs dancing with newfound might
Bar and TreeMap, pixels so bright
UI components, a coder's delight
CodeRabbit's magic, pure and white! 🎨

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.

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: 1

🧹 Nitpick comments (8)
packages/ui/src/icons/bar-icon.tsx (1)

5-20: LGTM! Well-structured SVG icon component

The implementation follows React best practices and maintains consistency with other icon components.

Consider adding ARIA attributes for accessibility

For better accessibility, consider adding aria-label and role attributes.

-  <svg className={className} viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" {...rest}>
+  <svg 
+    className={className} 
+    viewBox="0 0 24 24" 
+    fill="currentColor" 
+    xmlns="http://www.w3.org/2000/svg" 
+    aria-label="bar chart"
+    role="img"
+    {...rest}
+  >
packages/ui/src/icons/tree-map-icon.tsx (1)

5-16: LGTM! Well-structured SVG icon component

The implementation follows React best practices and maintains consistency with other icon components.

Consider adding ARIA attributes for accessibility

For better accessibility, consider adding aria-label and role attributes.

-  <svg className={className} viewBox="0 0 27 22" fill="currentColor" xmlns="http://www.w3.org/2000/svg" {...rest}>
+  <svg 
+    className={className} 
+    viewBox="0 0 27 22" 
+    fill="currentColor" 
+    xmlns="http://www.w3.org/2000/svg" 
+    aria-label="tree map"
+    role="img"
+    {...rest}
+  >

Consider optimizing rect elements

The rect elements could be more maintainable by using a map function over an array of configurations.

+  const rects = [
+    { width: 10, height: 10, x: 0, y: 0 },
+    { width: 10, height: 6, x: 11.5, y: 0 },
+    { width: 10, height: 10, x: 0, y: 12 },
+    { width: 10, height: 6, x: 11.5, y: 16 },
+    { width: 10, height: 6, x: 11.5, y: 8 },
+    { width: 4, height: 11, x: 23, y: 0 },
+    { width: 4, height: 4, x: 23, y: 13 },
+    { width: 4, height: 3, x: 23, y: 19 },
+  ];
+
   <svg className={className} viewBox="0 0 27 22" fill="currentColor" xmlns="http://www.w3.org/2000/svg" {...rest}>
-    <rect width="10" height="10" rx="1" fill="currentColor" />
-    <rect x="11.5" width="10" height="6" rx="1" fill="currentColor" />
-    <rect y="12" width="10" height="10" rx="1" fill="currentColor" />
-    <rect x="11.5" y="16" width="10" height="6" rx="1" fill="currentColor" />
-    <rect x="11.5" y="8" width="10" height="6" rx="1" fill="currentColor" />
-    <rect x="23" width="4" height="11" rx="1" fill="currentColor" />
-    <rect x="23" y="13" width="4" height="4" rx="1" fill="currentColor" />
-    <rect x="23" y="19" width="4" height="3" rx="1" fill="currentColor" />
+    {rects.map((rect, index) => (
+      <rect
+        key={index}
+        {...rect}
+        rx="1"
+        fill="currentColor"
+      />
+    ))}
   </svg>
packages/ui/src/icons/index.ts (1)

Line range hint 29-29: Remove duplicate export of info-icon

The "info-icon" is exported twice in this file (lines 19 and 29).

 export * from "./info-icon";
 export * from "./layer-stack";
 export * from "./layers-icon";
 export * from "./monospace-icon";
 export * from "./photo-filter-icon";
 export * from "./priority-icon";
 export * from "./related-icon";
 export * from "./sans-serif-icon";
 export * from "./serif-icon";
 export * from "./side-panel-icon";
 export * from "./transfer-icon";
-export * from "./info-icon";
 export * from "./dropdown-icon";
packages/ui/src/tabs/tab-list.tsx (3)

7-22: LGTM! Consider adding JSDoc comments.

The type definitions are well-structured and provide good flexibility. Consider adding JSDoc comments to document the purpose and usage of each type and their properties.

+/**
+ * Represents an individual tab item in the tab list
+ */
 export type TabListItem = {
+  /** Unique identifier for the tab */
   key: string;
+  /** Optional icon component */
   icon?: FC<LucideProps>;
   // ... add similar comments for other properties
 };

66-68: Improve icon and label spacing.

When both icon and label are present, there should be consistent spacing between them.

-        {tab.icon && <tab.icon className="size-4" />}
-        {tab.label}
+        <div className="flex items-center gap-2">
+          {tab.icon && <tab.icon className="size-4" />}
+          {tab.label}
+        </div>

24-31: Optimize component performance with memoization.

Consider memoizing the component to prevent unnecessary re-renders when parent components update.

-export const TabList: FC<TTabListProps> = ({
+export const TabList: FC<TTabListProps> = React.memo(({
   tabs,
   tabListClassName,
   tabClassName,
   size = "md",
   selectedTab,
   onTabChange,
-}) => (
+}) => {
   // ... component implementation
-);
+});
packages/ui/src/tabs/tabs.tsx (2)

9-13: LGTM! Consider making TabContent more flexible.

The type definitions look good. Consider making the TabContent type more flexible by allowing null or undefined content for lazy loading scenarios.

 export type TabContent = {
-  content: React.ReactNode;
+  content: React.ReactNode | null | undefined;
 };

59-61: Consider adding error boundary around tab content.

The handleTabChange function is well-implemented. Consider wrapping the tab content rendering with an error boundary to gracefully handle rendering errors.

+import { ErrorBoundary } from 'react-error-boundary';

 // ... inside Tab.Panel
-{tab.content}
+<ErrorBoundary fallback={<div>Error loading tab content</div>}>
+  {tab.content}
+</ErrorBoundary>
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between c779fc0 and 22a7beb.

📒 Files selected for processing (6)
  • packages/ui/src/icons/bar-icon.tsx (1 hunks)
  • packages/ui/src/icons/index.ts (1 hunks)
  • packages/ui/src/icons/tree-map-icon.tsx (1 hunks)
  • packages/ui/src/tabs/index.ts (1 hunks)
  • packages/ui/src/tabs/tab-list.tsx (1 hunks)
  • packages/ui/src/tabs/tabs.tsx (2 hunks)
🔇 Additional comments (3)
packages/ui/src/tabs/index.ts (1)

2-2: LGTM! Export aligns with modularization goal

The addition of the tab-list export supports the PR objective of making tab list items modular for independent use.

packages/ui/src/icons/index.ts (1)

52-53: LGTM! New icon exports follow existing pattern

The new exports for bar-icon and tree-map-icon are properly added.

packages/ui/src/tabs/tabs.tsx (1)

68-74: LGTM! TabList integration is clean and modular.

The TabList component integration is well-implemented, making the tab list reusable across different contexts.

packages/ui/src/tabs/tab-list.tsx Show resolved Hide resolved
@sriramveeraghanta sriramveeraghanta merged commit 7183cff into preview Jan 13, 2025
10 of 14 checks passed
@sriramveeraghanta sriramveeraghanta deleted the improvements-ui branch January 13, 2025 13:51
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.

3 participants