Skip to content

Commit

Permalink
Make items non-clickable
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Nov 18, 2024
1 parent 199f95c commit f13bfb7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
4 changes: 0 additions & 4 deletions packages/edit-site/src/classic-stylebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -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={ {} }
/>
),
},
Expand Down
25 changes: 14 additions & 11 deletions packages/edit-site/src/components/style-book/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down Expand Up @@ -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 }
/>
) )
);
Expand Down Expand Up @@ -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 (
<div role="row">
Expand All @@ -534,7 +537,7 @@ const Example = ( { id, title, blocks, isSelected, onClick, content } ) => {
title
) }
render={ <div /> }
role="button"
role={ !! onClick ? 'button' : null }
onClick={ onClick }
{ ...disabledProps }
>
Expand Down

0 comments on commit f13bfb7

Please sign in to comment.