-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[WEB-3128] improvement: made tab list items modular for independent use and added few icons #6387
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import * as React from "react"; | ||
|
|
||
| import { ISvgIcons } from "./type"; | ||
|
|
||
| export const BarIcon: React.FC<ISvgIcons> = ({ className = "", ...rest }) => ( | ||
| <svg className={className} viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg" {...rest}> | ||
| <path | ||
| d="M0 12.5859C0 11.4814 0.89543 10.5859 2 10.5859H3.64706C4.75163 10.5859 5.64706 11.4814 5.64706 12.5859V23.9977H0V12.5859Z" | ||
| fill="currentColor" | ||
| /> | ||
| <path | ||
| d="M9.17773 2C9.17773 0.89543 10.0732 0 11.1777 0H12.8248C13.9294 0 14.8248 0.895431 14.8248 2V24H9.17773V2Z" | ||
| fill="currentColor" | ||
| /> | ||
| <path | ||
| d="M18.3535 8.35156C18.3535 7.247 19.2489 6.35156 20.3535 6.35156H22.0006C23.1051 6.35156 24.0006 7.24699 24.0006 8.35156V23.9986H18.3535V8.35156Z" | ||
| fill="currentColor" | ||
| /> | ||
| </svg> | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import * as React from "react"; | ||
|
|
||
| import { ISvgIcons } from "./type"; | ||
|
|
||
| export const TreeMapIcon: React.FC<ISvgIcons> = ({ className = "", ...rest }) => ( | ||
| <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" /> | ||
| </svg> | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export * from "./tabs"; | ||
| export * from "./tab-list"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { Tab } from "@headlessui/react"; | ||
| import { LucideProps } from "lucide-react"; | ||
| import React, { FC } from "react"; | ||
| // helpers | ||
| import { cn } from "../../helpers"; | ||
|
|
||
| export type TabListItem = { | ||
| key: string; | ||
| icon?: FC<LucideProps>; | ||
| label?: React.ReactNode; | ||
| disabled?: boolean; | ||
| onClick?: () => void; | ||
| }; | ||
|
|
||
| type TTabListProps = { | ||
| tabs: TabListItem[]; | ||
| tabListClassName?: string; | ||
| tabClassName?: string; | ||
| size?: "sm" | "md" | "lg"; | ||
| selectedTab?: string; | ||
| onTabChange?: (key: string) => void; | ||
| }; | ||
|
|
||
| export const TabList: FC<TTabListProps> = ({ | ||
| tabs, | ||
| tabListClassName, | ||
| tabClassName, | ||
| size = "md", | ||
| selectedTab, | ||
| onTabChange, | ||
| }) => ( | ||
| <Tab.List | ||
| as="div" | ||
| className={cn( | ||
| "flex w-full min-w-fit items-center justify-between gap-1.5 rounded-md text-sm p-0.5 bg-custom-background-80/60", | ||
| tabListClassName | ||
| )} | ||
| > | ||
| {tabs.map((tab) => ( | ||
| <Tab | ||
| className={({ selected }) => | ||
| cn( | ||
| "flex items-center justify-center p-1 min-w-fit w-full font-medium text-custom-text-100 outline-none focus:outline-none cursor-pointer transition-all rounded", | ||
| (selectedTab ? selectedTab === tab.key : selected) | ||
| ? "bg-custom-background-100 text-custom-text-100 shadow-sm" | ||
| : tab.disabled | ||
| ? "text-custom-text-400 cursor-not-allowed" | ||
| : "text-custom-text-400 hover:text-custom-text-300 hover:bg-custom-background-80/60", | ||
| { | ||
| "text-xs": size === "sm", | ||
| "text-sm": size === "md", | ||
| "text-base": size === "lg", | ||
| }, | ||
| tabClassName | ||
| ) | ||
| } | ||
| key={tab.key} | ||
| onClick={() => { | ||
| if (!tab.disabled) { | ||
| onTabChange?.(tab.key); | ||
| tab.onClick?.(); | ||
| } | ||
| }} | ||
| disabled={tab.disabled} | ||
| > | ||
| {tab.icon && <tab.icon className="size-4" />} | ||
| {tab.label} | ||
| </Tab> | ||
| ))} | ||
| </Tab.List> | ||
| ); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.