Skip to content

Commit

Permalink
fix(DFD-274): Update tab panel component to use classname and remove …
Browse files Browse the repository at this point in the history
…useless gap
  • Loading branch information
Alexandre Amalric committed Nov 15, 2023
1 parent 6739849 commit bf4c654
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/weak-olives-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@talend/design-system': minor
---

fix(DFD-274): Update tab panel component to use classname and remove useless gap
21 changes: 12 additions & 9 deletions packages/design-system/src/components/Tabs/Primitive/TabPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { useContext } from 'react';
import classNames from 'classnames';

import { TabsInternalContext } from './TabsProvider';
import style from './TabStyles.module.scss';

export type TabPanelPropTypes = {
id: string;
Expand All @@ -9,17 +12,17 @@ export type TabPanelPropTypes = {

export function TabPanel({ children, id, renderIf }: TabPanelPropTypes): JSX.Element {
const context = useContext(TabsInternalContext);
const style = {
display: '',
};
if (id !== context?.value) {
if (renderIf) {
return <></>;
}
style.display = 'none';
if (id !== context?.value && renderIf) {
return <></>;
}

return (
<div id={id} role="tabpanel" style={style} tabIndex={0}>
<div
id={id}
role="tabpanel"
className={classNames(style.tabpanel, { [style['tabpanel--hidden']]: id !== context?.value })}
tabIndex={0}
>
{children}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
column-gap: var(--coral-spacing-m, 1.6rem);
}

.tabpanel {
width: 100%;
height: 100%;

&--hidden {
display: none;
}
}

.tab {
font: tokens.$coral-heading-s;
height: tokens.$coral-sizing-xs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function TabsProvider(props: TabsProviderPropTypes & WithChildren) {
});
return (
<nav id={props.id}>
<StackVertical gap="M">
<StackVertical gap={0}>
<TabsInternalContext.Provider value={{ size: props.size, ...controlled }}>
{props.children}
</TabsInternalContext.Provider>
Expand Down

0 comments on commit bf4c654

Please sign in to comment.