Skip to content
Snippets Groups Projects
Verified Commit bc4b7872 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3404302 by finnsky, smustgrave, lauriii, markconroy: Create header...

Issue #3404302 by finnsky, smustgrave, lauriii, markconroy: Create header component for Umami, with JS
parent ff392533
No related branches found
No related tags found
35 merge requests!12227Issue #3181946 by jonmcl, mglaman,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!9470[10.3.x-only-DO-NOT-MERGE]: #3331771 Fix file_get_contents(): Passing null to parameter,!8540Issue #3457061: Bootstrap Modal dialog Not closing after 10.3.0 Update,!8528Issue #3456871 by Tim Bozeman: Support NULL services,!8373Issue #3427374 by danflanagan8, Vighneshh: taxonomy_tid ViewsArgumentDefault...,!7526Expose roles in response,!7352Draft: Resolve #3203489 "Set filename as",!6880Add @property to the DateTimeItem,!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3742Issue #3328429: Create item list field formatter for displaying ordered and unordered lists,!3731Claro: role=button on status report items,!3668Resolve #3347842 "Deprecate the trusted",!3651Issue #3347736: Create new SDC component for Olivero (header-search),!3531Issue #3336994: StringFormatter always displays links to entity even if the user in context does not have access,!3478Issue #3337882: Deleted menus are not removed from content type config,!3355Issue #3209129: Scrolling problems when adding a block via layout builder,!3154Fixes #2987987 - CSRF token validation broken on routes with optional parameters.,!3133core/modules/system/css/components/hidden.module.css,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2812Issue #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL,!2794Issue #3100732: Allow specifying `meta` data on JSON:API objects,!2378Issue #2875033: Optimize joins and table selection in SQL entity query implementation,!2334Issue #3228209: Add hasRole() method to AccountInterface,!2062Issue #3246454: Add weekly granularity to views date sort,!1105Issue #3025039: New non translatable field on translatable content throws error,!1073issue #3191727: Focus states on mobile second level navigation items fixed,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!877Issue #2708101: Default value for link text is not saved,!579Issue #2230909: Simple decimals fail to pass validation,!560Move callback classRemove outside of the loop,!555Issue #3202493,!213Issue #2906496: Give Media a menu item under Content
Pipeline #107395 passed with warnings
Pipeline: drupal

#107399

    Showing
    with 195 additions and 161 deletions
    # This is so your IDE knows about the syntax for fixes and autocomplete.
    $schema: https://git.drupalcode.org/project/drupal/-/raw/10.1.x/core/modules/sdc/src/metadata.schema.json
    # The human readable name.
    name: Umami header
    # Status can be: "experimental", "stable", "deprecated", "obsolete".
    status: experimental
    # Schema for the props. We support www.json-schema.org. Learn more about the
    # syntax there.
    props:
    # Props are always an object with keys. Each key is a variable in your
    # component template.
    type: object
    properties:
    attributes:
    type: Drupal\Core\Template\Attribute
    title: Attributes
    description: Wrapper attributes.
    label:
    type: string
    # Slots always hold arbitrary markup. We know that beforehand, so no need for
    # a schema for slots.
    slots:
    # The key is the name of the slot. In your template you will use
    # {% block content %}.
    logo:
    title: Logo
    dropdown:
    title: Dropdown
    # This is how you take control of the keys in your library
    # declaration. The overrides specified here will be merged (shallow merge) with
    # the auto-generated library. The result of the merge will become the library
    # for the component.
    libraryOverrides:
    # Once you add a key in the overrides, you take control of it. What you type
    # here is what will end up in the library component.
    dependencies:
    - core/drupal
    - core/once
    .umami-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 4%;
    }
    /* Medium */
    @media screen and (min-width: 48rem) { /* 768px */
    .umami-header {
    padding-top: 0;
    }
    }
    /* Extra large + side margins */
    @media screen and (min-width: 80rem) { /* 1200px (large) + 80px (side margins) = 1280px */
    .umami-header {
    padding: 0;
    }
    }
    .umami-header__burger {
    width: 41px;
    height: 41px;
    margin-right: -9px;
    /* the padding, margin & transparent border means the hamburger doesn't move on focus/hover */
    padding: 0 6px;
    text-align: left;
    border: 3px solid transparent;
    border-radius: 0;
    background-color: transparent;
    line-height: 1;
    }
    .umami-header__burger:hover {
    background-color: transparent;
    }
    .umami-header__burger svg {
    display: block;
    }
    @media screen and (min-width: 48em) {
    .umami-header__burger {
    display: none;
    }
    }
    .umami-header__dropdown {
    overflow: hidden;
    flex-basis: 100%;
    max-height: 0;
    transition: max-height 0.5s ease-in;
    }
    @media screen and (min-width: 48em) {
    .umami-header__dropdown {
    overflow: auto;
    flex-basis: auto;
    max-height: none;
    }
    }
    .umami-header__burger[aria-expanded="true"] ~ .umami-header__dropdown {
    overflow-y: auto;
    /**
    * An exact max-height value must be set to make possible to animate the menu display.
    * It my not be much larger than the content because that would break the animation.
    * See: https://css-tricks.com/using-css-transitions-auto-dimensions/
    */
    max-height: 18.75rem;
    }
    .umami-header__logo {
    flex: 0 1 40%;
    }
    @media screen and (min-width: 48em) {
    .umami-header__logo {
    flex: 0 1 220px;
    margin: 2.5rem 0;
    }
    }
    ((Drupal, once) => {
    Drupal.behaviors.umamiHeader = {
    attach(context) {
    once(
    'umami-header',
    '[aria-controls="umami-header__dropdown"]',
    context,
    ).forEach((button) => {
    button.addEventListener('click', (e) => {
    button.setAttribute(
    'aria-expanded',
    e.currentTarget.getAttribute('aria-expanded') === 'false',
    );
    });
    });
    },
    };
    })(Drupal, once);
    <div{{ attributes.addClass('umami-header') }}>
    <div class="umami-header__logo">
    {% block logo %}{% endblock %}
    </div>
    <button
    type="button"
    class="umami-header__burger"
    aria-controls="umami-header__dropdown"
    aria-expanded="false"
    aria-label="{{ 'Toggle the menu'|t }}"
    >
    {{ source(componentMetadata.path ~ '/icons/burger.svg') }}
    </button>
    <div class="umami-header__dropdown">
    {% block dropdown %}{% endblock %}
    </div>
    </div>
    </div>
    ......@@ -4,45 +4,15 @@
    */
    .menu-main {
    overflow: hidden;
    max-height: 0;
    margin: 0;
    padding: 0;
    list-style-type: none;
    transition: max-height 0.5s ease-in;
    color: #000;
    font-family: "Scope One", Georgia, serif;
    font-size: 1.266rem;
    font-weight: 400;
    line-height: 1.2;
    }
    .menu-main--active {
    overflow-y: auto;
    /**
    * An exact max-height value must be set to make possible to animate the menu display.
    * It my not be much larger than the content because that would break the animation.
    * See: https://css-tricks.com/using-css-transitions-auto-dimensions/
    */
    max-height: 18.75rem;
    }
    .menu-main-toggle {
    width: 41px;
    height: 41px;
    margin-right: -9px;
    /* the padding, margin & transparent border means the hamburger doesn't move on focus/hover */
    padding: 0 6px;
    text-align: left;
    border: 3px solid transparent;
    border-radius: 0;
    background-color: transparent;
    line-height: 1;
    }
    .menu-main-toggle:hover {
    background-color: transparent;
    }
    .menu-main-toggle svg {
    display: block;
    }
    .menu-main__item {
    margin-top: 0.8em;
    text-align: center;
    ......@@ -75,13 +45,8 @@
    @media screen and (min-width: 48em) {
    .menu-main {
    display: flex;
    overflow: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-height: none;
    }
    .menu-main-toggle {
    display: none;
    }
    .menu-main__item {
    margin-top: 0;
    ......@@ -96,12 +61,6 @@
    }
    }
    @media screen and (min-width: 48em) {
    .menu-main-togglewrap {
    display: none;
    }
    }
    .menu-main__wrapper {
    flex: 0 1 100%;
    text-align: center;
    ......
    ......@@ -10,40 +10,3 @@
    padding: 0;
    background: #fff;
    }
    .region-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 4%;
    }
    @media screen and (min-width: 48em) {
    .region-header {
    padding-top: 0;
    }
    }
    /* Medium */
    @media screen and (min-width: 48rem) { /* 768px */
    .region-header {
    padding-top: 0;
    }
    }
    /* Extra large + side margins */
    @media screen and (min-width: 80rem) { /* 1200px (large) + 80px (side margins) = 1280px */
    .region-header {
    padding: 0;
    }
    }
    .region-header .block-system-branding-block {
    flex: 0 1 40%;
    }
    @media screen and (min-width: 48em) {
    .region-header .block-system-branding-block {
    flex: 0 1 220px;
    margin: 2.5rem 0;
    }
    }
    /**
    * @file
    * This file is used to add any javascript that is needed for the main menu.
    */
    (function () {
    const toggler = document.querySelector(
    '[data-drupal-selector="menu-main-toggle"]',
    );
    const menu = document.querySelector('[data-drupal-selector="menu-main"]');
    function toggleMenu() {
    toggler.classList.toggle('menu-main-toggle--active');
    menu.classList.toggle('menu-main--active');
    return false;
    }
    toggler.addEventListener('click', toggleMenu);
    })();
    {#
    /**
    * @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.
    * - in_preview: Whether the plugin is being rendered in preview mode.
    * - 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 classes = [
    'block',
    'block-menu',
    'navigation',
    'menu-' ~ derivative_plugin_id|clean_class ~ '__wrapper',
    ]
    %}
    <div class="menu-main-togglewrap">
    <button type="button" name="menu_toggle" class="menu-main-toggle" data-drupal-selector="menu-main-toggle" aria-label="Toggle the menu">{% include active_theme_path() ~ '/images/svg/menu-icon.svg' %}</button>
    </div>
    {% set heading_id = attributes.id ~ '-menu'|clean_id %}
    <nav role="navigation" aria-labelledby="{{ heading_id }}"{{ attributes.addClass(classes)|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>
    {#
    /**
    * @file
    * Theme override to display a region.
    *
    * Available variables:
    * - content: The content for this region, typically blocks.
    * - attributes: HTML attributes for the region <div>.
    * - region: The name of the region variable as defined in the theme's
    * .info.yml file.
    *
    * @see template_preprocess_region()
    */
    #}
    {%
    set classes = [
    'region',
    'region-' ~ region|clean_class,
    ]
    %}
    {% embed "umami:header" with {
    attributes,
    } %}
    {% block logo %}
    {{ elements.umami_branding }}
    {% endblock %}
    {% block dropdown %}
    {{ elements.umami_main_menu }}
    {% endblock %}
    {% endembed %}
    ......@@ -46,8 +46,6 @@ global:
    css/layout/grid-3.css: {}
    css/layout/grid-4.css: {}
    css/layout/layout.css: {}
    js:
    js/components/navigation/menu-main/menu-main.js: {}
    messages:
    css:
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment