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

Re-add base styling for footer actions to support simple customisations #11751

Merged

Conversation

lb-
Copy link
Member

@lb- lb- commented Mar 11, 2024

Overview

I'd recommend we also include this in 6.0.2 as it will help packages update to support Wagtail 6.0* easier.

Details

The PR referenced above did a lot of incredible work to clean up the complex styles in the footer, but it appears that some of that made basic customisations much easier.

This PR proposes we add some bare minimum styling back to support the common use case of showing a few buttons in the extra_footer_actions block.

Testing

Follow the steps in #11629 (comment)

Before

Screenshot 2024-03-12 at 7 22 32 am

After

Screenshot 2024-03-13 at 7 06 25 am

Copy link

squash-labs bot commented Mar 11, 2024

Manage this branch in Squash

Test this branch here: https://lb-fix11629-better-base-stylin-yj2pe.squash.io

@zerolab
Copy link
Contributor

zerolab commented Mar 12, 2024

@lb- I wonder if the extra actions should be inline, to the right of the primary actions as we had up to 6.0?

@lb-
Copy link
Member Author

lb- commented Mar 12, 2024

@zerolab the new max width makes this very tight except for maybe one added button.

Screenshot 2024-03-13 at 7 03 20 am

@lb- lb- force-pushed the fix/11629-better-base-styling-for-footer-actions branch 2 times, most recently from 5ee324d to 3f7b9f0 Compare March 12, 2024 21:11
@zerolab
Copy link
Contributor

zerolab commented Mar 12, 2024

Ah, that's unfortunate.
I guess the best thing we can do is advise people to register it as a page footer action. It is still worth for 1-2 extra buttons. Thank you

@lb-
Copy link
Member Author

lb- commented Mar 12, 2024

OK so should we close this PR or still attempt to account for a 'basic' usage here?

@zerolab

@zerolab
Copy link
Contributor

zerolab commented Mar 13, 2024

@lb- this PR is an improvement over what we have now, so we should keep it. Sorry if I was unclear

@laymonage
Copy link
Member

Regarding the max width, I haven't checked if this is possible, but we might be able to set the max width on just the dropdown, while using something like fit-content for the container. That might allow us to keep the max width in most cases, but still allowing additional items to appear with enough width side-by-side.

@lb-
Copy link
Member Author

lb- commented Mar 13, 2024

OK this is getting a bit more complex but this should support any arbitrary sibling elements to the dropdown while conserving the current intent of having a wider dropdown (to account for different label lengths).

I have also now accounted for small (mobile sized) devices supporting multiple buttons side by side and having the correct heights.

This may not work for really long translations and lots more buttons but should be ok.

Screenshot 2024-03-14 at 6 50 45 am Screenshot 2024-03-14 at 6 50 53 am

@lb- lb- force-pushed the fix/11629-better-base-styling-for-footer-actions branch from 3f7b9f0 to 138f441 Compare March 13, 2024 21:07
@lb- lb- requested a review from zerolab March 13, 2024 21:07
@lb- lb- force-pushed the fix/11629-better-base-styling-for-footer-actions branch from 138f441 to 09b30da Compare March 21, 2024 20:35
gasman added a commit to gasman/wagtail-content-import that referenced this pull request Mar 21, 2024
@lb- lb- force-pushed the fix/11629-better-base-styling-for-footer-actions branch from 09b30da to 8639000 Compare March 23, 2024 05:44
@laymonage laymonage self-requested a review April 2, 2024 05:27
@laymonage laymonage self-assigned this Apr 2, 2024
- Fixes wagtail#11629
- Relates to clean up done as part of wagtail#11629 which removed a lot of styling for footer actions which appeared to be unused.
- Re-add some base styling to support the ability for basic customisations where buttons are added within the `extra_footer_actions` block.
Copy link
Member

@laymonage laymonage left a comment

Choose a reason for hiding this comment

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

Thanks @lb-!

This is a solid base for reinstating the styles, but I noticed a few issues. I have made the fixes locally, I'll push them to your branch and double check. If I don't find any more issues, I think I'll merge this so we can unblock external packages like wagtail-content-import.

gap: theme('spacing.2');
grid-auto-flow: column;

> * {
Copy link
Member

Choose a reason for hiding this comment

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

From what I've seen we're only doing this to reset the default .button styles, so I think it's better to apply this more conservatively, e.g.

Suggested change
> * {
> .button {

// Support basic layout support for items added via `extra_footer_actions`

align-items: stretch;
display: grid;
Copy link
Member

Choose a reason for hiding this comment

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

As I understand, this allows us to remove the w-grid from these:

<nav class="actions actions--primary footer__container w-grid" aria-label="{% trans 'Actions' %}">

<nav class="actions actions--primary footer__container w-grid" aria-label="{% trans 'Actions' %}">

which were added after #11456 (comment).


> * {
// Reset the margin on any .button sibling elements
height: auto;
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately this causes the button to be very small when there's no dropdown (e.g. when the page is locked)

image

and the button to be very large when it has an icon (due to missing height set for the icon):

image

I think we have to define our own height here instead of relying on the dropdown's button height, which in turn relies on the default .button height of 3em or the $text-input-height:

min-height: $text-input-height;

Unfortunately, 42px or 2.625rem (the current height, which is also $text-input-height) is not defined in our spacing tokens. We can either add it as spacing[10.5] and use it, or use $text-input-height instead.

Since we already use $text-input-height in _dropdown-button.scss, I think we can use it here too. It would be nice to add it as spacing[10.5] in the future though, as it seems we use this value in quite a few places.

@laymonage laymonage force-pushed the fix/11629-better-base-styling-for-footer-actions branch from 8639000 to ee4b699 Compare April 2, 2024 09:00
@@ -103,6 +125,7 @@

.icon {
width: theme('spacing.4');
height: theme('spacing.4');
Copy link
Member

Choose a reason for hiding this comment

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

Without this, we had this issue (even before this PR) where the svg's height goes beyond the button's, but this wasn't noticeable until we added height: auto to the button in the earlier iteration of this PR.

image

<nav class="actions actions--primary footer__container w-grid" aria-label="{% trans 'Actions' %}">
<nav class="actions actions--primary footer__container" aria-label="{% trans 'Actions' %}">
Copy link
Member

Choose a reason for hiding this comment

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

Can confirm that this works OK even when there's only a single action

image image

// - set height responsively
// - add a margin when there is a .button sibling
// Unset these styles in favor of a fixed height and the grid gap
height: $text-input-height;
Copy link
Member

Choose a reason for hiding this comment

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

Tested a few different scenarios and this seems OK

image image image image

Copy link
Contributor

Choose a reason for hiding this comment

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

what about cases where one wraps that .button in a form? wagtail-localize used to do that for the additional buttons (a la "import from local file")

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, OK, good point. I wanted to remove the > but was afraid it would be risky.

The main dropdown action button from Wagtail is also wrapped inside another element, and without removing the > this technically still uses the default styles from .button (see bottom right), but the _dropdown-button.scss has its own min-height styles to handle the case for smaller screens so that it uses this same height instead of the smaller one:

image

I think it should be safe to remove the >.

Copy link
Member

Choose a reason for hiding this comment

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

Tried wrapping it in a <form> but the browser won't render it, probably because the footer actions are inside the page editor's form, and nested forms aren't valid HTML5.

Here's with a <div> instead (and > .button changed to .button)

image image

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for checking!

localize is a bit special in that it replaces the edit form with its React bits (one more reason to rewrite with good old panels).

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks everyone. A great solution in the end.

Copy link
Contributor

Choose a reason for hiding this comment

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

Team work! Thank you @lb- and @laymonage ❤️

laymonage added a commit to lb-/wagtail that referenced this pull request Apr 2, 2024
@laymonage laymonage force-pushed the fix/11629-better-base-styling-for-footer-actions branch from ee4b699 to 2d7429d Compare April 2, 2024 09:40
zerolab added a commit to wagtail/wagtail-localize that referenced this pull request Apr 2, 2024
@laymonage laymonage force-pushed the fix/11629-better-base-styling-for-footer-actions branch from 2d7429d to f941b45 Compare April 2, 2024 09:54
@laymonage laymonage merged commit f941b45 into wagtail:main Apr 2, 2024
11 of 14 checks passed
laymonage added a commit that referenced this pull request Apr 2, 2024
@laymonage
Copy link
Member

Thanks @lb- @zerolab

Will see about releasing 6.0.2 sometime this week.

@zerolab zerolab added this to the 6.0.2 milestone Apr 2, 2024
@lb- lb- deleted the fix/11629-better-base-styling-for-footer-actions branch April 2, 2024 21:54
@lb-
Copy link
Member Author

lb- commented Apr 2, 2024

Thanks @zerolab and @laymonage

zerolab added a commit to wagtail/wagtail-localize that referenced this pull request Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Footer action menu with extra_footer_actions needs better styling
3 participants