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

[core/media-text] Use CSS variables for media width #58174

Open
Fyrins opened this issue Jan 24, 2024 · 1 comment
Open

[core/media-text] Use CSS variables for media width #58174

Fyrins opened this issue Jan 24, 2024 · 1 comment
Labels
[Block] Media & Text Affects the Media & Text Block CSS Styling Related to editor and front end styles, CSS-specific issues. [Type] Enhancement A suggestion for improvement.

Comments

@Fyrins
Copy link

Fyrins commented Jan 24, 2024

What problem does this address?

Actually the media width is defined in CSS with the rule :

.wp-block-media-text {
    ...
    grid-template-columns: 50% 1fr;
    ...
}

and it is override with inline CSS when the media width is change :

<div class="wp-block-media-text" style="grid-template-columns: 33% auto;">

In a project I've to override grid-template-columns: 50% 1fr; with grid-template-columns: 50% minmax(0, auto); to avoid a conflict with Swiper.js but if the user change the media width, my code cannot work anymore because of the inline style.

What is your proposed solution?

Why not using CSS variables to avoid inline styling ? ie :

.wp-block-media-text {
    --media-text--media-width: 50%;
    ...
    grid-template-columns: var( --media-text--media-width) auto;
    ...
}

And in the inline style we put the variable value. So everyone can use the rule they want without being override by the inline styling.

<div class="wp-block-media-text" style="--media-text--media-width: 33%;">
@Fyrins Fyrins added the [Type] Enhancement A suggestion for improvement. label Jan 24, 2024
@skorasaurus skorasaurus added the [Block] Media & Text Affects the Media & Text Block label Jan 24, 2024
@cbirdsong
Copy link

@cbirdsong cbirdsong added the CSS Styling Related to editor and front end styles, CSS-specific issues. label Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Media & Text Affects the Media & Text Block CSS Styling Related to editor and front end styles, CSS-specific issues. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants