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

Spacer Block Not Responsive, May Lead to Unexpected Results #10081

Open
mrwweb opened this issue Sep 20, 2018 · 20 comments
Open

Spacer Block Not Responsive, May Lead to Unexpected Results #10081

mrwweb opened this issue Sep 20, 2018 · 20 comments
Labels
[Block] Spacer Affects the Spacer Block [Feature] Blocks Overall functionality of blocks Needs Design Feedback Needs general design feedback. [Type] Enhancement A suggestion for improvement.

Comments

@mrwweb
Copy link

mrwweb commented Sep 20, 2018

Describe the bug
The Spacer block is quite simple in that it applies a fixed height in pixels set by the editor.

To quickly take a step back, one general problem with WYSIWYG editors is that they encourage editors to overly optimize for the environment they're currently working in. This can lead to unintended consequences of editor decisions, often without the editor's knowledge.

Back to the issue, I think the Spacer likely will lead to unexpected results for editors when using this block on a large screen and not considering small screens. Arguably worse, even if editors want to consider small screens, there's no easy way to do so.

The screenshots below illustrate the issue. On my current monitor with a browser not even filling the entire screen, this spacer filled roughly 40% of the screen height. On an iPhone 7-size screen, it was 55%. It's not that hard to imagine a user making spacers that approach 100% of a smaller phone's screen.

I'm not sure of the best solution for this, but my first instinct would be that the spacer should be calculating a height as percentage of width and then implemented with a pseudo-element in the classic aspect ratio box technique. I'm sure there are other possibilities both for the behavior and implementation.

To Reproduce

  1. On a large screen, separate two visible blocks of any type with the largest reasonable spacer block you'd consider.
  2. Preview the page.
  3. Resize screen to a "phone" size

Expected behavior
Spacer adjusts to be reasonable on and screen size.

Screenshots
If applicable, add screenshots to help explain your problem.

Full Post on large screen
poem formatted with a spacer block

One screen's worth of the post on large screen:
the poem's spacer block takes up 40% of the screen height on large screens

Full Post on Small Screen
The same poem on a narrower screen

One screen's worth of the post on a small screen
On the narrow screen, the spacer block takes up 55% of the height

@designsimply designsimply added [Feature] Blocks Overall functionality of blocks Needs Design Feedback Needs general design feedback. labels Sep 21, 2018
@mrwweb mrwweb mentioned this issue Sep 22, 2018
2 tasks
@karmatosed
Copy link
Member

'If' this can be done without any interface in phase one, I would prefer that. I can see a need once we enter site building to have more granular control but for now having something 'just work' seems like the best step.

@mrwweb
Copy link
Author

mrwweb commented Oct 4, 2018

Completely agreed. In fact I don't think there should be interface. It strikes me as a fairly reasonable assumption that users inserting a spacer are defining the height they want at the current document width, so a ratio-based "just works" solution makes sense.

If users wanted to optimize heights at different breakpoints, I would think that's plugin-territory for a "Show only on [mobile/desktop]" feature (unless/until core added standardized responsive options for blocks).

@chrisvanpatten
Copy link
Contributor

I wonder if there's any way to re-use or extend the CSS used in the responsive video feature? Maybe similarly calculating the aspect ratio on the fly somehow…?

@karmatosed
Copy link
Member

Removing the design feedback as we are opting for no interface so it's just a matter of a pull request on this now. I say that knowing 'just' involves some 'fun' maths.

@karmatosed karmatosed removed the Needs Design Feedback Needs general design feedback. label Oct 8, 2018
@DancingPigeon
Copy link

Isn't the core issue here that using PX as the primary/only unit type is guaranteed to lead to issues related to changing viewport size? Why not allow something based off vh or em?

@mrwweb
Copy link
Author

mrwweb commented Oct 25, 2018

@DancingPigeon That's certainly another way to put it. In trying to think about the ideal "just works" experience, something close to maintaining the aspect ratio of the sizer feels right, though I also think that it might be even better if there were min- and max-heights to "cap" the changes. Something similar is usually done when using vw units for type sizing.

ems wouldn't maintain aspect ratio and only be responsive if the theme resizes typography, but vh units seem like a reasonable path forward. I didn't think the browser support was there, but reviewing that now (IE9+), makes me think that could be an even cleaner solution than the pseudo-element aspect ratio hack.

@DancingPigeon
Copy link

DancingPigeon commented Oct 26, 2018

I can see arguments for either. Personally, I think dragging by PX is the least valuable way for the 'standard' user to use the current control, and its certainly at odds with the current trend in how white space should be handled with respect to content. I can see an argument for either vh or em, depending of course whether we're talking about space as it relates to typography or viewport. I can see value in either, for different purposes of spacing.

@melchoyce
Copy link
Contributor

Maintaining aspect ratio and scaling down proportionally, IMO, is key. It should feel proportionally like the same amount of space, despite your screen size (though I agree we need a min/max cap).

Pixels are easier to visualize when deciding how large something is — but the actual output should probably be something more flexible, like vh.

@dweidner
Copy link

I would love to be able to customize the available spacer-heights, similar to how it is possible with the editor font sizes. For example:

add_theme_support( 'editor-spacer-sizes', [
    [
        'name' => __( 'Small', 'acme' ),
        'size' => 27,
        'slug' => 'small',
    ],
    [
        'name' => __( 'Medium', 'acme' ),
        'size' => 54,
        'slug' => 'regular',
    ],
    [
        'name' => __( 'Large', 'acme' ),
        'size' => 108,
        'slug' => 'large',
    ],
]);
add_theme_support( 'disable-custom-spacer-sizes' );

Resulting in the following markup:

<div class="wp-block-spacer is-large" aria-hidden="true"></div>

@mrwweb
Copy link
Author

mrwweb commented Dec 20, 2018

@dweidner seems like a good suggestion. I'd encourage you to make a separate ticket for that request as the direction of this ticket right now is probably UI-less.

@rafafields
Copy link

rafafields commented May 13, 2019

I would love to be able to customize the available spacer-heights, similar to how it is possible with the editor font sizes. For example:

add_theme_support( 'editor-spacer-sizes', [
    [
        'name' => __( 'Small', 'acme' ),
        'size' => 27,
        'slug' => 'small',
    ],
    [
        'name' => __( 'Medium', 'acme' ),
        'size' => 54,
        'slug' => 'regular',
    ],
    [
        'name' => __( 'Large', 'acme' ),
        'size' => 108,
        'slug' => 'large',
    ],
]);
add_theme_support( 'disable-custom-spacer-sizes' );

Resulting in the following markup:

<div class="wp-block-spacer is-large" aria-hidden="true"></div>

I think we all would love that solution. Until they implement something like that, I have coded a simple vanilla lightweight solution which you can configure with breakpoints. I hope it helps :)

Source -> https://codepen.io/Wondermochi/pen/YbGQdW

Edit: It looks like Gutenberg overwrite my javascript (even when I render it on head omg). Can someone tell why?

Finally I decided to set an !important height value to all spacer blocks which I can control from my css to optimize space in every breakpoint. In case of needen more space, I will add the block twice. Not clean but functional.

@melchoyce melchoyce added the Needs Dev Ready for, and needs developer efforts label Dec 20, 2019
@webprom
Copy link

webprom commented Jan 22, 2020

At lest using more units options would help a lot, i.e. vw, wh, em, % etc.

@tellthemachines tellthemachines added the CSS Styling Related to editor and front end styles, CSS-specific issues. label Apr 23, 2020
@Preen
Copy link

Preen commented Sep 10, 2020

Any news on this?

@Mamaduka
Copy link
Member

The Spacer block now supports different units for height, not just pixes, so I think we can close this issue. See #36186.

@mrwweb
Copy link
Author

mrwweb commented Jan 14, 2022

I'll just throw out that I think until the default value of the spacer block is changed to a responsive value (5vh?), the usability concerns expressed in this ticket—default usage leads to unresponsive bad results on small screens—are still valid.

@Rockstar907
Copy link

Rockstar907 commented Jan 14, 2022 via email

@jordesign
Copy link
Contributor

I'll just throw out that I think until the default value of the spacer block is changed to a responsive value (5vh?), the usability concerns expressed in this ticket—default usage leads to unresponsive bad results on small screens—are still valid.

@mrwweb - I'm seeing vh values being supported by the spacer block now - does that resolve the kind of thing you're talking about (for now)?

@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Aug 1, 2023
@mrwweb
Copy link
Author

mrwweb commented Aug 7, 2023

@jordesign I would not say that the addition of vh units resolves the problem since px units are still the default.

I think until vh is the default unit or the spacer switches to an aspect-ratio approach, most users are still unlikely to change the default value and will still experience these problems.

@jordesign
Copy link
Contributor

@mrwweb Having that value as the default is likely a much bigger conversation to have - in terms of consistency with other blocks etc. I'll leave this open - but add a label for Design Feedback 👍

@jordesign jordesign added Needs Design Feedback Needs general design feedback. and removed Needs Dev Ready for, and needs developer efforts CSS Styling Related to editor and front end styles, CSS-specific issues. labels Aug 8, 2023
@mrwweb
Copy link
Author

mrwweb commented Aug 9, 2023

Having that value as the default is likely a much bigger conversation to have

Totally agree. The original concern with the ticket is that any user that doesn't have a strong grasp of px vs. other units (probably most users) or who isn't thinking about responsiveness (probably most users) and inserts a spacer and drags it to be larger is likely going to create a sub-par experience for their mobile visitors.

I don't think that has changed, so I agree we should leave the ticket open. I'd love design feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Spacer Affects the Spacer Block [Feature] Blocks Overall functionality of blocks Needs Design Feedback Needs general design feedback. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests