Skip to content

Commit

Permalink
feat #344 - Tabs: Add activeTabClasses prop
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-dassana committed Jun 17, 2021
1 parent 68e7ab0 commit 6f77443
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/Tabs/Tab.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import cn from 'classnames'
import { createUseStyles } from 'react-jss'
import { generateThemedActiveTabStyles } from './utils'
import { TabsProps } from '.'
import React, { FC } from 'react'
import { styleguide, ThemeType } from 'components/assets/styles'

Expand Down Expand Up @@ -38,14 +39,15 @@ const useStyles = createUseStyles({
}
})

interface TabProps {
interface TabProps extends Pick<TabsProps, 'activeTabClasses'> {
isActiveTab: boolean
label: string
tabIndex: number
onClickTab: (tabIndex: number) => void
}

const Tab: FC<TabProps> = ({
activeTabClasses = [],
isActiveTab,
label,
onClickTab,
Expand All @@ -55,7 +57,8 @@ const Tab: FC<TabProps> = ({

const tabClasses = cn({
[classes.tab]: true,
[classes.activeTab]: isActiveTab
[classes.activeTab]: isActiveTab,
[cn(activeTabClasses)]: isActiveTab
})

return (
Expand Down
3 changes: 3 additions & 0 deletions src/components/Tabs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ export interface TabConfig {
}

export interface TabsProps {
activeTabClasses?: string[]
classes?: string[]
defaultActiveIndex?: number
onTabChange?: (data: TabConfig) => void
tabConfig: TabConfig[]
}

export const Tabs: FC<TabsProps> = ({
activeTabClasses = [],
classes = [],
defaultActiveIndex = 0,
onTabChange,
Expand All @@ -71,6 +73,7 @@ export const Tabs: FC<TabsProps> = ({
const renderTabItems = () =>
tabConfig.map(({ key, label }: TabConfig, i) => (
<Tab
activeTabClasses={activeTabClasses}
isActiveTab={i === activeIndex}
key={key}
label={label}
Expand Down

0 comments on commit 6f77443

Please sign in to comment.