From 628d15cc1ca09283875265a813cb995a50d6a5e6 Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Tue, 12 Nov 2024 14:09:43 +1100 Subject: [PATCH] Make items non-clickable --- packages/edit-site/src/classic-stylebook.js | 4 --- .../src/components/style-book/index.js | 25 +++++++++++-------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/packages/edit-site/src/classic-stylebook.js b/packages/edit-site/src/classic-stylebook.js index 5ab78a8af49ea..8c62ce35b32a5 100644 --- a/packages/edit-site/src/classic-stylebook.js +++ b/packages/edit-site/src/classic-stylebook.js @@ -68,13 +68,9 @@ function ClassicStylebookLayout() { enableResizing={ false } showCloseButton={ false } showTabs={ false } - isSelected={ () => null } - onSelect={ () => null } examples={ examplesForSinglePageUse } - onClick={ () => null } settings={ settings } sizes={ sizes } - goTo={ {} } /> ), }, diff --git a/packages/edit-site/src/components/style-book/index.js b/packages/edit-site/src/components/style-book/index.js index 2f6090f60fd00..99881cc762797 100644 --- a/packages/edit-site/src/components/style-book/index.js +++ b/packages/edit-site/src/components/style-book/index.js @@ -445,7 +445,11 @@ const Examples = memo( content={ example.content } blocks={ example.blocks } isSelected={ isSelected?.( example.name ) } - onClick={ () => onSelect?.( example.name ) } + onClick={ + !! onSelect + ? () => onSelect( example.name ) + : null + } /> ) ) } { !! filteredExamples?.subcategories?.length && @@ -482,9 +486,7 @@ const Subcategory = ( { examples, isSelected, onSelect } ) => { content={ example.content } blocks={ example.blocks } isSelected={ isSelected?.( example.name ) } - onClick={ () => { - onSelect?.( example.name ); - } } + onClick={ !! onSelect ? () => onSelect( example.name ) : null } /> ) ) ); @@ -512,12 +514,13 @@ const Example = ( { id, title, blocks, isSelected, onClick, content } ) => { [ blocks ] ); - const disabledProps = disabledExamples.includes( id ) - ? { - disabled: true, - accessibleWhenDisabled: true, - } - : {}; + const disabledProps = + disabledExamples.includes( id ) || ! onClick + ? { + disabled: true, + accessibleWhenDisabled: !! onClick, + } + : {}; return (
@@ -534,7 +537,7 @@ const Example = ( { id, title, blocks, isSelected, onClick, content } ) => { title ) } render={
} - role="button" + role={ !! onClick ? 'button' : null } onClick={ onClick } { ...disabledProps } >