Refactored to check for centered pages instead of left-justified pages. Simplified global application of widescreen in context processor. Fixed unformatted pages.

This commit is contained in:
CocoByte 2024-12-19 21:47:48 -07:00
parent f8d7cfdb6a
commit fde44c246c
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F
16 changed files with 507 additions and 538 deletions

View file

@ -19,7 +19,7 @@
// matches max-width to equal the max-width of .grid-container // matches max-width to equal the max-width of .grid-container
// used to trick the eye into thinking we have left-aligned a // used to trick the eye into thinking we have left-aligned a
// regular grid-container within a widescreen (see instances // regular grid-container within a widescreen (see instances
// where is_widescreen_left_justified is used in the html). // where is_widescreen_centered is used in the html).
.max-width--grid-container { .max-width--grid-container {
max-width: 64rem; max-width: 64rem;
} }

View file

@ -252,7 +252,7 @@ TEMPLATES = [
"registrar.context_processors.add_path_to_context", "registrar.context_processors.add_path_to_context",
"registrar.context_processors.portfolio_permissions", "registrar.context_processors.portfolio_permissions",
"registrar.context_processors.is_widescreen_mode", "registrar.context_processors.is_widescreen_mode",
"registrar.context_processors.is_widescreen_left_justified", "registrar.context_processors.is_widescreen_centered",
], ],
}, },
}, },

View file

@ -99,68 +99,30 @@ def portfolio_permissions(request):
def is_widescreen_mode(request): def is_widescreen_mode(request):
widescreen_paths = [ exclude_paths = ["/admin/"]
"/domain-request/",
] # If this list is meant to include specific paths, populate it.
portfolio_widescreen_paths = [
"/domains/",
"/requests/",
"/no-organization-requests/",
"/no-organization-domains/",
"/members/",
]
# widescreen_paths can be a bear as it trickles down sub-urls. exclude_paths gives us a way out.
exclude_paths = ["/domains/edit", "/admin/"]
# Check if the current path matches a widescreen path or the root path.
is_widescreen = any(path in request.path for path in widescreen_paths) or request.path == "/"
# Check if the user is an organization user and the path matches portfolio paths.
is_portfolio_widescreen = (
hasattr(request.user, "is_org_user")
and request.user.is_org_user(request)
and any(path in request.path for path in portfolio_widescreen_paths)
)
# Widescreen is now global for all pages EXCEPT admin
is_excluded = any(exclude_path in request.path for exclude_path in exclude_paths) is_excluded = any(exclude_path in request.path for exclude_path in exclude_paths)
# Return a dictionary with the widescreen mode status. # Return a dictionary with the widescreen mode status.
return { return {
"is_widescreen_mode": (is_widescreen or is_portfolio_widescreen or get_is_widescreen_left_justified(request)) "is_widescreen_mode": not is_excluded
and not is_excluded
} }
def is_widescreen_centered(request):
def get_is_widescreen_left_justified(request):
include_paths = [ include_paths = [
"/user-profile", "/domains/",
"/request/", "/requests/",
"/domain/", "/members/",
] ]
portfolio_include_paths = [ exclude_paths = [
"/organization/", "/domains/edit",
"/senior-official/",
"/member/",
"/members/new-member",
] ]
exclude_paths = []
is_excluded = any(exclude_path in request.path for exclude_path in exclude_paths) is_excluded = any(exclude_path in request.path for exclude_path in exclude_paths)
# Check if the current path matches a path in included_paths or the root path. # Check if the current path matches a path in included_paths or the root path.
is_widescreen_left_justified = any(path in request.path for path in include_paths) is_widescreen_centered = any(path in request.path for path in include_paths) or request.path=="/"
# Check if the user is an organization user and the path matches portfolio_only paths.
is_portfolio_widescreen_left_justified = (
hasattr(request.user, "is_org_user")
and request.user.is_org_user(request)
and any(path in request.path for path in portfolio_include_paths)
)
return (is_widescreen_left_justified or is_portfolio_widescreen_left_justified) and not is_excluded
def is_widescreen_left_justified(request):
# Return a dictionary with the widescreen mode status. # Return a dictionary with the widescreen mode status.
return {"is_widescreen_left_justified": get_is_widescreen_left_justified(request)} return {"is_widescreen_centered": is_widescreen_centered and not is_excluded}

View file

@ -6,7 +6,7 @@
{% block content %} {% block content %}
<main id="main-content" class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}"> <main id="main-content" class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}">
<div class="grid-row grow-gap {% if is_widescreen_left_justified %} max-width--grid-container {% endif %}"> <div class="grid-row grow-gap {% if not is_widescreen_centered %} max-width--grid-container {% endif %}">
<div class="tablet:grid-col-6 usa-prose margin-bottom-3"> <div class="tablet:grid-col-6 usa-prose margin-bottom-3">
<h1> <h1>
{% translate "You are not authorized to view this page" %} {% translate "You are not authorized to view this page" %}

View file

@ -6,7 +6,7 @@
{% block content %} {% block content %}
<main id="main-content" class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}"> <main id="main-content" class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}">
<div class="grid-row grow-gap {% if is_widescreen_left_justified %} max-width--grid-container {% endif %}"> <div class="grid-row grow-gap {% if not is_widescreen_centered %} max-width--grid-container {% endif %}">
<div class="tablet:grid-col-6 usa-prose margin-bottom-3"> <div class="tablet:grid-col-6 usa-prose margin-bottom-3">
<h1> <h1>
{% translate "You're not authorized to view this page." %} {% translate "You're not authorized to view this page." %}

View file

@ -6,7 +6,7 @@
{% block content %} {% block content %}
<main id="main-content" class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}"> <main id="main-content" class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}">
<div class="grid-row grid-gap {% if is_widescreen_left_justified %} max-width--grid-container {% endif %}"> <div class="grid-row grid-gap {% if not is_widescreen_centered %} max-width--grid-container {% endif %}">
<div class="tablet:grid-col-6 usa-prose margin-bottom-3"> <div class="tablet:grid-col-6 usa-prose margin-bottom-3">
<h1> <h1>
{% translate "We couldnt find that page" %} {% translate "We couldnt find that page" %}

View file

@ -6,7 +6,7 @@
{% block content %} {% block content %}
<main id="main-content" class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}"> <main id="main-content" class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}">
<div class="grid-row grid-gap {% if is_widescreen_left_justified %} max-width--grid-container {% endif %}"> <div class="grid-row grid-gap {% if not is_widescreen_centered %} max-width--grid-container {% endif %}">
<div class="tablet:grid-col-6 usa-prose margin-bottom-3"> <div class="tablet:grid-col-6 usa-prose margin-bottom-3">
<h1> <h1>
{% translate "We're having some trouble." %} {% translate "We're having some trouble." %}

View file

@ -6,7 +6,7 @@
{% block content %} {% block content %}
<div class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}"> <div class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}">
<div class="grid-row grid-gap {% if is_widescreen_left_justified %} max-width--grid-container {% endif %}"> <div class="grid-row grid-gap {% if not is_widescreen_centered %} max-width--grid-container {% endif %}">
<div class="tablet:grid-col-3 "> <div class="tablet:grid-col-3 ">
<p class="font-body-md margin-top-0 margin-bottom-2 <p class="font-body-md margin-top-0 margin-bottom-2
text-primary-darker text-semibold domain-name-wrap" text-primary-darker text-semibold domain-name-wrap"

View file

@ -4,7 +4,7 @@
{% block title %}{{form_titles|get_item:steps.current}} | Request a .gov | {% endblock %} {% block title %}{{form_titles|get_item:steps.current}} | Request a .gov | {% endblock %}
{% block content %} {% block content %}
<div class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}"> <div class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}">
<div class="grid-row grid-gap {% if is_widescreen_left_justified %} max-width--grid-container {% endif %}"> <div class="grid-row grid-gap {% if not is_widescreen_centered %} max-width--grid-container {% endif %}">
<div class="tablet:grid-col-3"> <div class="tablet:grid-col-3">
{% include 'domain_request_sidebar.html' %} {% include 'domain_request_sidebar.html' %}
</div> </div>

View file

@ -4,8 +4,9 @@
{% block title %} Start a request | {% endblock %} {% block title %} Start a request | {% endblock %}
{% block content %} {% block content %}
<main id="main-content" class="grid-container"> <main id="main-content" class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}">
<div class="grid-col desktop:grid-offset-2 desktop:grid-col-8"> <div class="grid-row {% if not is_widescreen_centered %} max-width--grid-container {% endif %}">
<div class="grid-col {% if is_widescreen_centered %} desktop:grid-offset-2 {% endif %} desktop:grid-col-8">
<form class="usa-form usa-form--extra-large" method="post" novalidate> <form class="usa-form usa-form--extra-large" method="post" novalidate>
{% csrf_token %} {% csrf_token %}
@ -25,7 +26,7 @@
{% include "includes/profile_information.html" with user=user%} {% include "includes/profile_information.html" with user=user%}
{% block form_buttons %} {% block form_buttons %}
<div class="stepnav"> <div class="stepnav">
<button <button
type="submit" type="submit"
@ -34,7 +35,7 @@
class="usa-button" class="usa-button"
>Continue</button> >Continue</button>
</div> </div>
{% endblock %} {% endblock %}
</form> </form>

View file

@ -8,18 +8,20 @@
{% endblock wrapperdiv %} {% endblock wrapperdiv %}
{% block content %} {% block content %}
<div class="grid-container"> <div class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}">
<div class="grid-col desktop:grid-offset-2 desktop:grid-col-8"> <div class="grid-row {% if not is_widescreen_centered %} max-width--grid-container {% endif %}">
<div class="grid-col {% if is_widescreen_centered %} desktop:grid-offset-2 {% endif %} desktop:grid-col-8">
<h1>Withdraw request for {{ DomainRequest.requested_domain.name }}?</h1> <h1>Withdraw request for {{ DomainRequest.requested_domain.name }}?</h1>
<p>If you withdraw your request, we won't review it. Once you withdraw your request, you can edit it and submit it again. </p> <p>If you withdraw your request, we won't review it. Once you withdraw your request, you can edit it and submit it again. </p>
<p><a href="{% url 'domain-request-withdrawn' DomainRequest.id %}" class="usa-button withdraw">Withdraw request</a> <p><a href="{% url 'domain-request-withdrawn' DomainRequest.id %}" class="usa-button withdraw">Withdraw request</a>
<a href="{% url 'domain-request-status' DomainRequest.id %}">Cancel</a></p> <a href="{% url 'domain-request-status' DomainRequest.id %}">Cancel</a></p>
</div> </div>
</div>
</div> </div>
{% endblock %} {% endblock %}

View file

@ -10,7 +10,7 @@
{# the entire logged in page goes here #} {# the entire logged in page goes here #}
{% block homepage_content %} {% block homepage_content %}
<div class="tablet:grid-col-11 desktop:grid-col-10 tablet:grid-offset-1"> <div class="tablet:grid-col-11 desktop:grid-col-10 {% if is_widescreen_centered %} tablet:grid-offset-1 {% endif %}">
{% block messages %} {% block messages %}
{% include "includes/form_messages.html" %} {% include "includes/form_messages.html" %}
{% endblock %} {% endblock %}

View file

@ -1,7 +1,8 @@
{% load custom_filters %} {% load custom_filters %}
{% load static url_helpers %} {% load static url_helpers %}
<main id="main-content" class="grid-container"> <main id="main-content" class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}">
<div class="grid-col desktop:grid-offset-2 desktop:grid-col-8"> <div class="grid-row {% if not is_widescreen_centered %} max-width--grid-container {% endif %}">
<div class="grid-col {% if is_widescreen_centered %} desktop:grid-offset-2 {% endif %} desktop:grid-col-8">
{% block breadcrumb %} {% block breadcrumb %}
{% if portfolio %} {% if portfolio %}
{% url 'domain-requests' as url %} {% url 'domain-requests' as url %}
@ -139,7 +140,7 @@
{% endblock modify_request %} {% endblock modify_request %}
</div> </div>
<div class="grid-col desktop:grid-offset-2 maxw-tablet"> <div class="grid-col {% if is_widescreen_centered %} desktop:grid-offset-2 maxw-tablet{% endif %}">
{% block request_summary_header %} {% block request_summary_header %}
<h2 class="text-primary-darker"> Summary of your domain request </h2> <h2 class="text-primary-darker"> Summary of your domain request </h2>
{% endblock request_summary_header%} {% endblock request_summary_header%}
@ -233,4 +234,5 @@
{% endwith %} {% endwith %}
{% endblock request_summary%} {% endblock request_summary%}
</div> </div>
</div>
</main> </main>

View file

@ -1,7 +1,8 @@
{% load custom_filters %} {% load custom_filters %}
{% load static url_helpers %} {% load static url_helpers %}
<main id="main-content" class="grid-container"> <main id="main-content" class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}">
<div class="grid-col desktop:grid-offset-2 desktop:grid-col-8"> <div class="grid-row {% if not is_widescreen_centered %} max-width--grid-container {% endif %}">
<div class="grid-col desktop:grid-col-8 {% if is_widescreen_centered %} desktop:grid-offset-2 {% endif %}">
{% block breadcrumb %} {% block breadcrumb %}
{% if portfolio %} {% if portfolio %}
{% url 'domain-requests' as url %} {% url 'domain-requests' as url %}
@ -139,7 +140,7 @@
{% endblock modify_request %} {% endblock modify_request %}
</div> </div>
<div class="grid-col desktop:grid-offset-2 maxw-tablet"> <div class="grid-col {% if is_widescreen_centered %} desktop:grid-offset-2 maxw-tablet{% endif %}">
{% block request_summary_header %} {% block request_summary_header %}
<h2 class="text-primary-darker"> Summary of your domain request </h2> <h2 class="text-primary-darker"> Summary of your domain request </h2>
{% endblock request_summary_header%} {% endblock request_summary_header%}
@ -237,4 +238,5 @@
{% endif %} {% endif %}
{% endblock request_summary%} {% endblock request_summary%}
</div> </div>
</div>
</main> </main>

View file

@ -8,8 +8,8 @@
{% if user.is_authenticated %} {% if user.is_authenticated %}
{# the entire logged in page goes here #} {# the entire logged in page goes here #}
<div class="grid-row {% if is_widescreen_left_justified %} max-width--grid-container {% endif %}"> <div class="grid-row {% if not is_widescreen_centered %} max-width--grid-container {% endif %}">
<div class="tablet:grid-col-11 desktop:grid-col-10 {% if not is_widescreen_left_justified %} tablet:grid-offset-1 {% endif %}"> <div class="tablet:grid-col-11 desktop:grid-col-10 {% if is_widescreen_centered %} tablet:grid-offset-1 {% endif %}">
{% block messages %} {% block messages %}
{% include "includes/form_messages.html" %} {% include "includes/form_messages.html" %}
{% endblock %} {% endblock %}

View file

@ -12,7 +12,7 @@ Edit your User Profile |
{% block content %} {% block content %}
<main id="main-content" class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}"> <main id="main-content" class="grid-container {% if is_widescreen_mode %} grid-container--widescreen {% endif %}">
<div class="grid-row {% if is_widescreen_left_justified %} max-width--grid-container {% endif %}"> <div class="grid-row {% if not is_widescreen_centered %} max-width--grid-container {% endif %}">
<div class="desktop:grid-col-8"> <div class="desktop:grid-col-8">
{% if messages %} {% if messages %}
{% for message in messages %} {% for message in messages %}