diff --git a/plugins/woocommerce-admin/client/components/table/style.scss b/plugins/woocommerce-admin/client/components/table/style.scss index 1b780f8a694..ad37901b596 100644 --- a/plugins/woocommerce-admin/client/components/table/style.scss +++ b/plugins/woocommerce-admin/client/components/table/style.scss @@ -3,7 +3,7 @@ .woocommerce-table { .woocommerce-card__body { padding: 0; - padding-bottom: $gap; + position: relative; } .woocommerce-card__action, @@ -28,6 +28,14 @@ height: auto; } } + + .woocommerce-pagination { + padding-top: $gap; + padding-bottom: $gap; + z-index: 1; + background: white; + position: relative; + } } .woocommerce-table__caption { @@ -37,7 +45,21 @@ .woocommerce-table__table { overflow-x: auto; - margin-bottom: $gap; + + &:after { + content: ''; + position: absolute; + right: 0; + top: 0; + width: 41px; + height: 100%; + background: linear-gradient(90deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.2)); + visibility: hidden; + } + + &.is-scrollable:after { + visibility: visible; + } table { border-collapse: collapse; diff --git a/plugins/woocommerce-admin/client/components/table/table.js b/plugins/woocommerce-admin/client/components/table/table.js index f4d13a4b5c1..e2e42bb961c 100644 --- a/plugins/woocommerce-admin/client/components/table/table.js +++ b/plugins/woocommerce-admin/client/components/table/table.js @@ -55,6 +55,7 @@ class Table extends Component { super( props ); this.state = { tabIndex: null, + isScrollable: false, }; this.container = createRef(); this.sortBy = this.sortBy.bind( this ); @@ -68,6 +69,12 @@ class Table extends Component { tabIndex: scrollable ? '0' : null, } ); /* eslint-enable react/no-did-mount-set-state */ + this.updateTableShadow(); + window.addEventListener( 'resize', this.updateTableShadow ); + } + + componentDidUnmount() { + window.removeEventListener( 'resize', this.updateTableShadow ); } sortBy( key ) { @@ -84,6 +91,14 @@ class Table extends Component { }; } + updateTableShadow = () => { + const table = this.container.current; + const scrolledToEnd = table.scrollWidth - table.scrollLeft <= table.offsetWidth; + this.setState( { + isScrollable: scrolledToEnd ? false : true, + } ); + }; + render() { const { ariaHidden, @@ -96,7 +111,9 @@ class Table extends Component { rows, } = this.props; const { tabIndex } = this.state; - const classes = classnames( 'woocommerce-table__table', classNames ); + const classes = classnames( 'woocommerce-table__table', classNames, { + 'is-scrollable': this.state.isScrollable, + } ); const sortedBy = query.orderby || get( find( headers, { defaultSort: true } ), 'key', false ); const sortDir = query.order || DESC; @@ -108,6 +125,7 @@ class Table extends Component { aria-hidden={ ariaHidden } aria-labelledby={ `caption-${ instanceId }` } role="group" + onScroll={ this.updateTableShadow } >