From 8bc9f39441bd0ce680c26d9b65f95830c68baf8f Mon Sep 17 00:00:00 2001 From: Adam Wood <1017872+adamwoodnz@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:15:37 +1300 Subject: [PATCH] Make back to top link optional --- mu-plugins/blocks/sidebar-container/index.php | 10 ++++++---- mu-plugins/blocks/sidebar-container/postcss/style.pcss | 3 +-- mu-plugins/blocks/sidebar-container/src/block.json | 7 ++++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/mu-plugins/blocks/sidebar-container/index.php b/mu-plugins/blocks/sidebar-container/index.php index 248c386b2..08edf085d 100644 --- a/mu-plugins/blocks/sidebar-container/index.php +++ b/mu-plugins/blocks/sidebar-container/index.php @@ -39,10 +39,12 @@ function init() { * @return string Returns the block markup. */ function render( $attributes, $content, $block ) { - $back_to_top = sprintf( - '
', - esc_html__( '↑ Back to top', 'wporg' ) - ); + $back_to_top = $attributes['hasBackToTop'] + ? sprintf( + '', + esc_html__( '↑ Back to top', 'wporg' ) + ) + : ''; $wrapper_attributes = get_block_wrapper_attributes(); return sprintf( diff --git a/mu-plugins/blocks/sidebar-container/postcss/style.pcss b/mu-plugins/blocks/sidebar-container/postcss/style.pcss index c9e1b45cc..b1a05dd91 100644 --- a/mu-plugins/blocks/sidebar-container/postcss/style.pcss +++ b/mu-plugins/blocks/sidebar-container/postcss/style.pcss @@ -18,7 +18,7 @@ width: var(--local--block-end-sidebar--width); margin-bottom: 0 !important; - padding-top: var(--wp--preset--spacing--20); + padding: var(--wp--preset--spacing--20) 0; main & { position: absolute; @@ -67,7 +67,6 @@ * + .is-link-to-top { border-top: 1px solid var(--wp--preset--color--light-grey-1); - padding-bottom: var(--wp--preset--spacing--20); } } } diff --git a/mu-plugins/blocks/sidebar-container/src/block.json b/mu-plugins/blocks/sidebar-container/src/block.json index 90d9b5ede..d9dacae3e 100644 --- a/mu-plugins/blocks/sidebar-container/src/block.json +++ b/mu-plugins/blocks/sidebar-container/src/block.json @@ -7,7 +7,12 @@ "category": "layout", "description": "A sticky container to be used in 2-column layouts.", "textdomain": "wporg", - "attributes": {}, + "attributes": { + "hasBackToTop": { + "type": "boolean", + "default": false + } + }, "supports": { "inserter": false, "__experimentalLayout": true,