diff --git a/corehq/apps/styleguide/context.py b/corehq/apps/styleguide/context.py index c0df34eb0354..78f77cb50579 100644 --- a/corehq/apps/styleguide/context.py +++ b/corehq/apps/styleguide/context.py @@ -53,6 +53,12 @@ def get_navigation_context(current_page): Page("Tables", 'styleguide_organisms_tables_b5'), ], ), + NavigationGroup( + name="Pages", + pages=[ + Page("Navigation", 'styleguide_pages_navigation_b5'), + ], + ), ], } diff --git a/corehq/apps/styleguide/static/styleguide/images/navigation/breadcrumbs.png b/corehq/apps/styleguide/static/styleguide/images/navigation/breadcrumbs.png new file mode 100644 index 000000000000..35c76ea5d6bb Binary files /dev/null and b/corehq/apps/styleguide/static/styleguide/images/navigation/breadcrumbs.png differ diff --git a/corehq/apps/styleguide/static/styleguide/images/navigation/side_navigation.png b/corehq/apps/styleguide/static/styleguide/images/navigation/side_navigation.png new file mode 100644 index 000000000000..ef3ea5b96540 Binary files /dev/null and b/corehq/apps/styleguide/static/styleguide/images/navigation/side_navigation.png differ diff --git a/corehq/apps/styleguide/static/styleguide/images/navigation/top_navigation.png b/corehq/apps/styleguide/static/styleguide/images/navigation/top_navigation.png new file mode 100644 index 000000000000..a54e32d19e55 Binary files /dev/null and b/corehq/apps/styleguide/static/styleguide/images/navigation/top_navigation.png differ diff --git a/corehq/apps/styleguide/templates/styleguide/bootstrap5/code_html_non_working.html b/corehq/apps/styleguide/templates/styleguide/bootstrap5/code_html_non_working.html new file mode 100644 index 000000000000..c41f820b66fa --- /dev/null +++ b/corehq/apps/styleguide/templates/styleguide/bootstrap5/code_html_non_working.html @@ -0,0 +1 @@ +{% include 'styleguide/bootstrap5/partials/readable_code_block.html' with content=content language="HTML" %} \ No newline at end of file diff --git a/corehq/apps/styleguide/templates/styleguide/bootstrap5/examples/navs_cards.html b/corehq/apps/styleguide/templates/styleguide/bootstrap5/examples/navs_cards.html new file mode 100644 index 000000000000..35c6f4eb59a7 --- /dev/null +++ b/corehq/apps/styleguide/templates/styleguide/bootstrap5/examples/navs_cards.html @@ -0,0 +1,27 @@ +
+
+
Winter
+ December, January, February +
+
+ +
+
+
Spring
+ March, April, May +
+
+ +
+
+
Summer
+ June, July, August +
+
+ +
+
+
Autumn
+ September, October, November +
+
diff --git a/corehq/apps/styleguide/templates/styleguide/bootstrap5/examples/navs_tabs.html b/corehq/apps/styleguide/templates/styleguide/bootstrap5/examples/navs_tabs.html new file mode 100644 index 000000000000..966131cb4eb2 --- /dev/null +++ b/corehq/apps/styleguide/templates/styleguide/bootstrap5/examples/navs_tabs.html @@ -0,0 +1,29 @@ + + +
+
+ December, January, February +
+
+ March, April, May +
+
+ June, July, August +
+
+ September, October, November +
+
diff --git a/corehq/apps/styleguide/templates/styleguide/bootstrap5/examples/page_header.html b/corehq/apps/styleguide/templates/styleguide/bootstrap5/examples/page_header.html new file mode 100644 index 000000000000..d183071baf6e --- /dev/null +++ b/corehq/apps/styleguide/templates/styleguide/bootstrap5/examples/page_header.html @@ -0,0 +1,11 @@ +

+ Mobile Workers +

+

+ Mobile workers' activity and form submissions can be monitored in the Reports section of this CommCare HQ project space. +
+ Read more about managing mobile workers on our + + Help Site + . +

diff --git a/corehq/apps/styleguide/templates/styleguide/bootstrap5/examples/page_title_block.html b/corehq/apps/styleguide/templates/styleguide/bootstrap5/examples/page_title_block.html new file mode 100644 index 000000000000..334dd97bde57 --- /dev/null +++ b/corehq/apps/styleguide/templates/styleguide/bootstrap5/examples/page_title_block.html @@ -0,0 +1,3 @@ +{% block page_title %} + {{ current_page.title }} +{% endblock %} diff --git a/corehq/apps/styleguide/templates/styleguide/bootstrap5/pages/navigation.html b/corehq/apps/styleguide/templates/styleguide/bootstrap5/pages/navigation.html new file mode 100644 index 000000000000..1c2e2bfcd3db --- /dev/null +++ b/corehq/apps/styleguide/templates/styleguide/bootstrap5/pages/navigation.html @@ -0,0 +1,164 @@ +{% extends 'styleguide/bootstrap5/base.html' %} +{% load hq_shared_tags %} + +{% block intro %} +

Navigation

+

+ Users should always know where they are and how to get back where they came from. +

+{% endblock intro %} + +{% block toc %} +
On this page
+
+ +{% endblock toc %} + +{% block content %} +

Overview

+

+ These standard navigation elements should be present on almost every page. The following assumes + that the page descends from hqwebapp/bootstrap5/base_section.html, which virtually all pages should. +

+ +

+ Top Navigation +

+
+
+ top navigation example +
+
+

+ The top navigation should always be visible to users. Individual tabs are defined in + tabclasses.py. + Which tab is highlighted depends on the url_prefix_formats defined for each tab. Which items + appear in a tab's dropdown is determined by dropdown_items. +

+ +

+ Side Navigation +

+
+
+ top navigation example +
+
+

+ The side navigation appears almost everywhere. Major exceptions are the dashboard, + which has no navigation, and app manager, which has a custom sidebar corresponding to the app's structure. + Other pages should almost certainly have a sidebar. +

+

+ The sidebar is also defined in + tabclasses.py, + controlled by the sidebar_items class methods. +

+

+ Temporary sub-items that appear only when on a specific page, such as the "Create Form Data Export" item that + appears under the main "Export Form Data" item only when you're creating a new export, can be added using + the subpages property. +

+

+ Dynamic item names, such as displaying the username when editing a web user, can be enabled by passing a + function to the menu item's title. +

+ + +
+
+ top navigation example +
+
+

+ Breadcrumbs are defined by the parent_pages class method in a class-based view. + Standard pages should have a breadcrumb for the top nav section (e.g., "Data"), for the left sidebar section + if there is one (e.g., "Edit Data"), and for the page itself. Multi-step workflows such as case import should + also be reflected in breadcrumbs. All items in the breadcrumbs should be links, except for the last + (the current page). +

+

+ A few pages override the page_breadcrumbs block defined in the template: + hqwebapp/bootstrap5/base_section.html. This should only be done in exceptional circumstances. +

+
+ Usage Notes: See this example for + how to implement breadcrumbs on a class-based view. +
+ +

+ Page Headers +

+

+ A page header at the top of the page's main content helps the user stay oriented, and this is a good place to + briefly introduce the user to the page and link to documentation. +

+

+ This is an area where the technical implementation isn't well-standardized. When possible, make sure you + page_title attribute is defined if using a class-based view + (see this example) + or passed into the template context if using a functional view. +

+

+ For a class-based view, you would then (ideally) set the page_title block this way: + {% include 'styleguide/bootstrap5/code_html_non_working.html' with content=examples.page_title_block %} +

+

+ Otherwise, you can set the page header manually with the following bit of HTML at the beginning of + {% verbatim %}{% block page_content %}{% endverbatim %}: +

+ {% include 'styleguide/bootstrap5/code_example.html' with content=examples.page_header %} + +

+ In-page Navigation +

+

+ If a page has multiple sections, you have a few options to visually separate them: +

+ + +

+ Below is an example of sectioning a page with tabs. This is the most preferred method of sectioning a page in HQ. +

+ {% include 'styleguide/bootstrap5/code_example.html' with content=examples.navs_tabs %} + +

+ Below is an example of sectioning a page with cards. +

+ {% include 'styleguide/bootstrap5/code_example.html' with content=examples.navs_cards %} +{% endblock content %} diff --git a/corehq/apps/styleguide/urls.py b/corehq/apps/styleguide/urls.py index 18ff354590ae..4e9a6b84d12a 100644 --- a/corehq/apps/styleguide/urls.py +++ b/corehq/apps/styleguide/urls.py @@ -80,4 +80,6 @@ name="styleguide_organisms_forms_b5"), url(r'^b5/organisms/tables/$', bootstrap5.styleguide_organisms_tables, name="styleguide_organisms_tables_b5"), + url(r'^b5/pages/navigation/$', bootstrap5.styleguide_pages_navigation, + name="styleguide_pages_navigation_b5"), ] diff --git a/corehq/apps/styleguide/views/bootstrap5.py b/corehq/apps/styleguide/views/bootstrap5.py index 5a671630b246..71a208085ab1 100644 --- a/corehq/apps/styleguide/views/bootstrap5.py +++ b/corehq/apps/styleguide/views/bootstrap5.py @@ -310,3 +310,17 @@ def styleguide_organisms_tables(request): }, }) return render(request, 'styleguide/bootstrap5/organisms/tables.html', context) + + +@use_bootstrap5 +def styleguide_pages_navigation(request): + context = get_navigation_context("styleguide_pages_navigation_b5") + context.update({ + 'examples': { + 'page_title_block': get_example_context('styleguide/bootstrap5/examples/page_title_block.html'), + 'page_header': get_example_context('styleguide/bootstrap5/examples/page_header.html'), + 'navs_cards': get_example_context('styleguide/bootstrap5/examples/navs_cards.html'), + 'navs_tabs': get_example_context('styleguide/bootstrap5/examples/navs_tabs.html'), + }, + }) + return render(request, 'styleguide/bootstrap5/pages/navigation.html', context)