Skip to content

Commit

Permalink
Merge pull request #52 from deriv-com/shayan/add-title-font-size-prop…
Browse files Browse the repository at this point in the history
…-to-tabs

chore: added TitleFontSize to Tabs component
  • Loading branch information
shayan-deriv authored Feb 1, 2024
2 parents 4585d43 + 27ecfbb commit d587cd1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/components/Tabs/TabTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ export type TabTitleProps = {
className?: string;
variant: 'primary' | 'secondary';
onChange?: () => void;
TitleFontSize?: React.ComponentProps<typeof Text>['size'];
};

const TabTitle = ({ icon, activeTab, isActive, setSelectedTab, title,className,variant, onChange }: TabTitleProps) => {
const TabTitle = ({ icon, activeTab, isActive, setSelectedTab, title,className,variant, onChange, TitleFontSize }: TabTitleProps) => {
const handleOnClick = useCallback((title: string) => {
setSelectedTab(title);
onChange?.();
Expand All @@ -32,7 +33,7 @@ const TabTitle = ({ icon, activeTab, isActive, setSelectedTab, title,className,v
onClick={()=>handleOnClick(title)}
>
{icon}
<Text weight={isActive ? 'bold' : 'normal'}>{title}</Text>
<Text weight={isActive ? 'bold' : 'normal'} size={TitleFontSize}>{title}</Text>
</button>
);
};
Expand Down
6 changes: 4 additions & 2 deletions lib/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { ReactElement, useEffect, useState } from 'react';
import TabTitle, { TabTitleProps } from './TabTitle';
import { Text } from '../Text';
import clsx from 'clsx';
import './Tabs.scss';

Expand All @@ -10,9 +11,10 @@ type TabsProps = {
className?: string;
variant?: 'primary' | 'secondary';
onChange?: (index: number) => void;
TitleFontSize?: React.ComponentProps<typeof Text>['size'];
};

const Tabs = ({ children, activeTab, wrapperClassName, className, variant = 'primary', onChange }: TabsProps): JSX.Element => {
const Tabs = ({ children, activeTab, wrapperClassName, className, variant = 'primary', onChange, TitleFontSize }: TabsProps): JSX.Element => {
const [selectedTab, setSelectedTab] = useState(activeTab || children[0].props.title);

useEffect(() => {
Expand All @@ -36,7 +38,7 @@ const Tabs = ({ children, activeTab, wrapperClassName, className, variant = 'pri
variant={variant}
onChange={()=>onChange?.(index)}
className={item.props.className}

TitleFontSize={TitleFontSize}
/>
)
})}
Expand Down

0 comments on commit d587cd1

Please sign in to comment.