Skip to content

Commit

Permalink
Add regions, make sidebars content aware
Browse files Browse the repository at this point in the history
  • Loading branch information
occupant committed Feb 16, 2023
1 parent bc4a695 commit 85d7ad2
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 28 deletions.
2 changes: 2 additions & 0 deletions kraken.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ ckeditor_stylesheets:
- css/drupal.ckeditor.iframe.css

regions:
pre_content: 'Pre-content'
search: 'Search'
primary_menu: 'Primary menu'
secondary_menu: 'Secondary menu'
alert_region: 'Alert region'
Expand Down
8 changes: 6 additions & 2 deletions templates/includes/header.clf7.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
<div class="collapse expand" id="ubc7-global-menu">
{% endif %}
<div id="ubc7-search" class="expand">
<div class="clf-container">
<div id="ubc7-search-box">
<div class="clf-container">
<div id="ubc7-search-box" class="mx-auto max-w-[360px]">
{% if page.search %}
{{ page.search }}
{% else %}
<form class="form-search" method="get" action="https://www.ubc.ca/search/refine/" role="search">
<label for="q" class="hidden">Search UBC</label>
{% if searchlabel_option %}
Expand All @@ -23,6 +26,7 @@
{% endif %}
<button type="submit" class="btn">Search</button>
</form>
{% endif %}
</div>
</div> <!-- /clf-container -->
</div>
Expand Down
16 changes: 11 additions & 5 deletions templates/layout/page--node-type--awards.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
{% set sidebar_secondary_attributes = create_attribute() %}
{% set secondary_content_attributes = create_attribute() %}
{% set prefooter_attributes = create_attribute() %}
{% set sidebar_primary_exists = page.sidebar_primary|render|striptags('<img><video><audio><drupal-render-placeholder>')|trim is not empty %}
{% set sidebar_secondary_exists = page.sidebar_secondary|render|striptags('<img><video><audio><drupal-render-placeholder>')|trim is not empty %}
{%
set grid_classes = [
'container',
Expand Down Expand Up @@ -113,7 +115,7 @@
'col-span-full',
]
%}
{% if not page.sidebar_primary and not page.sidebar_secondary %}
{% if not sidebar_primary_exists and not page.sidebar_secondary %}
{%
set main_content_classes = [
'col-span-full',
Expand All @@ -123,7 +125,7 @@
]
%}
{% endif %}
{% if page.sidebar_primary and not page.sidebar_secondary %}
{% if sidebar_primary_exists and not page.sidebar_secondary %}
{%
set main_content_classes = [
'col-span-full',
Expand All @@ -143,7 +145,7 @@
]
%}
{% endif %}
{% if not page.sidebar_primary and page.sidebar_secondary %}
{% if sidebar_secondary_exists and not sidebar_primary_exists %}
{%
set main_content_classes = [
'col-span-full',
Expand All @@ -169,6 +171,10 @@

<div id="main-content">

{% if page.pre_content %}
{{ page.pre_content }}
{% endif %}

{% if (clf_version == '8') %}
{% include '@kraken/includes/header.html.twig' %}
{% else %}
Expand Down Expand Up @@ -205,13 +211,13 @@
</section>
</div>

{% if page.sidebar_primary %}
{% if sidebar_primary_exists %}
<section{{ sidebar_primary_attributes.addClass(sidebar_primary_classes).setAttribute('id', 'sidebar-primary') }}>
{{ page.sidebar_primary }}
</section>
{% endif %}

{% if page.sidebar_secondary %}
{% if sidebar_secondary_exists %}
<section{{ sidebar_secondary_attributes.addClass(sidebar_secondary_classes).setAttribute('id', 'sidebar-secondary') }}>
{{ page.sidebar_secondary }}
</section>
Expand Down
18 changes: 12 additions & 6 deletions templates/layout/page--node-type--homepage.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
{% set sidebar_secondary_attributes = create_attribute() %}
{% set secondary_content_attributes = create_attribute() %}
{% set prefooter_attributes = create_attribute() %}
{% set sidebar_primary_exists = page.sidebar_primary|render|striptags('<img><video><audio><drupal-render-placeholder>')|trim is not empty %}
{% set sidebar_secondary_exists = page.sidebar_secondary|render|striptags('<img><video><audio><drupal-render-placeholder>')|trim is not empty %}
{%
set grid_classes = [
'container',
Expand Down Expand Up @@ -105,15 +107,15 @@
'col-span-full',
]
%}
{% if not page.sidebar_primary and not page.sidebar_secondary %}
{% if not sidebar_primary_exists and not sidebar_secondary_exists %}
{%
set main_content_classes = [
'col-span-full',
'mt-12',
]
%}
{% endif %}
{% if page.sidebar_primary and not page.sidebar_secondary %}
{% if sidebar_primary_exists and not sidebar_secondary_exists %}
{%
set main_content_classes = [
'col-span-full',
Expand All @@ -133,8 +135,8 @@
]
%}
{% endif %}
{% if page.sidebar_secondary and not page.sidebar_primary %}
{%
{% if sidebar_secondary_exists and not sidebar_primary_exists %}
{%
set main_content_classes = [
'col-span-full',
'md--col-span-8',
Expand All @@ -157,6 +159,10 @@

<div id="main-content">

{% if page.pre_content %}
{{ page.pre_content }}
{% endif %}

{% if (clf_version == '8') %}
{% include '@kraken/includes/header.html.twig' %}
{% else %}
Expand Down Expand Up @@ -187,13 +193,13 @@
</section>
</div>

{% if page.sidebar_primary %}
{% if sidebar_primary_exists %}
<section{{ sidebar_primary_attributes.addClass(sidebar_primary_classes).setAttribute('id', 'sidebar-primary') }}>
{{ page.sidebar_primary }}
</section>
{% endif %}

{% if page.sidebar_secondary %}
{% if sidebar_secondary_exists %}
<section{{ sidebar_secondary_attributes.addClass(sidebar_secondary_classes).setAttribute('id', 'sidebar-secondary') }}>
{{ page.sidebar_secondary }}
</section>
Expand Down
16 changes: 11 additions & 5 deletions templates/layout/page--node-type--ubc-landing-page.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
{% set sidebar_secondary_attributes = create_attribute() %}
{% set secondary_content_attributes = create_attribute() %}
{% set prefooter_attributes = create_attribute() %}
{% set sidebar_primary_exists = page.sidebar_primary|render|striptags('<img><video><audio><drupal-render-placeholder>')|trim is not empty %}
{% set sidebar_secondary_exists = page.sidebar_secondary|render|striptags('<img><video><audio><drupal-render-placeholder>')|trim is not empty %}
{%
set grid_classes = [
'container',
Expand Down Expand Up @@ -113,15 +115,15 @@
'col-span-full',
]
%}
{% if not page.sidebar_primary and not page.sidebar_secondary %}
{% if not sidebar_primary_exists and not sidebar_secondary_exists %}
{%
set main_content_classes = [
'col-span-full',
'mt-12',
]
%}
{% endif %}
{% if page.sidebar_primary and not page.sidebar_secondary %}
{% if sidebar_primary_exists and not sidebar_secondary_exists %}
{%
set main_content_classes = [
'col-span-full',
Expand All @@ -141,7 +143,7 @@
]
%}
{% endif %}
{% if page.sidebar_secondary and not page.sidebar_primary %}
{% if sidebar_secondary_exists and not sidebar_primary_exists %}
{%
set main_content_classes = [
'col-span-full',
Expand All @@ -167,6 +169,10 @@

<div id="main-content">

{% if page.pre_content %}
{{ page.pre_content }}
{% endif %}

{% if (clf_version == '8') %}
{% include '@kraken/includes/header.html.twig' %}
{% else %}
Expand Down Expand Up @@ -203,13 +209,13 @@
</section>
</div>

{% if page.sidebar_primary %}
{% if sidebar_primary_exists %}
<section{{ sidebar_primary_attributes.addClass(sidebar_primary_classes).setAttribute('id', 'sidebar-primary') }}>
{{ page.sidebar_primary }}
</section>
{% endif %}

{% if page.sidebar_secondary %}
{% if sidebar_secondary_exists %}
<section{{ sidebar_secondary_attributes.addClass(sidebar_secondary_classes).setAttribute('id', 'sidebar-secondary') }}>
{{ page.sidebar_secondary }}
</section>
Expand Down
16 changes: 11 additions & 5 deletions templates/layout/page--node-type--ubc-page.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
{% set sidebar_secondary_attributes = create_attribute() %}
{% set secondary_content_attributes = create_attribute() %}
{% set prefooter_attributes = create_attribute() %}
{% set sidebar_primary_exists = page.sidebar_primary|render|striptags('<img><video><audio><drupal-render-placeholder>')|trim is not empty %}
{% set sidebar_secondary_exists = page.sidebar_secondary|render|striptags('<img><video><audio><drupal-render-placeholder>')|trim is not empty %}
{%
set grid_classes = [
'container',
Expand Down Expand Up @@ -113,15 +115,15 @@
'col-span-full',
]
%}
{% if not page.sidebar_primary and not page.sidebar_secondary %}
{% if not sidebar_primary_exists and not sidebar_secondary_exists %}
{%
set main_content_classes = [
'col-span-full',
'mt-12',
]
%}
{% endif %}
{% if page.sidebar_primary and not page.sidebar_secondary %}
{% if sidebar_primary_exists and not sidebar_secondary_exists %}
{%
set main_content_classes = [
'col-span-full',
Expand All @@ -141,7 +143,7 @@
]
%}
{% endif %}
{% if page.sidebar_secondary and not page.sidebar_primary %}
{% if sidebar_secondary_exists and not sidebar_primary_exists %}
{%
set main_content_classes = [
'col-span-full',
Expand All @@ -167,6 +169,10 @@

<div id="main-content">

{% if page.pre_content %}
{{ page.pre_content }}
{% endif %}

{% if (clf_version == '8') %}
{% include '@kraken/includes/header.html.twig' %}
{% else %}
Expand Down Expand Up @@ -203,13 +209,13 @@
</section>
</div>

{% if page.sidebar_primary %}
{% if sidebar_primary_exists %}
<section{{ sidebar_primary_attributes.addClass(sidebar_primary_classes).setAttribute('id', 'sidebar-primary') }}>
{{ page.sidebar_primary }}
</section>
{% endif %}

{% if page.sidebar_secondary %}
{% if sidebar_secondary_exists %}
<section{{ sidebar_secondary_attributes.addClass(sidebar_secondary_classes).setAttribute('id', 'sidebar-secondary') }}>
{{ page.sidebar_secondary }}
</section>
Expand Down
16 changes: 11 additions & 5 deletions templates/layout/page.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
{% set sidebar_secondary_attributes = create_attribute() %}
{% set secondary_content_attributes = create_attribute() %}
{% set prefooter_attributes = create_attribute() %}
{% set sidebar_primary_exists = page.sidebar_primary|render|striptags('<img><video><audio><drupal-render-placeholder>')|trim is not empty %}
{% set sidebar_secondary_exists = page.sidebar_secondary|render|striptags('<img><video><audio><drupal-render-placeholder>')|trim is not empty %}
{%
set grid_classes = [
'container',
Expand Down Expand Up @@ -113,7 +115,7 @@
'col-span-full',
]
%}
{% if not page.sidebar_primary and not page.sidebar_secondary %}
{% if not sidebar_primary_exists and not sidebar_secondary_exists %}
{%
set main_content_classes = [
'col-span-full',
Expand All @@ -125,7 +127,7 @@
]
%}
{% endif %}
{% if page.sidebar_primary and not page.sidebar_secondary %}
{% if sidebar_primary_exists and not sidebar_secondary_exists %}
{%
set main_content_classes = [
'col-span-full',
Expand All @@ -145,7 +147,7 @@
]
%}
{% endif %}
{% if page.sidebar_secondary and not page.sidebar_primary %}
{% if sidebar_secondary_exists and not sidebar_primary_exists %}
{%
set main_content_classes = [
'col-span-full',
Expand All @@ -171,6 +173,10 @@

<div id="main-content">

{% if page.pre_content %}
{{ page.pre_content }}
{% endif %}

{% if (clf_version == '8') %}
{% include '@kraken/includes/header.html.twig' %}
{% else %}
Expand Down Expand Up @@ -207,13 +213,13 @@
</section>
</div>

{% if page.sidebar_primary %}
{% if sidebar_primary_exists %}
<section{{ sidebar_primary_attributes.addClass(sidebar_primary_classes).setAttribute('id', 'sidebar-primary') }}>
{{ page.sidebar_primary }}
</section>
{% endif %}

{% if page.sidebar_secondary %}
{% if sidebar_secondary_exists %}
<section{{ sidebar_secondary_attributes.addClass(sidebar_secondary_classes).setAttribute('id', 'sidebar-secondary') }}>
{{ page.sidebar_secondary }}
</section>
Expand Down

0 comments on commit 85d7ad2

Please sign in to comment.