diff --git a/packages/block-library/src/table/block.json b/packages/block-library/src/table/block.json index 60d8164a5e463..32e380693b409 100644 --- a/packages/block-library/src/table/block.json +++ b/packages/block-library/src/table/block.json @@ -126,6 +126,12 @@ "__experimentalSkipSerialization": true, "gradients": true }, + "__experimentalBorder": { + "__experimentalSkipSerialization": true, + "color": true, + "style": true, + "width": true + }, "__experimentalSelector": ".wp-block-table > table" }, "editorStyle": "wp-block-table-editor", diff --git a/packages/block-library/src/table/edit.js b/packages/block-library/src/table/edit.js index 310c8b189877c..22e756bdd450b 100644 --- a/packages/block-library/src/table/edit.js +++ b/packages/block-library/src/table/edit.js @@ -15,6 +15,7 @@ import { AlignmentToolbar, useBlockProps, __experimentalUseColorProps as useColorProps, + __experimentalUseBorderProps as useBorderProps, } from '@wordpress/block-editor'; import { __ } from '@wordpress/i18n'; import { @@ -103,6 +104,7 @@ function TableEdit( { const [ selectedCell, setSelectedCell ] = useState(); const colorProps = useColorProps( attributes ); + const borderProps = useBorderProps( attributes ); /** * Updates the initial column count used for table creation. @@ -477,10 +479,12 @@ function TableEdit( { ) } { ! isEmpty && ( { renderedSections }
diff --git a/packages/block-library/src/table/save.js b/packages/block-library/src/table/save.js index dbc2e389bf875..a2aaef4f81a78 100644 --- a/packages/block-library/src/table/save.js +++ b/packages/block-library/src/table/save.js @@ -9,6 +9,7 @@ import classnames from 'classnames'; import { RichText, useBlockProps, + __experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles, __experimentalGetColorClassesAndStyles as getColorClassesAndStyles, } from '@wordpress/block-editor'; @@ -21,8 +22,9 @@ export default function save( { attributes } ) { } const colorProps = getColorClassesAndStyles( attributes ); + const borderProps = getBorderClassesAndStyles( attributes ); - const classes = classnames( colorProps.className, { + const classes = classnames( colorProps.className, borderProps.className, { 'has-fixed-layout': hasFixedLayout, } ); @@ -73,7 +75,7 @@ export default function save( { attributes } ) {
diff --git a/packages/block-library/src/table/style.scss b/packages/block-library/src/table/style.scss index 0a18b92b5b8d4..f5c61cdc36938 100644 --- a/packages/block-library/src/table/style.scss +++ b/packages/block-library/src/table/style.scss @@ -97,4 +97,36 @@ border-bottom: 1px solid $gray-100; } + + // Border Styles + // + // Allow any custom border color, style or width selections to be inherited + // from the table element that receives the border support props. + + .has-border-color { + > *, + tr, + th, + td { + border-color: inherit; + } + } + + table[style*="border-style"] { + > *, + tr, + th, + td { + border-style: inherit; + } + } + + table[style*="border-width"] { + > *, + tr, + th, + td { + border-width: inherit; + } + } }