Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Site editor: style the selected template pattern #65917

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a1a89e7
Updated code to set active pattern and its styling
benazeer-ben Oct 7, 2024
17cfe90
Fixes for linting issues on updated files
benazeer-ben Oct 8, 2024
a31771b
Updated code based on the first round feedback points
benazeer-ben Oct 10, 2024
2a30d64
Modification to highlight active iitem on focus
benazeer-ben Oct 11, 2024
4b09b2a
Removed local/session storage
benazeer-ben Oct 14, 2024
9cee60c
Changes applied from drafted PR
benazeerhassan1909 Oct 18, 2024
bf02cf7
Changes applied from drafted PR
benazeerhassan1909 Oct 18, 2024
f727ff0
Updated with new style changes
benazeerhassan1909 Oct 22, 2024
71fc3e5
Linting Fix
benazeerhassan1909 Oct 22, 2024
88369cb
Updated code to set active pattern and its styling
benazeer-ben Oct 7, 2024
5ce1c69
Fixes for linting issues on updated files
benazeer-ben Oct 8, 2024
9d1b5f3
Updated code based on the first round feedback points
benazeer-ben Oct 10, 2024
976c3e1
Modification to highlight active iitem on focus
benazeer-ben Oct 11, 2024
e882062
Removed local/session storage
benazeer-ben Oct 14, 2024
f0aa553
Changes applied from drafted PR
benazeerhassan1909 Oct 18, 2024
214d982
Changes applied from drafted PR
benazeerhassan1909 Oct 18, 2024
9cea49b
Updated with new style changes
benazeerhassan1909 Oct 22, 2024
c8eeba5
Linting Fix
benazeerhassan1909 Oct 22, 2024
046d54a
Merge branch 'enhancement/selected-template-style' of https://github.…
benazeerhassan1909 Oct 24, 2024
3edee3f
Merge branch 'trunk' of github.com:benazeer-ben/gutenberg into enhanc…
benazeer-ben Oct 28, 2024
0cc1530
Merge branch 'trunk' into enhancement/selected-template-style
ciampo Nov 27, 2024
d93540f
Fix spacing
ciampo Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function BlockPattern( {
onHover,
showTitlesAsTooltip,
category,
isSelected,
} ) {
const [ isDragging, setIsDragging ] = useState( false );
const { blocks, viewportWidth } = pattern;
Expand Down Expand Up @@ -114,6 +115,7 @@ function BlockPattern( {
pattern.type ===
INSERTER_PATTERN_TYPES.user &&
! pattern.syncStatus,
'is-selected': isSelected,
}
) }
/>
Expand Down Expand Up @@ -192,6 +194,7 @@ function BlockPatternsList(
ref
) {
const [ activeCompositeId, setActiveCompositeId ] = useState( undefined );
const [ activePattern, setActivePattern ] = useState( null ); // State to track active pattern

useEffect( () => {
// Reset the active composite item whenever the available patterns change,
Expand All @@ -201,6 +204,11 @@ function BlockPatternsList(
setActiveCompositeId( firstCompositeItemId );
}, [ blockPatterns ] );

const handleClickPattern = ( pattern, blocks ) => {
setActivePattern( pattern.name );
onClickPattern( pattern, blocks );
};

return (
<Composite
orientation={ orientation }
Expand All @@ -216,11 +224,14 @@ function BlockPatternsList(
key={ pattern.name }
id={ pattern.name }
pattern={ pattern }
onClick={ onClickPattern }
onClick={ handleClickPattern }
onHover={ onHover }
isDraggable={ isDraggable }
showTitlesAsTooltip={ showTitlesAsTooltip }
category={ category }
isSelected={
!! activePattern && activePattern === pattern.name
}
/>
) ) }
{ pagingProps && <BlockPatternsPaging { ...pagingProps } /> }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,29 @@
outline: $border-width solid rgba($black, 0.1);
outline-offset: -$border-width;
border-radius: $radius-medium;

transition: outline 0.1s linear;
@include reduce-motion("transition");
}
}

&:hover:not(:focus) .block-editor-block-preview__container::after {
// Selected
&.is-selected .block-editor-block-preview__container::after {
outline-color: $gray-900;
outline-width: var(--wp-admin-border-width-focus);
outline-offset: calc(-1 * var(--wp-admin-border-width-focus));
}

// Hover state
&:hover .block-editor-block-preview__container::after {
outline-color: rgba($black, 0.3);
}

&:focus .block-editor-block-preview__container::after {
// Focused state
&[data-focus-visible] .block-editor-block-preview__container::after {
outline-color: var(--wp-admin-theme-color);
outline-width: var(--wp-admin-border-width-focus);
outline-offset: calc((-1 * var(--wp-admin-border-width-focus)));
transition: outline 0.1s linear;
@include reduce-motion("transition");
outline-offset: calc(-1 * var(--wp-admin-border-width-focus));
}

.block-editor-patterns__pattern-details:not(:empty) {
Expand All @@ -68,6 +78,7 @@
.block-editor-patterns__pattern-icon-wrapper {
min-width: 24px;
height: 24px;

.block-editor-patterns__pattern-icon {
fill: var(--wp-block-synced-color);
}
Expand Down
Loading