diff --git a/plugins/woocommerce-admin/client/dashboard/dashboard-charts/index.js b/plugins/woocommerce-admin/client/dashboard/dashboard-charts/index.js index b71eeee0ffb..b7492eae7df 100644 --- a/plugins/woocommerce-admin/client/dashboard/dashboard-charts/index.js +++ b/plugins/woocommerce-admin/client/dashboard/dashboard-charts/index.js @@ -89,7 +89,7 @@ class DashboardCharts extends Component { return ( ( + renderContent={ ( { onToggle } ) => ( { window.wcAdminFeatures[ 'dashboard/customizable' ] && (
diff --git a/plugins/woocommerce-admin/client/dashboard/leaderboards/index.js b/plugins/woocommerce-admin/client/dashboard/leaderboards/index.js index 3d4f769142f..cb50d21c70e 100644 --- a/plugins/woocommerce-admin/client/dashboard/leaderboards/index.js +++ b/plugins/woocommerce-admin/client/dashboard/leaderboards/index.js @@ -73,7 +73,7 @@ class Leaderboards extends Component { 'Choose which leaderboards to display and other settings', 'woocommerce-admin' ) } - renderChildren={ ( { onToggle } ) => ( + renderContent={ ( { onToggle } ) => ( { window.wcAdminFeatures[ 'dashboard/customizable' ] && (
diff --git a/plugins/woocommerce-admin/client/dashboard/store-performance/index.js b/plugins/woocommerce-admin/client/dashboard/store-performance/index.js index e22414db295..1f9c3dc7345 100644 --- a/plugins/woocommerce-admin/client/dashboard/store-performance/index.js +++ b/plugins/woocommerce-admin/client/dashboard/store-performance/index.js @@ -84,7 +84,7 @@ class StorePerformance extends Component { 'Choose which analytics to display and the section name', 'woocommerce-admin' ) } - renderChildren={ ( { onToggle } ) => ( + renderContent={ ( { onToggle } ) => ( { window.wcAdminFeatures[ 'dashboard/customizable' ] && (
diff --git a/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js b/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js index 02cda56c563..913a6925ece 100644 --- a/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js +++ b/plugins/woocommerce-admin/client/header/activity-panel/panels/orders.js @@ -235,10 +235,15 @@ class OrdersPanel extends Component { } const menu = ( - - Test - Test - + ( + + Test + Test + + ) } + /> ); const title = diff --git a/plugins/woocommerce-admin/packages/components/CHANGELOG.md b/plugins/woocommerce-admin/packages/components/CHANGELOG.md index 7e4024d19fb..b8dfe1ad61c 100644 --- a/plugins/woocommerce-admin/packages/components/CHANGELOG.md +++ b/plugins/woocommerce-admin/packages/components/CHANGELOG.md @@ -1,7 +1,8 @@ -# unreleased +# 3.0.0 (unreleased) - TableCard component: new `onPageChange` prop. - Pagination no longer considers `0` a valid input and triggers `onPageChange` on the input blur event. - Tweaks to SummaryListPlaceholder height in order to better match SummaryNumber. +- EllipsisMenu component (breaking change): Remove `children` prop in favor of a render prop `renderContent` so that function arguments `isOpen`, `onToggle`, and `onClose` can be passed down. # 2.0.0 - Chart legend component now uses withInstanceId HOC so the ids used in several HTML elements are unique. diff --git a/plugins/woocommerce-admin/packages/components/src/ellipsis-menu/example.md b/plugins/woocommerce-admin/packages/components/src/ellipsis-menu/example.md index 7638ee934ab..77719df68f1 100644 --- a/plugins/woocommerce-admin/packages/components/src/ellipsis-menu/example.md +++ b/plugins/woocommerce-admin/packages/components/src/ellipsis-menu/example.md @@ -1,26 +1,40 @@ ```jsx -import { EllipsisMenu, MenuItem, MenuTitle } from '@woocommerce/components'; +import { EllipsisMenu, MenuItem, MenuTitle, Button } from '@woocommerce/components'; const MyEllipsisMenu = withState( { showCustomers: true, showOrders: true, } )( ( { setState, showCustomers, showOrders } ) => ( - - Display Stats - setState( { showCustomers: ! showCustomers } ) }> - setState( { showCustomers: ! showCustomers } ) } - /> - - setState( { showOrders: ! showOrders } ) }> - setState( { showOrders: ! showOrders } ) } - /> - - + { + return ( +
+ Display Stats + setState( { showCustomers: ! showCustomers } ) }> + setState( { showCustomers: ! showCustomers } ) } + /> + + setState( { showOrders: ! showOrders } ) }> + setState( { showOrders: ! showOrders } ) } + /> + + + + +
+ ); + } } + /> ) ); ``` diff --git a/plugins/woocommerce-admin/packages/components/src/ellipsis-menu/index.js b/plugins/woocommerce-admin/packages/components/src/ellipsis-menu/index.js index ac5309ec2ef..58262e703af 100644 --- a/plugins/woocommerce-admin/packages/components/src/ellipsis-menu/index.js +++ b/plugins/woocommerce-admin/packages/components/src/ellipsis-menu/index.js @@ -12,12 +12,12 @@ import PropTypes from 'prop-types'; */ class EllipsisMenu extends Component { render() { - const { children, label, renderChildren } = this.props; - if ( ! children && ! renderChildren ) { + const { label, renderContent } = this.props; + if ( ! renderContent ) { return null; } - const renderToggle = ( { onToggle, isOpen } ) => { + const renderEllipsis = ( { onToggle, isOpen } ) => { const toggleClassname = classnames( 'woocommerce-ellipsis-menu__toggle', { 'is-opened': isOpen, } ); @@ -33,11 +33,9 @@ class EllipsisMenu extends Component { ); }; - // @todo Make all children rendered by render props so Dropdown args can be passed? - const renderContent = renderContentArgs => ( + const renderMenu = renderContentArgs => ( - { children && children } - { renderChildren && renderChildren( renderContentArgs ) } + { renderContent( renderContentArgs ) } ); @@ -46,8 +44,8 @@ class EllipsisMenu extends Component {
); @@ -60,13 +58,9 @@ EllipsisMenu.propTypes = { */ label: PropTypes.string.isRequired, /** - * A list of `MenuTitle`/`MenuItem` components + * A function returning `MenuTitle`/`MenuItem` components as a render prop. Arguments from Dropdown passed as function arguments. */ - children: PropTypes.node, - /** - * A list of `MenuTitle`/`MenuItem` components as a render prop. Arguments from Dropdown passed as function arguments. - */ - renderChildren: PropTypes.func, + renderContent: PropTypes.func, }; export default EllipsisMenu; diff --git a/plugins/woocommerce-admin/packages/components/src/table/index.js b/plugins/woocommerce-admin/packages/components/src/table/index.js index 6dcd4fd26ef..dbf7f5f2ece 100644 --- a/plugins/woocommerce-admin/packages/components/src/table/index.js +++ b/plugins/woocommerce-admin/packages/components/src/table/index.js @@ -340,25 +340,29 @@ class TableCard extends Component { ), ] } menu={ - showMenu && - { __( 'Columns:', 'woocommerce-admin' ) } - { allHeaders.map( ( { key, label, required } ) => { - if ( required ) { - return null; - } - return ( - - { label } - - ); - } ) } - + showMenu && ( + + { __( 'Columns:', 'woocommerce-admin' ) } + { allHeaders.map( ( { key, label, required } ) => { + if ( required ) { + return null; + } + return ( + + { label } + + ); + } ) } + + ) } + /> } > { isLoading ? (