Skip to content

Commit

Permalink
feat(TabList): add opt-out for default padding (#1915)
Browse files Browse the repository at this point in the history
  • Loading branch information
YossiSaadi authored Jan 25, 2024
1 parent ea01ce4 commit b7be6bf
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 48 deletions.
4 changes: 4 additions & 0 deletions src/components/Tabs/TabList/TabList.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

.tabsWrapper {
padding-bottom: 20px;

&.noPadding {
padding-bottom: 0;
}
}

.tabsWrapper .tabsList {
Expand Down
6 changes: 5 additions & 1 deletion src/components/Tabs/TabList/TabList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface TabListProps extends VibeComponentProps {
activeTabId?: number;
tabType?: string;
size?: string;
noPadding?: boolean;
children?: ReactElement<TabProps>[];
}

Expand All @@ -28,6 +29,7 @@ const TabList: FC<TabListProps> = forwardRef(
activeTabId = 0,
tabType = "Compact",
size,
noPadding,
children,
"data-testid": dataTestId
},
Expand Down Expand Up @@ -105,7 +107,9 @@ const TabList: FC<TabListProps> = forwardRef(
return (
<div
ref={mergedRef}
className={cx(styles.tabsWrapper, className, [getStyle(styles, camelCase(tabType))])}
className={cx(styles.tabsWrapper, { [styles.noPadding]: noPadding }, className, [
getStyle(styles, camelCase(tabType))
])}
id={id}
data-testid={dataTestId || getTestId(ComponentDefaultTestId.TAB_LIST, id)}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`TabList renders correctly stretched tab list 1`] = `
exports[`TabList renders correctly with activeTabId 1`] = `
<div
className="tabsWrapper stretched"
className="tabsWrapper compact"
data-testid="tab-list"
>
<ul
className="tabsList"
role="tablist"
tabIndex={0}
>
<li
aria-disabled={false}
aria-selected={true}
className="tabWrapper tabListTabWrapper active"
data-testid="tab"
role="tab"
>
<a
className="tabInner tabListTabInner"
onClick={[Function]}
>
First
</a>
</li>
<li
aria-disabled={false}
aria-selected={false}
Expand All @@ -35,28 +21,28 @@ exports[`TabList renders correctly stretched tab list 1`] = `
className="tabInner tabListTabInner"
onClick={[Function]}
>
Second
First
</a>
</li>
<li
aria-disabled={false}
aria-selected={false}
className="tabWrapper tabListTabWrapper"
aria-selected={true}
className="tabWrapper tabListTabWrapper active"
data-testid="tab"
role="tab"
>
<a
className="tabInner tabListTabInner"
onClick={[Function]}
>
Third
Second
</a>
</li>
</ul>
</div>
`;

exports[`TabList renders correctly with activeTabId 1`] = `
exports[`TabList renders correctly with children 1`] = `
<div
className="tabsWrapper compact"
data-testid="tab-list"
Expand All @@ -66,20 +52,6 @@ exports[`TabList renders correctly with activeTabId 1`] = `
role="tablist"
tabIndex={0}
>
<li
aria-disabled={false}
aria-selected={false}
className="tabWrapper tabListTabWrapper"
data-testid="tab"
role="tab"
>
<a
className="tabInner tabListTabInner"
onClick={[Function]}
>
First
</a>
</li>
<li
aria-disabled={false}
aria-selected={true}
Expand All @@ -91,16 +63,16 @@ exports[`TabList renders correctly with activeTabId 1`] = `
className="tabInner tabListTabInner"
onClick={[Function]}
>
Second
First
</a>
</li>
</ul>
</div>
`;

exports[`TabList renders correctly with children 1`] = `
exports[`TabList renders correctly with className 1`] = `
<div
className="tabsWrapper compact"
className="tabsWrapper test compact"
data-testid="tab-list"
>
<ul
Expand All @@ -126,10 +98,11 @@ exports[`TabList renders correctly with children 1`] = `
</div>
`;

exports[`TabList renders correctly with className 1`] = `
exports[`TabList renders correctly with id 1`] = `
<div
className="tabsWrapper test compact"
data-testid="tab-list"
className="tabsWrapper compact"
data-testid="tab-list_test"
id="test"
>
<ul
className="tabsList"
Expand All @@ -154,11 +127,10 @@ exports[`TabList renders correctly with className 1`] = `
</div>
`;

exports[`TabList renders correctly with id 1`] = `
exports[`TabList renders correctly with noPadding 1`] = `
<div
className="tabsWrapper compact"
data-testid="tab-list_test"
id="test"
className="tabsWrapper noPadding compact"
data-testid="tab-list"
>
<ul
className="tabsList"
Expand All @@ -179,6 +151,34 @@ exports[`TabList renders correctly with id 1`] = `
First
</a>
</li>
<li
aria-disabled={false}
aria-selected={false}
className="tabWrapper tabListTabWrapper"
data-testid="tab"
role="tab"
>
<a
className="tabInner tabListTabInner"
onClick={[Function]}
>
Second
</a>
</li>
<li
aria-disabled={false}
aria-selected={false}
className="tabWrapper tabListTabWrapper"
data-testid="tab"
role="tab"
>
<a
className="tabInner tabListTabInner"
onClick={[Function]}
>
Third
</a>
</li>
</ul>
</div>
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ describe("TabList renders correctly", () => {
expect(tree).toMatchSnapshot();
});

it("stretched tab list", () => {
it("with noPadding", () => {
const tree = renderer
.create(
<TabList tabType="stretched">
<TabList noPadding>
<Tab>First</Tab>
<Tab>Second</Tab>
<Tab>Third</Tab>
Expand Down

0 comments on commit b7be6bf

Please sign in to comment.