Skip to content

Commit

Permalink
Make back to top link optional
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwoodnz committed Jan 12, 2024
1 parent 78186e9 commit 8bc9f39
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
10 changes: 6 additions & 4 deletions mu-plugins/blocks/sidebar-container/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ function init() {
* @return string Returns the block markup.
*/
function render( $attributes, $content, $block ) {
$back_to_top = sprintf(
'<p class="has-small-font-size is-link-to-top"><a href="#wp--skip-link--target">%s</a></p>',
esc_html__( '↑ Back to top', 'wporg' )
);
$back_to_top = $attributes['hasBackToTop']
? sprintf(
'<p class="has-small-font-size is-link-to-top"><a href="#wp--skip-link--target">%s</a></p>',
esc_html__( '↑ Back to top', 'wporg' )
)
: '';

$wrapper_attributes = get_block_wrapper_attributes();
return sprintf(
Expand Down
3 changes: 1 addition & 2 deletions mu-plugins/blocks/sidebar-container/postcss/style.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion mu-plugins/blocks/sidebar-container/src/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8bc9f39

Please sign in to comment.