-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Social Links Block: Add icon and background color options #25372
Social Links Block: Add icon and background color options #25372
Conversation
@apeatling and @glendaviesnz these color options are working for me although I feel there should be a better way of achieving it than I've come up with. I'd appreciate any suggestions or feedback you have. |
This functions well. I think there should be a |
f46c6e7
to
c7da4c7
Compare
I've added a contrast checker although it doesn't really handle the default backgrounds that vary in color by the social media platform. This PR has also been rebased and conflicts resolved after the addition of the "open in new tab" feature for social links. I also had to change the approach a little as for the moment colors cannot be retrieved from the general settings ( #25419 ). There is a PR to re-add the default colors and gradients ( #25523 ) however updating this to leverage the |
$url = ( isset( $attributes['url'] ) ) ? $attributes['url'] : false; | ||
$label = ( isset( $attributes['label'] ) ) ? $attributes['label'] : block_core_social_link_get_name( $service ); | ||
$class_name = isset( $attributes['className'] ) ? ' ' . $attributes['className'] : false; | ||
$service = ( isset( $attributes['service'] ) ) ? $attributes['service'] : 'Icon'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this and the others could be updated to use array_key_exists( 'service', $attributes )
. That seems to be a cleaner way that some of the other core blocks now use.
This all seems to work as advertised. Apologies if you already explored this, but the specificity of the individual link color settings is reasonably light, so rather than having to pass down context and set individual attributes for each embedded link is there some way we could instead add a generic style at the parent level? eg. adding a style of: .override-background.wp-block-social-links:not(.is-style-logos-only) .wp-social-link {
background-color: red;
} replaces the background on all the child icons. |
That was my thinking initially as well, to be able to just apply the color choices to the social links block itself and allow the individual links to inherit that as required. Unfortunately, I couldn't find a way to achieve the desired results doing this. Some of the issues I ran into in this area were:
I could be missing something so if you do have further suggestions, let me know and I can explore those. For now though, this does give us the control over colors we need, hopefully that is ok. |
No, I don't think you are missing anything, it just seemed like there should be a simpler approach, but due to the factors you list I think the approach you have take is the only way to push the styles down to the children. |
@apeatling do you have any suggestions on who is best to give us a signoff on this approach? |
Maybe @nosolosw or @youknowriad might have thoughts on the approach? |
Hi there! thanks for the PR. In general, we're trying to move away from specific customization and attributes in favor of generic support flags that can be enabled across blocks, so my questions here are: Can we use the |
Hi @youknowriad, thanks for taking a look at this! I'm still trying to get my head around how everything fits together. I did initially try to leverage Looking back at this PR, do you think an option would be to use |
I was thinking |
The idea was, the better UX was for the user to only have to make a single set of color selections. That is the approach used by the navigation block. |
I wonder if there's a way to make the settings on the parent component work as a "default value" for its children instead. |
@youknowriad I don't have an answer for this at the moment but logged this example at #22887 because I smell that these little glitches in the system may be addressed together. |
@youknowriad and @nosolosw would you be happy for us to move forward with this current approach so we have the functionality in place? I'm happy to come back and revisit this when we have a solution to the larger questions raised. |
Personally, I'd rather compromise on the UI and make this per icon for now until we figure out a better API for handling |
It doesn't make sense per icon to me unless it's just an implementation detail (the control lives int he wrapper and propagates) |
@apeatling Would you like to weigh in and cast a vote on a preferred approach to this one? Should we allow what is the best experience for a user, to be the tie breaker if needed? |
I agree that changing per icon is not the ideal user experience, and we're better off optimizing for the user. |
4bb63cf
to
ceb9458
Compare
An alternative approach to this is available in #28084 I'm inclined to close this PR in favour of the new approach if others agree. |
Closing this PR in favour of #28084 |
Description
Added options to the social links block allowing a user to specify the icon or background colors and have that apply to all the social links contained within it.
Note: Saving the styles in the social link blocks will be done if this general approach is continued instead of switching to the useColors hook if possible.
#21605
How has this been tested?
Only manual testing.
WordPress: 5.5.1
Testing Instructions
Screenshots
Types of changes
New feature. Enhancement.
Next Steps
Switch to using__experimentalUseColors
if its possible to achieve same editor functionality. (didn't work for me)Checklist: