Skip to content

Commit

Permalink
chore(Tabs): ability to customize scrollArea
Browse files Browse the repository at this point in the history
  • Loading branch information
zaaakher committed May 29, 2024
1 parent bf778e8 commit 24c96ed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
13 changes: 9 additions & 4 deletions packages/components/elements/tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,17 @@ const Tabs = React.forwardRef<

type TabsListProps = React.ComponentPropsWithoutRef<
typeof TabsPrimitive.List
> & { scrollable?: boolean };
> & {
scrollable?: boolean;
classNames?: {
scrollArea?: string;
};
};

const TabsList = React.forwardRef<
React.ElementRef<typeof TabsPrimitive.List>,
TabsListProps
>(({ className, ...props }, ref) => {
>(({ className, classNames, ...props }, ref) => {
const { orientation, variant } = React.useContext(TabsContext);
const [size, setSize] = React.useState(
(typeof window !== "undefined" && window.innerWidth) || 1200,
Expand All @@ -134,9 +139,9 @@ const TabsList = React.forwardRef<
}
}, []);

if ((props.scrollable && size < 768) && orientation === "horizontal") {
if (props.scrollable && size < 768 && orientation === "horizontal") {
return (
<ScrollArea orientation="horizontal">
<ScrollArea orientation="horizontal" className={classNames?.scrollArea}>
<TabsPrimitive.List
ref={ref}
className={cn(
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sikka/hawa",
"version": "0.38.13",
"version": "0.38.14",
"description": "Modern UI Kit made with Tailwind",
"author": {
"name": "Sikka Software",
Expand Down
15 changes: 6 additions & 9 deletions packages/storybook/stories/ElementsStories/Tabs.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ export const Default: Story = {
dir={direction}
onValueChange={() => setTest(false)}
>
<TabsList
scrollable
className="hawa-w-full"
>
<TabsList scrollable className="hawa-w-full">
<TabsTrigger
value="account"
showPopover={test}
Expand All @@ -53,13 +50,13 @@ export const Default: Story = {
</TabsTrigger>
<TabsTrigger value="password">{t("password")}</TabsTrigger>
<TabsTrigger value="password1">{t("password")}</TabsTrigger>
<TabsTrigger value="password2">{t("password")}</TabsTrigger>
<TabsTrigger value="password3">{t("password")}</TabsTrigger>
{/* <TabsTrigger value="password2">{t("password")}</TabsTrigger> */}
{/* <TabsTrigger value="password3">{t("password")}</TabsTrigger>
<TabsTrigger value="password4">{t("password")}</TabsTrigger>
<TabsTrigger value="password5">{t("password")}</TabsTrigger>
<TabsTrigger value="password6">{t("password")}</TabsTrigger>
<TabsTrigger value="password7">{t("password")}</TabsTrigger>
<TabsTrigger
<TabsTrigger value="password7">{t("password")}</TabsTrigger> */}
{/* <TabsTrigger
value="settings"
chipProps={{ label: "", color: "red", size: "small" }}
>
Expand All @@ -70,7 +67,7 @@ export const Default: Story = {
chipProps={{ label: t("new"), color: "red", size: "small" }}
>
{t("display")}
</TabsTrigger>
</TabsTrigger> */}
</TabsList>
<TabsContent value="account">
<Card>
Expand Down

0 comments on commit 24c96ed

Please sign in to comment.