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

Implement new designs for header/breadcrumbs in slim_header.html #11332

Merged
merged 39 commits into from
Jan 2, 2024

Conversation

laymonage
Copy link
Member

@laymonage laymonage commented Dec 12, 2023

image
Old description

WIP

image

The snippets views still look a bit funny atm as they still use both slim_header.html and header.html. Will work on porting features over from header.html to slim_header.html and remove/reduce header.html usage.

Please check the following:

  • Do the tests still pass?1
  • Does the code comply with the style guide?
    • Run make lint from the Wagtail root.
  • For Python changes: Have you added tests to cover the new/fixed behaviour?
  • For front-end changes: Did you test on all of Wagtail’s supported environments?2
    • Please list the exact browser and operating system versions you tested:
    • Please list which assistive technologies 3 you tested:
  • For new features: Has the documentation been updated accordingly?

Please describe additional details for testing this change.

Footnotes

  1. Development Testing

  2. Browser and device support

  3. Accessibility Target

Copy link

squash-labs bot commented Dec 12, 2023

Manage this branch in Squash

Test this branch here: https://laymonageheaders-new-design-04on0.squash.io

@laymonage laymonage force-pushed the headers-new-design branch 2 times, most recently from 417c028 to 9fea602 Compare December 14, 2023 16:40
@laymonage
Copy link
Member Author

laymonage commented Dec 14, 2023

Progress update

image

@laymonage laymonage self-assigned this Dec 14, 2023
@laymonage laymonage changed the title Implement new designs for header/breadcrumbs in slim_header.html WIP: Implement new designs for header/breadcrumbs in slim_header.html Dec 14, 2023
@laymonage laymonage force-pushed the headers-new-design branch 5 times, most recently from 1bb653e to 3fac354 Compare December 18, 2023 15:21
@laymonage laymonage force-pushed the headers-new-design branch 2 times, most recently from 3330e57 to bc9d16c Compare December 19, 2023 15:05
@laymonage laymonage marked this pull request as ready for review December 19, 2023 15:09
@laymonage laymonage changed the title WIP: Implement new designs for header/breadcrumbs in slim_header.html Implement new designs for header/breadcrumbs in slim_header.html Dec 19, 2023
Copy link
Member

@thibaudcolas thibaudcolas left a comment

Choose a reason for hiding this comment

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

@laymonage looking pretty solid, could you take some time to move more of your TODO comments to a GitHub issue or similar? They seem valuable to track future progress but not critical enough for us to get to on short notice.

I’ll review this later in more depth.

wagtail/admin/templates/wagtailadmin/shared/header.html Outdated Show resolved Hide resolved
@laymonage laymonage force-pushed the headers-new-design branch 2 times, most recently from 736fc75 to dadc272 Compare December 19, 2023 17:14
@@ -1,4 +1,4 @@
.page-explorer .w-breadcrumbs {
.w-breadcrumbs:not(.editor-view .w-breadcrumbs) {
Copy link
Member Author

Choose a reason for hiding this comment

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

From commit message:

We want to make the slim_header.html as the basis for the modern header
template that will be used everywhere, eventually replacing header.html.

Rather than making the page explorer be the special case where we want
the last item to be bigger, do it the other way around i.e. use the
smaller font size on the create/edit views. This ensures that the big
font size is used on all other views e.g. Inspect view.

@@ -2,7 +2,7 @@
{% load i18n wagtailadmin_tags %}
{% block titletag %}{% blocktrans trimmed with snippet_type_name=model_opts.verbose_name %}New {{ snippet_type_name }}{% endblocktrans %}{% endblock %}
{% block content %}
{% include 'wagtailadmin/shared/headers/slim_header.html' %}
{% include 'wagtailadmin/shared/headers/slim_header.html' with breadcrumbs_items=breadcrumbs_items side_panels=side_panels history_url=history_url %}
Copy link
Member Author

Choose a reason for hiding this comment

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

We can't use only yet for snippets and pages due to #11358

@@ -7,9 +8,34 @@
{% block header %}
{% block slim_header %}
{% if breadcrumbs_items %}
{% fragment stripped as actions %}
Copy link
Member Author

Choose a reason for hiding this comment

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

Use the stripped option so that if both blocks are empty, the resulting fragment is actually empty instead of being a string consisting of only whitespaces. This ensures that when the fragment is passed down to the slim_header.html, you can check its emptiness with if

(horrible, I know, but give me something better?)

Copy link
Member

Choose a reason for hiding this comment

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

Indeed pretty horrible! This doesn’t strike me as a dealbreaker but definitely one for a list of refactorings.

@@ -69,6 +69,8 @@ def get_url(self, url_name, args=()):


class TestCustomIcon(BaseSnippetViewSetTests):
# TODO: decide what to do with this test, since the new designs after
Copy link
Member Author

Choose a reason for hiding this comment

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

To be addressed with #11366

@@ -156,7 +155,6 @@ def get_template_names(self):

class IndexView(generic.IndexViewOptionalFeaturesMixin, generic.IndexView):
view_name = "list"
table_class = InlineActionsTable
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a leftover I forgot to cleanup in #11295

Comment on lines +61 to +62
{% if not search_url %}
{% elif search_form or filters %}
Copy link
Member Author

Choose a reason for hiding this comment

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

Empty if, to avoid extra indent

The <form> now works with search_form or filters (or both). You can have filters without search and vice versa, but use the same URL in general (the index results URL)

@@ -858,6 +857,7 @@ def workflow_history_detail_view(self):
object_icon=self.icon,
header_icon="list-ul",
workflow_history_url_name=self.get_url_name("workflow_history"),
_show_breadcrumbs=False,
Copy link
Member Author

Choose a reason for hiding this comment

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

See https://static-wagtail-v5-2.netlify.app/admin/snippets/base/person/workflow_history/4/detail/3/ for why I added this, it's not ready to use breadcrumbs yet and I should've done this in 5.2

page_title and page_subtitle are not meant to be read as one phrase
…e_buttons

To follow the pattern for get_list_buttons and get_list_more_buttons

This will be made clearer in the next commit
And rename get_results_url() in pages' BaseIndexView to
get_index_results_url to match the method in generic IndexView
10px was never the right width.

Using CSS instead of the column's width attribute allows us to use media queries to change the width responsively
…tables

The added CSS handles the case when nice padding is removed (to make the listing
go full-width) and no bulk actions are available (e.g. a ModelViewSet index view
or some other view that extends generic listing view).

This allows us to not rely on the full-width class (which should
eventually be removed) while correctly apply the spacing regardless
whether nice-padding is used or not, and whether bulk actions are
available or not.

If nice-padding is used, then the listing view will look as they
previously do.
Report pages have styles for .report that adds margins similar to nice-padding
…form

Also make the search form optional. The <form> element may still be
rendered as if there is either the search form or the filters, or both.
Before c8edfd1, empty q is considered invalid, so is_searching is False. After that commit, empty q is valid so set is_searching based on the truthiness of the search_query instead
Even though they have tooltips on hover/focus, axe will complain if they don't have aria-label
Copy link
Member

@thibaudcolas thibaudcolas left a comment

Choose a reason for hiding this comment

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

Looking good @laymonage!

I noted an issue with the snippets’ "mode index" view which was displaying an "Add" button when it’s not meant to, so took the liberty to override header_buttons there too.

Other than that, follow-up changes needed:

  • Locale selector, wagtail/admin/templates/wagtailadmin/generic/form.html, possibly elsewhere
  • Copy-pasted w-header, wagtail/admin/templates/wagtailadmin/generic/form.html
  • TODO comments, wagtail/snippets/tests/test_viewset.py
  • TODO comment, wagtail/admin/views/pages/revisions.py
  • A better approach to snippets

Tested in Chrome 120, Firefox 121, Firefox 115 ESR


input[type='checkbox'] {
margin-inline-end: 0;
&:has(.bulk-action-checkbox) {
Copy link
Member

Choose a reason for hiding this comment

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

:has browser support isn’t good enough for us to use it for any critical styles. In this case I’ve confirmed the only issue would be the checkboxes being placed too far to the left so this seems acceptable.

@@ -1091,6 +1091,7 @@ def register_icons(icons):
"rotate.svg",
"search.svg",
"site.svg",
"sliders.svg",
Copy link
Member

Choose a reason for hiding this comment

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

This will also need adding to our wagtail_icons_table.txt when merging. I can take care of that.

<div id="listing-results">
{% if breadcrumbs_items and locale %}
{# TODO: temporarily put the locale selector here since we no longer use the legacy header #}
Copy link
Member

Choose a reason for hiding this comment

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

Yes this needs adjusting. Seems reasonable enough to me as long as we do complete this in time for the release.

@@ -7,9 +8,34 @@
{% block header %}
{% block slim_header %}
{% if breadcrumbs_items %}
{% fragment stripped as actions %}
Copy link
Member

Choose a reason for hiding this comment

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

Indeed pretty horrible! This doesn’t strike me as a dealbreaker but definitely one for a list of refactorings.

@thibaudcolas thibaudcolas merged commit 2cf9730 into wagtail:main Jan 2, 2024
11 of 13 checks passed
@lb-
Copy link
Member

lb- commented Feb 28, 2024

I think this PR may have introduced an issue - see #11704

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants