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

New HQ Style Guide (for Bootstrap 5 Pages), and Bootstrap 5 Migration Guide #34202

Merged
merged 67 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
461320e
add initial styleguide stylesheet based on bootstrap 5's docs pages
biyeun Oct 4, 2023
df81609
add first bootstrap 5 styleguide view
biyeun Oct 4, 2023
00862a7
add page on accessibility
biyeun Oct 4, 2023
842fc1f
add typography section
biyeun Oct 4, 2023
f9a0f8d
embed nunito sans in base styleguide stylesheet
biyeun Oct 4, 2023
017e691
add colors page in styleguide
biyeun Oct 6, 2023
82e88a5
adding icons section to stylesheet b5
biyeun Oct 6, 2023
ccbf070
move icon-related images out of bootstrap3 specific images and into n…
biyeun Oct 6, 2023
21fae92
add code guidelines page
biyeun Oct 9, 2023
9291826
add app-biometrics to icon list
biyeun Oct 24, 2023
425ad5b
update process for creating new icons in commcare font
biyeun Oct 25, 2023
8c4d628
remove old icon creation process from bootstrap 3 styleguide and poin…
biyeun Oct 25, 2023
78757bb
add buttons in molecules section
biyeun Oct 25, 2023
3559ebd
change alert class
biyeun Oct 25, 2023
4b4fcc5
make code examples more standardized and easier to work with
biyeun Oct 26, 2023
7691755
add selections section to molecules
biyeun Oct 26, 2023
4d4dd4b
add a way to include crispy forms examples quickly in bootstrap5 styl…
biyeun Oct 31, 2023
e0d2760
add styleguide for checkboxes and switches, use_bootstrap5 decorator …
biyeun Oct 31, 2023
b54c5c5
share more code between example templates
biyeun Nov 1, 2023
b7d4dc6
add example template with crispy forms with js
biyeun Nov 1, 2023
554791c
add demo for the Select2Ajax widget in crispy forms
biyeun Nov 1, 2023
6251207
add crispy forms related docs for selections
biyeun Nov 1, 2023
e976fb6
make sure example forms appear the same as the rest of HQ
biyeun Nov 1, 2023
d0a8ede
add USE_BOOTSTRAP5 to window context before javascript_libraries temp…
biyeun Nov 6, 2023
142d28e
make sure styleguide/base.html has the initial data and registered ur…
biyeun Nov 6, 2023
2c3ff84
add styleguide page for modals
biyeun Nov 6, 2023
ba62c91
add pagination section to molecules
biyeun Nov 6, 2023
66235d9
add section for searching and filtering in molecules for bootstrap 5 …
biyeun Nov 7, 2023
0bc49ea
update some text in pagination section
biyeun Nov 7, 2023
d540c6a
update typos in table of contents for searching section
biyeun Nov 7, 2023
31715fd
make sure csrf token is injected into ajax calls on styleguide pages
biyeun Nov 9, 2023
be1d4fe
add section for inline edit in molecules for bootstrap5 styleguide
biyeun Nov 9, 2023
ef03049
add feedback section under moleculs in bootstrap 5 styleguide
biyeun Nov 9, 2023
25aad7e
fix formatting
biyeun Nov 9, 2023
caf3e0a
style code blocks in styleguide with ace so that they are more readable
biyeun Nov 14, 2023
8ae8bda
add forms section to Organisms > Forms in bootstrap 5 styleguide
biyeun Nov 14, 2023
763d38d
set ace base path in styleguide
biyeun Nov 15, 2023
ed7d754
add additional docs for placeholders, help text, disabled, and readon…
biyeun Nov 16, 2023
5455c9d
add blocks for stylesheets and javascript in base styleguide template
biyeun Nov 28, 2023
c9d542c
add support for copying links to individual sections in the styleguide
biyeun Nov 28, 2023
8d16b85
add styleguide section on tables
biyeun Nov 28, 2023
085caf7
add additional styleguide context on colors for design
biyeun Nov 30, 2023
3761f06
add more context surrounding tables and layout
biyeun Dec 6, 2023
bfe1dc1
add migration guide
biyeun Dec 13, 2023
38be322
update refs to hqwebapp/js/widgets in the styleguide
biyeun Jan 18, 2024
ae3f47c
update styleguide/base.html to use tempus dominus as main date time p…
biyeun Jan 23, 2024
05381a4
add dates and times section to styleguide
biyeun Jan 23, 2024
e70462f
cleanup migration guide text
biyeun Jan 23, 2024
32963f0
fix code guidelines toc
biyeun Jan 23, 2024
6034b8a
make sure all styleguide pages have use_bootstrap5 decorator
biyeun Jan 23, 2024
510c610
add usage note for datatables
biyeun Jan 23, 2024
d6303c8
add link to javascript guide on read the docs
biyeun Jan 23, 2024
383b6d1
add section on navigation
biyeun Jan 23, 2024
2fc29f7
update code for display widget
biyeun Jan 25, 2024
44307d3
rename to get_python_example_context
biyeun Jan 25, 2024
8081c5f
add utilities for helping to structure necessary template context for…
biyeun Feb 22, 2024
f35f082
fix url prefix in old styleguide tabs
biyeun Feb 22, 2024
bbc559a
add styleguide section on views
biyeun Feb 22, 2024
ec58095
standardize padding around text-only code examples
biyeun Feb 22, 2024
1dfc1d2
add bootstrap 5 styleguide tabs to tabs/config.py
biyeun Feb 22, 2024
13f7e2b
add example of top-level navigation tabs to styleguide page on naviga…
biyeun Feb 22, 2024
40b02be
update bootstrap migration guide on suggestions for sharing markdown …
biyeun Feb 22, 2024
5f74eda
specify app_name a little more to reduce confusion
biyeun Feb 22, 2024
e7912ce
make this table bold
biyeun Feb 22, 2024
9c192b3
add deprecation message and link to new styleguide in bootstrap 3 sty…
biyeun Feb 22, 2024
8d3e342
lint
biyeun Feb 22, 2024
558d24c
update icons in styleguide to match new icons from fontawesome 6
biyeun Feb 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions corehq/apps/hqwebapp/context.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from collections import namedtuple

Section = namedtuple('Section', 'page_name url')
ParentPage = namedtuple('ParentPage', 'title url')


def get_page_context(page_title, page_url, page_name=None, parent_pages=None, domain=None, section=None):
"""This sets up the page context for functional views inheriting from the following base templates:
hqwebapp/{bootstrap_version}/base_page.html
hqwebapp/{bootstrap_version}/base_section.html
note: do not inherit from two_column.html, unless you have a very specific use-case
for navigation, see the style guide section on Navigation

:param page_title: an instance of ``str``, title of the page...inserted into <title></title> tags
:param page_url: an instance of ``str``, often reverse("urlname") or reverse("urlname", args=[...])
:param page_name: an instance of ``str``, human-visible page name, defaults to page_title
:param parent_pages: ``None`` or a ``list`` of ``ParentPage``
:param domain: an instance of ``str``, the domain slug
:param section: an instance of the ``Section`` context
"""
page_name = page_name or page_title
parent_pages = parent_pages or []
base_context = {
'current_page': {
'page_name': page_name,
'title': page_title,
'url': page_url,
'parents': parent_pages,
},
}
if domain:
base_context['domain'] = domain
if section:
base_context['section'] = section
return base_context
224 changes: 224 additions & 0 deletions corehq/apps/hqwebapp/static/hqwebapp/scss/styleguide.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
@import "functions";
@import "commcarehq/variables";
@import "variables";
@import "variables-dark";

// Layout structure inspired by Bootstrap's 5.3 docs page

.sg-gutter {
--bs-gutter-x: 3rem;
}

.sg-layout {
display: grid;
grid-template-areas: "sidebar main";
grid-template-columns: 1fr 5fr;
gap: 1.5rem;
font-size: 1rem;
}

.sg-example {
font-size: $font-size-base;

pre {
font-size: .8rem;
}
}

.sg-sidebar {
grid-area: sidebar;

@media (min-width: 992px) {
position: -webkit-sticky;
position: sticky;
top: 5rem;
display: block !important;
height: calc(100vh - 6rem);
padding-left: 0.25rem;
margin-left: -0.25rem;
overflow-y: auto;
}
}

.sg-main {
grid-area: main;

grid-template-areas:
"intro toc"
"content toc";
grid-template-rows: auto 1fr;
grid-template-columns: 4fr 1fr;

@media (min-width: 768px) {
display: grid;
gap: inherit;
}
}

.sg-title {
font-size: 3rem;
}

.sg-lead {
font-size: 1.5rem;
}

.sg-intro {
grid-area: intro;
}

.sg-toc {
grid-area: toc;
font-size: 1rem;

@media (min-width: 992px) {
position: -webkit-sticky;
position: sticky;
top: 5rem;
right: 0;
z-index: 2;
height: calc(100vh - 7rem);
overflow-y: auto;
}

}

.sg-toc nav {
font-size: 0.875rem;

ul {
padding-left: 0;
margin-bottom: 0;
list-style: none;

ul {
padding-left: 1rem;
}
}

a {
display: block;
padding: 0.125rem 0 0.125rem 0.75rem;
text-decoration: none;
border-left: 0.125rem solid transparent;

&.active {
font-weight: 500;
border-left-color: $color-purple-dark;
}
}

}

.sg-content {
grid-area: content;
min-width: 1px;
}
.sg-links-link {
padding: 3px 10px;
display: block;

&.active {
font-weight: 600;
}

&.active,
&:hover {
background-color: $cc-brand-hi;
}
}

code {
color: $purple;
background: none;
border: none;
font-weight: bold;
}

pre.ace-chrome {
background-color: transparent;
line-height: 1.25rem;
}

pre.ace-chrome .ace_marker-layer .ace_bracket {
border: none;
}

pre.ace-chrome .ace_comment {
font-weight: bold;
}

$sg-color-preview: (
"blue-100": $blue-100,
"blue-200": $blue-200,
"blue-300": $blue-300,
"blue-400": $blue-400,
"blue-500": $blue-500,
"blue-600": $blue-600,
"blue-700": $blue-700,
"blue-800": $blue-800,
"blue-900": $blue-900,
"gray-100": $gray-100,
"gray-200": $gray-200,
"gray-300": $gray-300,
"gray-400": $gray-400,
"gray-500": $gray-500,
"gray-600": $gray-600,
"gray-700": $gray-700,
"gray-800": $gray-800,
"gray-900": $gray-900,
"indigo-100": $indigo-100,
"indigo-200": $indigo-200,
"indigo-300": $indigo-300,
"indigo-400": $indigo-400,
"indigo-500": $indigo-500,
"indigo-600": $indigo-600,
"indigo-700": $indigo-700,
"indigo-800": $indigo-800,
"indigo-900": $indigo-900,
"purple-100": $purple-100,
"purple-200": $purple-200,
"purple-300": $purple-300,
"purple-400": $purple-400,
"purple-500": $purple-500,
"purple-600": $purple-600,
"purple-700": $purple-700,
"purple-800": $purple-800,
"purple-900": $purple-900,
"pink-100": $pink-100,
"pink-200": $pink-200,
"pink-300": $pink-300,
"pink-400": $pink-400,
"pink-500": $pink-500,
"pink-600": $pink-600,
"pink-700": $pink-700,
"pink-800": $pink-800,
"pink-900": $pink-900,
"salmon-100": $salmon-100,
"salmon-200": $salmon-200,
"salmon-300": $salmon-300,
"salmon-400": $salmon-400,
"salmon-500": $salmon-500,
"salmon-600": $salmon-600,
"salmon-700": $salmon-700,
"salmon-800": $salmon-800,
"salmon-900": $salmon-900,
"indigo": $indigo,
"purple": $purple,
"pink": $pink,
"salmon": $salmon,
"orange": $orange,
"dimagi-deep-purple": $dimagi-deep-purple,
"dimagi-sky": $dimagi-sky,
"dimagi-indigo": $dimagi-indigo,
"dimagi-marigold": $dimagi-marigold,
"dimagi-sunset": $dimagi-sunset,
"dimagi-mango": $dimagi-mango,
);

@each $color, $value in $sg-color-preview {
.sg-bg-#{$color} {
color: color-contrast($value);
background-color: $value;
}
}
Loading
Loading