diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index b90b6993a..dbca8bd64 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -1,12 +1,13 @@ export * from "./avatar"; -export * from "./breadcrumbs"; export * from "./badge"; +export * from "./breadcrumbs"; export * from "./button"; +export * from "./control-link"; export * from "./dropdowns"; export * from "./form-fields"; export * from "./icons"; export * from "./progress"; export * from "./spinners"; +export * from "./tabs"; export * from "./tooltip"; export * from "./loader"; -export * from "./control-link"; diff --git a/packages/ui/src/tabs/icon-tabs.tsx b/packages/ui/src/tabs/icon-tabs.tsx new file mode 100644 index 000000000..fd8cd0351 --- /dev/null +++ b/packages/ui/src/tabs/icon-tabs.tsx @@ -0,0 +1,84 @@ +import React from "react"; +// tooltip +import { Tooltip } from "../tooltip"; +// helpers +import { cn } from "../../helpers"; + +export type TIconTabsProps = { + buttonClassName?: string; + containerClassName?: string; + hideTooltip?: boolean; + iconClassName?: string; + iconsList: { + key: string; + title: string; + icon: any; + }[]; + onSelect: (key: string) => void; + overlayClassName?: string; + selectedKey: string | undefined; +}; + +export const IconTabs: React.FC = (props) => { + const { + buttonClassName, + containerClassName, + hideTooltip = false, + iconClassName, + iconsList, + onSelect, + overlayClassName, + selectedKey, + } = props; + + const selectedTabIndex = iconsList.findIndex((icon) => icon.key === selectedKey); + + return ( +
+
+ {iconsList.map((icon) => ( + + + + ))} +
+ ); +}; diff --git a/packages/ui/src/tabs/index.ts b/packages/ui/src/tabs/index.ts new file mode 100644 index 000000000..9b9932140 --- /dev/null +++ b/packages/ui/src/tabs/index.ts @@ -0,0 +1 @@ +export * from "./icon-tabs"; diff --git a/web/components/issues/issue-layouts/filters/header/layout-selection.tsx b/web/components/issues/issue-layouts/filters/header/layout-selection.tsx index 305be7eff..ca7c914ef 100644 --- a/web/components/issues/issue-layouts/filters/header/layout-selection.tsx +++ b/web/components/issues/issue-layouts/filters/header/layout-selection.tsx @@ -1,7 +1,6 @@ import React from "react"; - // ui -import { Tooltip } from "@plane/ui"; +import { IconTabs } from "@plane/ui"; // types import { TIssueLayouts } from "@plane/types"; // constants @@ -17,26 +16,10 @@ export const LayoutSelection: React.FC = (props) => { const { layouts, onChange, selectedLayout } = props; return ( -
- {ISSUE_LAYOUTS.filter((l) => layouts.includes(l.key)).map((layout) => ( - - - - ))} -
+ layouts.includes(l.key))} + onSelect={(key) => onChange(key as TIssueLayouts)} + selectedKey={selectedLayout} + /> ); }; diff --git a/web/constants/issue.ts b/web/constants/issue.ts index ccf609b1f..1c76c2d02 100644 --- a/web/constants/issue.ts +++ b/web/constants/issue.ts @@ -131,11 +131,11 @@ export const ISSUE_LAYOUTS: { title: string; icon: any; }[] = [ - { key: "list", title: "List Layout", icon: List }, - { key: "kanban", title: "Kanban Layout", icon: Kanban }, - { key: "calendar", title: "Calendar Layout", icon: Calendar }, - { key: "spreadsheet", title: "Spreadsheet Layout", icon: Sheet }, - { key: "gantt_chart", title: "Gantt Chart Layout", icon: GanttChartSquare }, + { key: "list", title: "List layout", icon: List }, + { key: "kanban", title: "Kanban layout", icon: Kanban }, + { key: "calendar", title: "Calendar layout", icon: Calendar }, + { key: "spreadsheet", title: "Spreadsheet layout", icon: Sheet }, + { key: "gantt_chart", title: "Gantt Chart layout", icon: GanttChartSquare }, ]; export const ISSUE_LIST_FILTERS = [ @@ -449,4 +449,4 @@ export const groupReactionEmojis = (reactions: any) => { } return _groupedEmojis; -}; \ No newline at end of file +};