Skip to content

Commit

Permalink
feat(tab bar component): added a hidden-panel prop
Browse files Browse the repository at this point in the history
added hidden-panel prop so the user can specify when the tab content should appear
  • Loading branch information
gustavoFreireS committed Aug 30, 2019
1 parent 3ba3385 commit fb5f46d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
24 changes: 13 additions & 11 deletions src/components/tabs/tab-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface ITabBarProps {
onTabsChange?: (modifiedList: ITab[], tabList?: ReactChildren) => void;
closeIcon?: ReactElement;
className?: string;
hiddenPanel?: boolean;
}

const TabBar = (props: ITabBarProps) => {
Expand Down Expand Up @@ -245,17 +246,18 @@ const TabBar = (props: ITabBarProps) => {
</span>
)}
</div>
{tabList.map((child: any) => {
return (
<div
id={`${child.id}-panel`}
key={`${child.id}-panel`}
className={`tab-panel ${checkActive(child) ? 'active' : ''}`}
>
{child.tabComponent}
</div>
);
})}
{!props.hiddenPanel &&
tabList.map((child: any) => {
return (
<div
id={`${child.id}-panel`}
key={`${child.id}-panel`}
className={`tab-panel ${checkActive(child) ? 'active' : ''}`}
>
{child.tabComponent}
</div>
);
})}
</Fragment>
);
};
Expand Down
8 changes: 7 additions & 1 deletion src/components/testInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ const TabInterface = () => {
);
};
return (
<TabBar closeable={true} reorderable={true} newTab={createNew} className="small-tab">
<TabBar
closeable={true}
reorderable={true}
newTab={createNew}
className="small-tab"
hiddenPanel
>
<Tab text="first tab" classNameActive="red-header" className="the-rest">
<form className="frm">
<h1>Form 1</h1>
Expand Down

0 comments on commit fb5f46d

Please sign in to comment.