-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Conversation
WalkthroughThis pull request introduces new UI components and icons to the packages/ui directory. It includes the addition of two new icon components, Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 componentThe 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 componentThe 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-iconThe "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
📒 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 goalThe 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 patternThe 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.
Description
Type of Change
Screenshots and Media (if applicable)
Test Scenarios
References
WEB-3128
Summary by CodeRabbit
New Features
BarIcon
andTreeMapIcon
TabList
component for creating customizable tab interfacesDocumentation