From 3532fc602d3c8c96181db38636b68263e9bafa2f Mon Sep 17 00:00:00 2001 From: Austin Sullivan Date: Thu, 5 May 2022 13:21:22 -0700 Subject: [PATCH] feat(tabs): add secondary border-bottom variation, update demos (#7311) * feat(tabs): add secondary border-bottom variation, update demos * improve prop description Co-authored-by: Jenny <32821331+jenny-s51@users.noreply.github.com> * sentence case test aria labels Co-authored-by: Jenny <32821331+jenny-s51@users.noreply.github.com> --- .../react-core/src/components/Tabs/Tabs.tsx | 6 +- .../components/Tabs/__tests__/Tabs.test.tsx | 41 ++++++- packages/react-core/src/demos/Tabs.md | 110 +++++++++--------- 3 files changed, 98 insertions(+), 59 deletions(-) diff --git a/packages/react-core/src/components/Tabs/Tabs.tsx b/packages/react-core/src/components/Tabs/Tabs.tsx index 3a57d4fb9cd..6428f31e67f 100644 --- a/packages/react-core/src/components/Tabs/Tabs.tsx +++ b/packages/react-core/src/components/Tabs/Tabs.tsx @@ -41,8 +41,10 @@ export interface TabsProps extends Omit { isVertical, isBox, hasBorderBottom, + hasSecondaryBorderBottom, leftScrollAriaLabel, rightScrollAriaLabel, 'aria-label': ariaLabel, @@ -361,6 +364,7 @@ export class Tabs extends React.Component { showScrollButtons && !isVertical && styles.modifiers.scrollable, usePageInsets && styles.modifiers.pageInsets, !hasBorderBottom && styles.modifiers.noBorderBottom, + hasSecondaryBorderBottom && styles.modifiers.borderBottom, formatBreakpointMods(inset, styles), variantStyle[variant], className diff --git a/packages/react-core/src/components/Tabs/__tests__/Tabs.test.tsx b/packages/react-core/src/components/Tabs/__tests__/Tabs.test.tsx index d7ac98364eb..a12c8c386de 100644 --- a/packages/react-core/src/components/Tabs/__tests__/Tabs.test.tsx +++ b/packages/react-core/src/components/Tabs/__tests__/Tabs.test.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { render } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import { Tabs } from '../Tabs'; import { Tab } from '../Tab'; import { TabTitleText } from '../TabTitleText'; @@ -350,3 +350,42 @@ test('should render tabs with no bottom border', () => { expect(asFragment()).toMatchSnapshot(); }); +test('should not render tabs with secondary border bottom when not passed hasSecondaryBorderBottom', () => { + render( + + "Tab item 1"}> + Tab 1 section + + "Tab item 2"}> + Tab 2 section + + "Tab item 3"}> + Tab 3 section + + + ); + + const tabsContainer = screen.queryByLabelText('Secondary bottom border'); + + expect(tabsContainer).not.toHaveClass('pf-m-border-bottom'); +}); + +test('should render tabs with secondary border bottom when passed hasSecondaryBorderBottom', () => { + render( + + "Tab item 1"}> + Tab 1 section + + "Tab item 2"}> + Tab 2 section + + "Tab item 3"}> + Tab 3 section + + + ); + + const tabsContainer = screen.queryByLabelText('Secondary bottom border'); + + expect(tabsContainer).toHaveClass('pf-m-border-bottom'); +}); diff --git a/packages/react-core/src/demos/Tabs.md b/packages/react-core/src/demos/Tabs.md index f61407ee175..4e75cb7c985 100644 --- a/packages/react-core/src/demos/Tabs.md +++ b/packages/react-core/src/demos/Tabs.md @@ -378,65 +378,60 @@ TabsOpenWithSecondaryTabsDemo = () => { Terminal} tabContentId={`tabContent${4}`} /> - - - - - - - - - - + + + + + + ); @@ -467,6 +462,7 @@ TabsOpenWithSecondaryTabsDemo = () => { ```js isFullscreen file="./examples/Tabs/ModalTabs.tsx" ``` + ### Gray tabs ```js isFullscreen file="./examples/Tabs/GrayTabs.tsx"