diff --git a/plugins/woocommerce-blocks/assets/js/base/components/index.ts b/plugins/woocommerce-blocks/assets/js/base/components/index.ts index 3275bd602d9..ac18ea408aa 100644 --- a/plugins/woocommerce-blocks/assets/js/base/components/index.ts +++ b/plugins/woocommerce-blocks/assets/js/base/components/index.ts @@ -27,4 +27,3 @@ export * from './sidebar-layout'; export * from './snackbar-list'; export * from './state-input'; export * from './summary'; -export * from './tabs'; diff --git a/plugins/woocommerce-blocks/assets/js/base/components/tabs/index.tsx b/plugins/woocommerce-blocks/assets/js/base/components/tabs/index.tsx deleted file mode 100644 index 0b88edcc373..00000000000 --- a/plugins/woocommerce-blocks/assets/js/base/components/tabs/index.tsx +++ /dev/null @@ -1,123 +0,0 @@ -/** - * External dependencies - */ -import { withInstanceId } from '@wordpress/compose'; -import classnames from 'classnames'; -import { __ } from '@wordpress/i18n'; -import { useTabState, Tab, TabList, TabPanel } from 'reakit/Tab'; -/** - * Internal dependencies - */ -import './style.scss'; - -export interface TabsProps { - /** - * Component wrapper classname - */ - className?: string; - /** - * Event handler triggered when a tab is selected - */ - onSelect?: ( tabName: string ) => void; - /** - * Array of tab objects - */ - tabs: Array< { - name: string; - title: string; - content: JSX.Element; - ariaLabel?: string; - } >; - /** - * Classname to be applied to the active tab - */ - activeClass?: string; - /** - * Name of the tab to be selected by default - */ - initialTabName?: string | undefined; - /** - * Aria label for the tablist - */ - ariaLabel?: string; - /** - * Instance ID for the component - */ - instanceId: number; - /** - * ID for the component - */ - id?: string; -} - -/** - * Exporting the component for Storybook. Use the default export instead. - */ -export const __TabsWithoutInstanceId = ( { - className, - onSelect = () => null, - tabs, - activeClass = 'is-active', - initialTabName, - ariaLabel = __( 'Tabbed Content', 'woocommerce' ), - instanceId, - id, -}: TabsProps ): JSX.Element | null => { - const initialTab = initialTabName - ? { selectedId: `${ instanceId }-${ initialTabName }` } - : undefined; - const tabState = useTabState( initialTab ); - if ( tabs.length === 0 ) { - return null; - } - return ( -
- - { tabs.map( ( { name, title, ariaLabel: tabAriaLabel } ) => ( - onSelect( name ) } - type="button" - key={ name } - aria-label={ tabAriaLabel } - > - - { title } - - - ) ) } - - - { tabs.map( ( { name, content } ) => ( - - { tabState.selectedId === `${ instanceId }-${ name }` && - content } - - ) ) } -
- ); -}; - -export default withInstanceId( __TabsWithoutInstanceId ); diff --git a/plugins/woocommerce-blocks/assets/js/base/components/tabs/stories/index.stories.tsx b/plugins/woocommerce-blocks/assets/js/base/components/tabs/stories/index.stories.tsx deleted file mode 100644 index 1be8237ade7..00000000000 --- a/plugins/woocommerce-blocks/assets/js/base/components/tabs/stories/index.stories.tsx +++ /dev/null @@ -1,54 +0,0 @@ -/** - * External dependencies - */ -import type { Story, Meta } from '@storybook/react'; -import { useState } from '@wordpress/element'; - -/** - * Internal dependencies - */ -import { __TabsWithoutInstanceId as Tabs, TabsProps } from '..'; - -export default { - title: 'Base Components/Tabs', - component: Tabs, - args: { - tabs: [ - { - name: 'firstTab', - title: 'First Tab', - content:
Content of the first tab
, - }, - { - name: 'secondTab', - title: 'Second Tab', - content:
Content of the second tab
, - }, - ], - initialTabName: 'firstTab', - }, - argTypes: { - initialTabName: { - control: { - type: 'select', - options: [ 'firstTab', 'secondTab' ], - }, - }, - }, -} as Meta< TabsProps >; - -const Template: Story< TabsProps > = ( args ) => { - const [ initialTab, setInitialTab ] = useState( args.initialTabName ); - - return ( - { - setInitialTab( newTabName ); - } } - { ...args } - /> - ); -}; - -export const Default = Template.bind( {} ); diff --git a/plugins/woocommerce-blocks/assets/js/base/components/tabs/style.scss b/plugins/woocommerce-blocks/assets/js/base/components/tabs/style.scss deleted file mode 100644 index 19a1055940b..00000000000 --- a/plugins/woocommerce-blocks/assets/js/base/components/tabs/style.scss +++ /dev/null @@ -1,60 +0,0 @@ -.wc-block-components-tabs { - .wc-block-components-tabs__list { - display: flex; - flex-direction: row; - flex-wrap: wrap; - width: 100%; - > .wc-block-components-tabs__item { - border: none; - flex: auto; - background: transparent; - padding: $gap-small $gap; - color: inherit; - outline-offset: -1px; - text-align: center; - transition: box-shadow 0.1s linear; - box-shadow: inset 0 -1px currentColor; - border-radius: 0; - &.is-active { - box-shadow: inset 0 -3px currentColor; - font-weight: 600; - position: relative; - } - &:focus { - outline-offset: -1px; - outline: 1px dotted currentColor; - } - &:hover, - &:active { - background: transparent; - } - .wc-block-components-tabs__item-content { - @include font-size(regular); - line-height: 1; - width: fit-content; - display: inline-block; - font-weight: bold; - - > img, - > svg { - height: 1.2em; - vertical-align: middle; - margin: 0.2em 0 -0.2em; - } - - .wc-block-components-payment-method-icons { - margin: 0.2em 0 -0.2em; - - .wc-block-components-payment-method-icon { - height: 1.2em; - vertical-align: middle; - } - } - } - } - } - .wc-block-components-tabs__content { - padding: $gap 0; - text-transform: none; - } -} diff --git a/plugins/woocommerce-blocks/package.json b/plugins/woocommerce-blocks/package.json index 2d113b6e735..e08dba0ec7d 100644 --- a/plugins/woocommerce-blocks/package.json +++ b/plugins/woocommerce-blocks/package.json @@ -314,7 +314,6 @@ "prop-types": "^15.8.1", "react-number-format": "4.9.3", "react-transition-group": "^4.4.5", - "reakit": "1.3.11", "request": "2.88.2", "trim-html": "0.1.9", "use-debounce": "9.0.4", diff --git a/plugins/woocommerce/changelog/46219-dev-delete-base-tabs-component b/plugins/woocommerce/changelog/46219-dev-delete-base-tabs-component new file mode 100644 index 00000000000..0bca412defd --- /dev/null +++ b/plugins/woocommerce/changelog/46219-dev-delete-base-tabs-component @@ -0,0 +1,4 @@ +Significance: patch +Type: dev +Comment: Remove the unused WooCommerce blocks Tabs component, remove Reakit dependency. + diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8736fa659f2..6b13ba13946 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3965,9 +3965,6 @@ importers: react-transition-group: specifier: ^4.4.5 version: 4.4.5(react-dom@17.0.2)(react@17.0.2) - reakit: - specifier: 1.3.11 - version: 1.3.11(react-dom@17.0.2)(react@17.0.2) request: specifier: 2.88.2 version: 2.88.2 @@ -45305,7 +45302,6 @@ packages: prop-types: 15.8.1 react: 17.0.2 scheduler: 0.19.1 - bundledDependencies: false /react-dom@17.0.2(react@17.0.2): resolution: {integrity: sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==} @@ -45838,7 +45834,6 @@ packages: react-is: 16.13.1 scheduler: 0.19.1 dev: true - bundledDependencies: false /react-test-renderer@17.0.2(react@17.0.2): resolution: {integrity: sha512-yaQ9cB89c17PUb0x6UfWRs7kQCorVdHlutU1boVPEsB8IDZH6n9tHxMacc3y0JoXOJUsZb/t/Mb8FUWMKaM7iQ==}