Port navbar from Sculpin
This commit is contained in:
parent
117e5999ff
commit
b812176a04
|
@ -4,4 +4,5 @@ core: 8.x
|
|||
type: theme
|
||||
base theme: stable
|
||||
libraries:
|
||||
- opdavies/global-scripts
|
||||
- opdavies/global-styling
|
||||
|
|
|
@ -2,3 +2,8 @@ global-styling:
|
|||
css:
|
||||
base:
|
||||
dist/tailwind.css: {}
|
||||
global-scripts:
|
||||
js:
|
||||
'https://cdn.jsdelivr.net/gh/alpinejs/alpine@v2.x.x/dist/alpine.min.js':
|
||||
type: external
|
||||
minified: true
|
||||
|
|
5
web/themes/custom/opdavies/package-lock.json
generated
5
web/themes/custom/opdavies/package-lock.json
generated
|
@ -196,6 +196,11 @@
|
|||
"integrity": "sha1-l6ERlkmyEa0zaR2fn0hqjsn74KM=",
|
||||
"dev": true
|
||||
},
|
||||
"alpinejs": {
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/alpinejs/-/alpinejs-2.3.5.tgz",
|
||||
"integrity": "sha512-/zQiqmiM3gBVKD+yeP7p9XzOXfhxxDMAfoaJRpXiAJykGaeSe3L+bvp/a6uRQMygPV+UUdgAk8fdfToJttRcUQ=="
|
||||
},
|
||||
"amdefine": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz",
|
||||
|
|
|
@ -14,15 +14,27 @@
|
|||
*/
|
||||
#}
|
||||
{% block content %}
|
||||
<div class="flex items-center">
|
||||
{% if site_logo %}
|
||||
<a href="{{ path('<front>') }}" title="{{ 'Home'|t }}" rel="home" class="site-logo mr-2">
|
||||
<img src="{{ site_logo }}" alt="{{ 'Home'|t }}"/>
|
||||
</a>
|
||||
{% endif %}
|
||||
<div class="flex items-center leading-snug ">
|
||||
{% if site_logo %}
|
||||
<a
|
||||
class="font-semibold text-base text-white"
|
||||
href="{{ path('<front>') }}"
|
||||
rel="home"
|
||||
title="{{ 'Home'|t }}"
|
||||
>
|
||||
<img src="{{ site_logo }}" alt="{{ 'Home'|t }}"/>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if site_name %}
|
||||
<div class="site-name text-2xl">
|
||||
<a href="{{ path('<front>') }}" title="{{ 'Home'|t }}" rel="home">{{ site_name }}</a>
|
||||
<div>
|
||||
<a
|
||||
class="font-semibold text-sm text-white"
|
||||
href="{{ path('<front>') }}"
|
||||
rel="home"
|
||||
title="{{ 'Home'|t }}"
|
||||
>
|
||||
{{ site_name }}
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if site_slogan %}
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
{#
|
||||
/**
|
||||
* @file
|
||||
* Theme override for a menu block.
|
||||
*
|
||||
* Available variables:
|
||||
* - plugin_id: The ID of the block implementation.
|
||||
* - label: The configured label of the block if visible.
|
||||
* - configuration: A list of the block's configuration values.
|
||||
* - label: The configured label for the block.
|
||||
* - label_display: The display settings for the label.
|
||||
* - provider: The module or other provider that provided this block plugin.
|
||||
* - Block plugin specific settings will also be stored here.
|
||||
* - content: The content of this block.
|
||||
* - attributes: HTML attributes for the containing element.
|
||||
* - id: A valid HTML ID and guaranteed unique.
|
||||
* - title_attributes: HTML attributes for the title element.
|
||||
* - content_attributes: HTML attributes for the content element.
|
||||
* - title_prefix: Additional output populated by modules, intended to be
|
||||
* displayed in front of the main title tag that appears in the template.
|
||||
* - title_suffix: Additional output populated by modules, intended to be
|
||||
* displayed after the main title tag that appears in the template.
|
||||
*
|
||||
* Headings should be used on navigation menus that consistently appear on
|
||||
* multiple pages. When this menu block's label is configured to not be
|
||||
* displayed, it is automatically made invisible using the 'visually-hidden' CSS
|
||||
* class, which still keeps it visible for screen-readers and assistive
|
||||
* technology. Headings allow screen-reader and keyboard only users to navigate
|
||||
* to or skip the links.
|
||||
* See http://juicystudio.com/article/screen-readers-display-none.php and
|
||||
* http://www.w3.org/TR/WCAG-TECHS/H42.html for more information.
|
||||
*/
|
||||
#}
|
||||
{% set heading_id = attributes.id ~ '-menu'|clean_id %}
|
||||
<nav
|
||||
class="h-full flex items-center"
|
||||
role="navigation"
|
||||
aria-labelledby="{{ heading_id }}"{{ attributes|without('role', 'aria-labelledby') }}
|
||||
>
|
||||
{# Label. If not displayed, we still provide it for screen readers. #}
|
||||
{% if not configuration.label_display %}
|
||||
{% set title_attributes = title_attributes.addClass('visually-hidden') %}
|
||||
{% endif %}
|
||||
{{ title_prefix }}
|
||||
<h2{{ title_attributes.setAttribute('id', heading_id) }}>{{ configuration.label }}</h2>
|
||||
{{ title_suffix }}
|
||||
|
||||
{# Menu. #}
|
||||
{% block content %}
|
||||
{{ content }}
|
||||
{% endblock %}
|
||||
</nav>
|
|
@ -45,47 +45,77 @@
|
|||
* @ingroup themeable
|
||||
*/
|
||||
#}
|
||||
<div class="container mx-auto p-4">
|
||||
<div class="antialiased font-sans text-gray-800 leading-relaxed">
|
||||
<div class="min-h-screen flex flex-col">
|
||||
<div id="nav" class="bg-blue-500 border-b-3 border-blue-700">
|
||||
<div class="container">
|
||||
<div class="md:flex" x-data="{ isOpen: false }">
|
||||
<div class="w-full flex items-center md:w-1/3 lg:w-1/4">
|
||||
<div class="w-3/4 py-6">
|
||||
<div>
|
||||
{{ page.header }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<header role="banner">
|
||||
{{ page.header }}
|
||||
</header>
|
||||
<div class="w-1/4 text-right flex items-center justify-end md:hidden">
|
||||
<button type="button" class="nav-toggle appearance-none text-white hover:text-gray-300 focus:outline-none"
|
||||
aria-label="Toggle main menu" @click="isOpen = !isOpen">
|
||||
<svg class="js-hidden fill-current text-inherit w-6 h-6" xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20">
|
||||
<path x-show="!isOpen"
|
||||
d="M16.4 9H3.6c-.552 0-.6.447-.6 1 0 .553.048 1 .6 1h12.8c.552 0 .6-.447.6-1 0-.553-.048-1-.6-1zm0 4H3.6c-.552 0-.6.447-.6 1 0 .553.048 1 .6 1h12.8c.552 0 .6-.447.6-1 0-.553-.048-1-.6-1zM3.6 7h12.8c.552 0 .6-.447.6-1 0-.553-.048-1-.6-1H3.6c-.552 0-.6.447-.6 1 0 .553.048 1 .6 1z"></path>
|
||||
<path x-show="isOpen"
|
||||
d="M10 8.586L2.929 1.515 1.515 2.929 8.585 10l-7.07 7.071 1.414 1.414L10 11.415l7.071 7.07 1.414-1.414L11.415 10l7.07-7.071-1.414-1.414L10 8.585z"
|
||||
fill-rule="evenodd" style="display: none;"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ page.primary_menu }}
|
||||
{{ page.secondary_menu }}
|
||||
|
||||
{{ page.breadcrumb }}
|
||||
|
||||
{{ page.highlighted }}
|
||||
|
||||
{{ page.help }}
|
||||
|
||||
<main role="main">
|
||||
<a id="main-content" tabindex="-1"></a>{# link is in html.html.twig #}
|
||||
|
||||
<div class="md:flex -mx-4">
|
||||
<div class="md:flex-1 p-4">
|
||||
{{ page.content }}
|
||||
</div>{# /.layout-content #}
|
||||
|
||||
{% if page.sidebar_first %}
|
||||
<aside class="md:w-1/4 p-4" role="complementary">
|
||||
{{ page.sidebar_first }}
|
||||
</aside>
|
||||
{% endif %}
|
||||
|
||||
{% if page.sidebar_second %}
|
||||
<aside class="md:w-1/4" role="complementary">
|
||||
{{ page.sidebar_second }}
|
||||
</aside>
|
||||
{% endif %}
|
||||
<div class="-mx-4 md:mt-0 md:mx-0 md:relative md:flex md:flex-wrap md:flex-1 md:justify-end">
|
||||
{{ page.primary_menu }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<div class="container mx-auto p-4">
|
||||
|
||||
{% if page.footer %}
|
||||
<footer role="contentinfo">
|
||||
{{ page.footer }}
|
||||
</footer>
|
||||
{% endif %}
|
||||
{{ page.secondary_menu }}
|
||||
|
||||
</div>{# /.layout-container #}
|
||||
{{ page.breadcrumb }}
|
||||
|
||||
{{ page.highlighted }}
|
||||
|
||||
{{ page.help }}
|
||||
|
||||
<main role="main">
|
||||
<a id="main-content" tabindex="-1"></a>{# link is in html.html.twig #}
|
||||
|
||||
<div class="md:flex -mx-4">
|
||||
<div class="md:flex-1 p-4">
|
||||
{{ page.content }}
|
||||
</div>{# /.layout-content #}
|
||||
|
||||
{% if page.sidebar_first %}
|
||||
<aside class="md:w-1/4 p-4" role="complementary">
|
||||
{{ page.sidebar_first }}
|
||||
</aside>
|
||||
{% endif %}
|
||||
|
||||
{% if page.sidebar_second %}
|
||||
<aside class="md:w-1/4" role="complementary">
|
||||
{{ page.sidebar_second }}
|
||||
</aside>
|
||||
{% endif %}
|
||||
</div>
|
||||
</main>
|
||||
|
||||
{% if page.footer %}
|
||||
<footer role="contentinfo">
|
||||
{{ page.footer }}
|
||||
</footer>
|
||||
{% endif %}
|
||||
|
||||
</div>{# /.layout-container #}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
{#
|
||||
/**
|
||||
* @file
|
||||
* Theme override to display a menu.
|
||||
*
|
||||
* Available variables:
|
||||
* - menu_name: The machine name of the menu.
|
||||
* - items: A nested list of menu items. Each menu item contains:
|
||||
* - attributes: HTML attributes for the menu item.
|
||||
* - below: The menu item child items.
|
||||
* - title: The menu link title.
|
||||
* - url: The menu link url, instance of \Drupal\Core\Url
|
||||
* - localized_options: Menu link localized options.
|
||||
* - is_expanded: TRUE if the link has visible children within the current
|
||||
* menu tree.
|
||||
* - is_collapsed: TRUE if the link has children within the current menu tree
|
||||
* that are not currently visible.
|
||||
* - in_active_trail: TRUE if the link is in the active trail.
|
||||
*/
|
||||
#}
|
||||
{% import _self as menus %}
|
||||
|
||||
{#
|
||||
We call a macro which calls itself to render the full tree.
|
||||
@see https://twig.symfony.com/doc/1.x/tags/macro.html
|
||||
#}
|
||||
{{ menus.menu_links(items, attributes, 0) }}
|
||||
|
||||
{% macro menu_links(items, attributes, menu_level) %}
|
||||
{% import _self as menus %}
|
||||
|
||||
{% if items %}
|
||||
<div class="w-full md:block" :class="[ isOpen ? 'block' : 'hidden' ]">
|
||||
{% if menu_level == 0 %}
|
||||
<ul{{ attributes.addClass('
|
||||
w-full h-full mt-2px py-4 bg-blue-700
|
||||
md:mt-0 md:mx-0 md:relative md:flex md:flex-wrap md:flex-1 md:justify-end
|
||||
md:bg-blue-500 md:border-b-0
|
||||
') }}>
|
||||
{% else %}
|
||||
<ul>
|
||||
{% endif %}
|
||||
{% for item in items %}
|
||||
<li{{ item.attributes.addClass('flex flex-1 justify-center') }}>
|
||||
{% set linkClasses = ['w-full flex items-center mx-4 mt-1 -mb-px py-3 px-4 block rounded text-sm text-white no-underline hover:underline focus:outline-none focus:underline md:py-1 md:px-2 md:mx-2 md:mt-0 md:mr-0'] %}
|
||||
{% if item.in_active_trail %}
|
||||
{% set linkClasses = linkClasses|merge(['cursor-default bg-blue-500 hover:border-blue-600 hover:no-underline md:bg-blue-700']) %}
|
||||
{% endif %}
|
||||
{{ link(item.title, item.url, { class: linkClasses|join(' ') }) }}
|
||||
{% if item.below %}
|
||||
{{ menus.menu_links(item.below, attributes, menu_level + 1) }}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endmacro %}
|
Loading…
Reference in a new issue