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

Remove Button component from social link block, replace with button element #61270

Merged
merged 3 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions packages/block-library/src/social-link/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const SocialLinkEdit = ( {
/>
</InspectorControls>
<li { ...blockProps }>
<Button
<button
className="wp-block-social-link-anchor"
ref={ setPopoverAnchor }
onClick={ () => setPopover( true ) }
Expand All @@ -171,7 +171,7 @@ const SocialLinkEdit = ( {
>
{ socialLinkText }
</span>
</Button>
</button>
{ isSelected && showURLPopover && (
<SocialLinkURLPopover
url={ url }
Expand Down
36 changes: 25 additions & 11 deletions packages/block-library/src/social-link/editor.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
// The editor uses the button component, the frontend uses a link.
// Therefore we unstyle the button component to make it more like the frontend.
.wp-block-social-links .wp-social-link {
line-height: 0;
}

// The editor uses the button element, the frontend uses a link.
// Therefore we unstyle the button element to make it more like the frontend.
.wp-block-social-link-anchor {
align-items: center;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we be able to lower the specificity here? If we ever want to support border or typography styling for this block, these styles could interfere.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was planning to look at dropping the specificity here over in #61032 as the block style variations need it as well

background: none;
border: 0;
box-sizing: border-box;
cursor: pointer;
display: inline-flex;
font-size: inherit;
color: currentColor;
height: auto;

// This rule ensures social link buttons display correctly in template parts.
opacity: 1;

button {
font-size: inherit;
color: currentColor;
height: auto;
line-height: 0;
// This rule is duplicated from the style.scss and needs to be the same as there.
padding: 0.25em;

// This rule ensures social link buttons display correctly in template parts.
opacity: 1;
// Focus styles replicate the `@wordpress/components` button component.
&:focus:not(:disabled) {
border-radius: 2px;
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);

// This rule is duplicated from the style.scss and needs to be the same as there.
padding: 0.25em;
// Windows High Contrast mode will show this outline, but not the box-shadow.
outline: 3px solid transparent;
}
}

Expand Down
Loading