From edb09e68bbfae2f08de6694d1c606089ac55c6e4 Mon Sep 17 00:00:00 2001 From: mbecle Date: Mon, 29 Apr 2024 16:49:14 +0200 Subject: [PATCH] feat: breadcrumb group --- components/Molecules/Breadcrumb/Breadcrumb.js | 16 ++++++ .../Breadcrumb/Breadcrumb.stories.js | 30 ++++++++--- .../Molecules/Breadcrumb/Breadcrumb.twig | 43 ++++++++++----- .../Molecules/Breadcrumb/breadcrumb.css | 54 +++++++++++++------ 4 files changed, 105 insertions(+), 38 deletions(-) create mode 100644 components/Molecules/Breadcrumb/Breadcrumb.js diff --git a/components/Molecules/Breadcrumb/Breadcrumb.js b/components/Molecules/Breadcrumb/Breadcrumb.js new file mode 100644 index 0000000..5433b34 --- /dev/null +++ b/components/Molecules/Breadcrumb/Breadcrumb.js @@ -0,0 +1,16 @@ +const breadcrumbFunction = () => { + const btnCompressed = document.querySelector('.Breadcrumb-compressed'); + const liCompressed = document.getElementById('Breadcrumb-compressed'); + const items = document.querySelectorAll(".Breadcrumb-item"); + + if (btnCompressed) { + btnCompressed.addEventListener('click', function () { + items.forEach(function (item) { + item.classList.remove("hide") + }); + liCompressed.classList.add("hide") + }) + }; +} + +export default breadcrumbFunction; diff --git a/components/Molecules/Breadcrumb/Breadcrumb.stories.js b/components/Molecules/Breadcrumb/Breadcrumb.stories.js index 8f95d9e..e190360 100644 --- a/components/Molecules/Breadcrumb/Breadcrumb.stories.js +++ b/components/Molecules/Breadcrumb/Breadcrumb.stories.js @@ -1,4 +1,5 @@ import Breadcrumb from './Breadcrumb.twig'; +import breadcrumbFunction from './Breadcrumb.js'; export default { title: 'Design System/Molecules/Breadcrumb' @@ -7,12 +8,27 @@ export default { export const Base = { render: (args) => Breadcrumb(args), args: { - customText: 'Homepage', - href: '' - }, - argTypes: { - compressed: { - control: { type: 'boolean' } - } + items: [ + { label: 'Page parante', href: '#' }, + { label: 'Page mère', href: '#' }, + { label: 'Page actuelle' } + ] + } +}; + +export const Lengthy = { + render: (args) => Breadcrumb(args), + play: () => { + breadcrumbFunction() }, + args: { + items: [ + { label: 'Non visible', href: '#' }, + { label: 'Non visible', href: '#' }, + { label: 'Page parante', href: '#' }, + { label: 'Page mère', href: '#' }, + { label: 'Page actuelle' } + ] + + } }; diff --git a/components/Molecules/Breadcrumb/Breadcrumb.twig b/components/Molecules/Breadcrumb/Breadcrumb.twig index 683cc45..2f9146e 100644 --- a/components/Molecules/Breadcrumb/Breadcrumb.twig +++ b/components/Molecules/Breadcrumb/Breadcrumb.twig @@ -1,14 +1,29 @@ -{% set classes = '' %} -{% if compressed %} - {% set classes = classes ~ ' Breadcrumb--compressed' %} -{% endif %} - -{% if href %} - - {{ compressed ? '...' : customText }} - -{% else %} - - {{ compressed ? '...' : customText }} - -{% endif %} + + + + + diff --git a/components/Molecules/Breadcrumb/breadcrumb.css b/components/Molecules/Breadcrumb/breadcrumb.css index d9e391a..810c845 100644 --- a/components/Molecules/Breadcrumb/breadcrumb.css +++ b/components/Molecules/Breadcrumb/breadcrumb.css @@ -1,32 +1,48 @@ .Breadcrumb { - color: var(--grey); - font-size: var(--font-size-paragraph-4); - line-height: var(--line-height-paragraph-4); - font-family: var(--font-family-paragraph-4); - text-decoration: none; - outline: none; - - &:active, - a&:hover { - color: var(--black); - text-decoration: underline; + &-list { + display: flex; + flex-wrap: wrap; + gap: 8px; + align-items: center; } - &:active&:hover { - color: var(--grey-dark); - } + &-item { + color: var(--black); + font-size: var(--font-size-paragraph-4); + line-height: var(--line-height-paragraph-4); + font-family: var(--font-family-paragraph-4); + display: flex; + gap: 8px; + + &--isLink { + &::after { + content: '/'; + font-size: rem-convert(10px); + } + } - &:focus { - background-color: var(--theme-light); + &-link { + outline: none; + + a&:hover { + color: var(--grey); + } + + &:focus { + background-color: var(--theme-light); + } + } } - &--compressed { + &-compressed { background-color: var(--grey-lightest); width: rem-convert(16px); height: rem-convert(16px); display: inline-flex; justify-content: center; line-height: rem-convert(8px); + text-decoration: none; + margin-top: 2px; &:focus { background-color: var(--grey-lightest); @@ -37,4 +53,8 @@ background-color: var(--theme-lightest); } } + + .hide { + display: none; + } }