diff --git a/src/patterns/04-components/tabs/_tabs.scss b/src/patterns/04-components/tabs/_tabs.scss new file mode 100644 index 0000000000000000000000000000000000000000..ae13a39a9813f95d0c923caa8b5f95f0a6154841 --- /dev/null +++ b/src/patterns/04-components/tabs/_tabs.scss @@ -0,0 +1,115 @@ +// @file +// Styles for UW Tabs. +@use '../../../01-core' as *; + +.uw-tabs { + margin: var(--size-1) auto; + + &.catalog { + + @include medium { + padding: 0; + } + } + + width: 100%; + + .hide-js{ + display: none; + + html:not(.js) & { + border-bottom: 2px solid $button-background-color-hover; + display: block; + margin-bottom: var(--size-1); + padding-bottom: var(--size-1); + } + } +} + +//buttons wrapper +.uw-tab { + @include flexbox(); + + @supports (scrollbar-width: none) { + scrollbar-width: none; + } + + overflow-y: scroll; + + @include medium { + overflow-y: initial; + } + + html:not(.js) & { + display:none; + } + + a { + white-space: nowrap; + } +} + +.uw-tab::-webkit-scrollbar { + display: none; +} + +// button +.uw-tablinks { + border-bottom: 0.4rem solid #fff; + font-weight: inherit; + margin: 0 0 0 0.15rem; + max-width: inherit; + padding: 1rem 2rem; + + @include medium { + border-bottom: 0.4rem solid var(--uw-white); + font-weight: inherit; + margin: 0 0 0 0.15rem; + max-width: inherit; + padding: 1rem 2rem; + } + + &[aria-selected="true"] { + background: $button-background-color-hover; + border-bottom: 0.4rem solid $button-text-color-hover; + color: $button-text-color-hover; + + &:hover{ + border-bottom: 0.4rem solid #ddd; + } + } + + &:hover{ + border-bottom: 0.4rem solid var(--uw-white); + } +} + +.uw-tabcontent[role="tabpanel"] { + @include uw-flex-grid(); + padding-top: var(--size-2); + + &[hidden] { + display: none; + } +} + +html:not(.js) .uw-tabcontent[role="tabpanel"][hidden]{ + @include flexbox(); +} + +.uw-tabcontent[role="tabpanel"] .card{ + @include uw-flex-grid-item(); +} + + +.block-local-tasks-block{ + nav nav ul li a { + font-family: var(--font-systemmedium); + } +} + +.uw-tablinks { + &.active { + border-bottom: 0.4rem solid #4e4e4e; + } +} diff --git a/src/patterns/04-components/tabs/_tabs.twig b/src/patterns/04-components/tabs/_tabs.twig new file mode 100644 index 0000000000000000000000000000000000000000..10a09fa3cd5340ec26790d370565fe374712e38b --- /dev/null +++ b/src/patterns/04-components/tabs/_tabs.twig @@ -0,0 +1,51 @@ +<div class="uw-tabs{% if tabs_modifier_class %} {{ tabs_modifier_class }}{% endif %}"> + + <div class="uw-tab" role="tablist" aria-label="Multi-tab-list"> + {% for type in content_list %} + {% if tab_type == "link" %} + <a href="{{ type.url }}" class="uw-tablinks {{ button_modifier_classes }}{% if type.active %} active{% endif %}">{{ type.text }}</a> + {% elseif tab_type == "button" %} + {% set button_class -%} + uw-tablinks {{ button_modifier_classes }}{% if type.button_class %} {{ type.button_class }}{% endif %} + {%- endset %} + <button class="{{ button_class }}"{% if uuid %} data-uuid="{{ uuid }}"{% endif %}>{{ type.text }}</button> + {% else %} + {% set button_class -%} + uw-tablinks {{ button_modifier_classes }}{% if type.button_class %} {{ type.button_class }}{% endif %} + {%- endset %} + <button role="tab" class="{{ button_class }}" {% if loop.index == 1 %} aria-selected="true" {% else %} aria-selected="false" {% endif %} aria-controls="{{ type }}" id="tab-{{ loop.index }}" tabindex="0" data-uuid="{{ rand }}">{{ type }}</button> + {% endif %} + {% endfor %} + </div> + + {% if tab_type == "content" %} + {% for type in content_list %} + <h2 class="hide-js"> {{ type }}</h2> + <div id="{{ type }}" class="uw-tabcontent" role="tabpanel" tabindex="0" aria-labelledby="tab-{{ loop.index }}" {% if loop.index > 1 %} hidden {% endif %} > + + {% if loop.index == 1 %} + {% block content_area_1 %} + Content area 1 + {% endblock %} + {% elseif loop.index == 2 %} + {% block content_area_2 %} + Content area 2 + {% endblock %} + {% elseif loop.index == 3 %} + {% block content_area_3 %} + Content area 3 + {% endblock %} + {% elseif loop.index == 4 %} + {% block content_area_4 %} + Content area 4 + {% endblock %} + {% elseif loop.index == 5 %} + {% block content_area_5 %} + Content area 5 + {% endblock %} + {% endif %} + + </div> + {% endfor %} + {% endif %} +</div> diff --git a/src/patterns/04-components/tabs/tabs--buttons/tabs--buttons.twig b/src/patterns/04-components/tabs/tabs--buttons/tabs--buttons.twig new file mode 100644 index 0000000000000000000000000000000000000000..dde1833fe5c554a086178c0dd5d24857ca124e3c --- /dev/null +++ b/src/patterns/04-components/tabs/tabs--buttons/tabs--buttons.twig @@ -0,0 +1,8 @@ +{% include "@components/tabs/_tabs.twig" with { + tab_type: 'button', + content_list: content_list, + button_modifier_classes: button_modifier_classes, + tabs_modifier_class: tabs_modifier_class, + exp_col_all: exp_col_all, + uuid: uuid, +} %} diff --git a/src/patterns/04-components/tabs/tabs--buttons/tabs--buttons.yml b/src/patterns/04-components/tabs/tabs--buttons/tabs--buttons.yml new file mode 100644 index 0000000000000000000000000000000000000000..3a8ee0f42caf4cf39109bfccc48631492a9e9845 --- /dev/null +++ b/src/patterns/04-components/tabs/tabs--buttons/tabs--buttons.yml @@ -0,0 +1,11 @@ +--- +modifier_classes: '' +content_list: + - + text: 'Button1' + - + text: 'Button2' + - + text: 'Button3' + - + text: 'Button4' diff --git a/src/patterns/04-components/tabs/tabs--content/tabs--content.twig b/src/patterns/04-components/tabs/tabs--content/tabs--content.twig new file mode 100644 index 0000000000000000000000000000000000000000..070e6207c654028378c2bccdae05ecccd4ec5d9a --- /dev/null +++ b/src/patterns/04-components/tabs/tabs--content/tabs--content.twig @@ -0,0 +1,9 @@ +{% set button_modifier_classes -%} + button button--large {{ modifier_classes }} +{%- endset %} + +{% include "@components/tabs/_tabs.twig" with { + tab_type: 'content', + content_list: content_list, + button_modifier_classes: button_modifier_classes, +} %} \ No newline at end of file diff --git a/src/patterns/04-components/tabs/tabs--content/tabs--content.yml b/src/patterns/04-components/tabs/tabs--content/tabs--content.yml new file mode 100644 index 0000000000000000000000000000000000000000..f69e8f1a1bb78dec0610705677040dfa4070ce3e --- /dev/null +++ b/src/patterns/04-components/tabs/tabs--content/tabs--content.yml @@ -0,0 +1,6 @@ +--- +modifier_classes: '' +content_list: + - Tab1 + - Tab2 + - Tab3 diff --git a/src/patterns/04-components/tabs/tabs--exp-col-all/tabs--exp-col-all.twig b/src/patterns/04-components/tabs/tabs--exp-col-all/tabs--exp-col-all.twig new file mode 100644 index 0000000000000000000000000000000000000000..bb17765f217e39339c73823aa67a723fdfbecdd4 --- /dev/null +++ b/src/patterns/04-components/tabs/tabs--exp-col-all/tabs--exp-col-all.twig @@ -0,0 +1,17 @@ +{% set content_list = { + '0': { + 'text': 'Expand all', + 'button_class': 'uw-exp-col-expand-all', + }, + '1': { + 'text': 'Collapse all', + 'button_class': 'uw-exp-col-collapse-all', + } +} %} + +{% include '@components/tabs/tabs--buttons/tabs--buttons.twig' with { + content_list: content_list, + tabs_modifier_class: 'uw-exp-col', + button_modifier_classes: 'uw-exp-col-button', + uuid: uuid, +} %} \ No newline at end of file diff --git a/src/patterns/04-components/tabs/tabs--link/tabs--link.twig b/src/patterns/04-components/tabs/tabs--link/tabs--link.twig new file mode 100644 index 0000000000000000000000000000000000000000..c558818f5dde7983e10e728eafcbec17d4545667 --- /dev/null +++ b/src/patterns/04-components/tabs/tabs--link/tabs--link.twig @@ -0,0 +1,10 @@ +{% set button_modifier_classes -%} + button button--large {{ modifier_classes }} +{%- endset %} + +{% include "@components/tabs/_tabs.twig" with { + tab_type: 'link', + content_list: content_list, + button_modifier_classes: button_modifier_classes, + tabs_modifier_class: tabs_modifier_class, +} %} diff --git a/src/patterns/04-components/tabs/tabs--link/tabs--link.yml b/src/patterns/04-components/tabs/tabs--link/tabs--link.yml new file mode 100644 index 0000000000000000000000000000000000000000..cf8331556d0c4e8be8eb8c80341977087af77135 --- /dev/null +++ b/src/patterns/04-components/tabs/tabs--link/tabs--link.yml @@ -0,0 +1,16 @@ +--- +modifier_classes: '' +content_list: + - + url: 'https://google.ca' + text: 'Link1' + - + url: 'https://google.ca' + text: 'Link2' + active: 1 + - + url: 'https://google.ca' + text: 'Link3' + - + url: 'https://google.ca' + text: 'Link4' diff --git a/src/patterns/04-components/tabs/tabs.js b/src/patterns/04-components/tabs/tabs.js new file mode 100644 index 0000000000000000000000000000000000000000..8b9fc0dd054892dd0eeb28a2f50d4f7d0d8d689b --- /dev/null +++ b/src/patterns/04-components/tabs/tabs.js @@ -0,0 +1,28 @@ +/** + * @file + */ + +(function ($, Drupal) { + 'use strict'; + Drupal.behaviors.tabs = { + attach: function () { + $(document).ready(function () { + + $('.uw-contact-expand-all').click(function () { + $('.uw-contact details').each(function () { + console.log($(this)); + $(this).attr('open', ''); + }); + }); + + $('.uw-contact-collapse-all').click(function () { + $('.uw-contact details').each(function () { + console.log($(this)); + $(this).removeAttr('open'); + }); + }); + + }); + } + }; +})(jQuery, Drupal); diff --git a/src/patterns/04-components/tabs/tabs.md b/src/patterns/04-components/tabs/tabs.md new file mode 100644 index 0000000000000000000000000000000000000000..028f42dba1184033bc3819ebc95d2b7b05deb309 --- /dev/null +++ b/src/patterns/04-components/tabs/tabs.md @@ -0,0 +1,12 @@ +--- +el: .tabs +title: Tabs +--- + +__Variables:__ +* modifier_classes: [string] Classes to modify the default component styling. +* heading: [string] Accessible heading of the tabs. +* tabs: [array] Tab items. Each item is an object containing: + * active: [boolean] Whether the item is active. + * url: [string] URL of the item. + * text: [string] Text of the item. diff --git a/src/patterns/04-components/tabs/tabs.yml b/src/patterns/04-components/tabs/tabs.yml new file mode 100644 index 0000000000000000000000000000000000000000..afb30a6322271f15ceaf693ff8032ddbda24431f --- /dev/null +++ b/src/patterns/04-components/tabs/tabs.yml @@ -0,0 +1,10 @@ +--- +modifier_classes: '' +is_demo: true +lists: + Tab-1: + - + Tab-2: + - + Tab-3: + -