diff --git a/public/assets/components/breadcrumb.css b/public/assets/components/breadcrumb.css index 26c9fbe2..41c35f10 100644 --- a/public/assets/components/breadcrumb.css +++ b/public/assets/components/breadcrumb.css @@ -5,36 +5,27 @@ .component_breadcrumb .breadcrumb { margin: 0 0 0px 0; z-index: 1000; - padding: 3px 0 3px 10px; } .component_breadcrumb .breadcrumb .ul { + display: flex; list-style-type: none; margin: 0; width: 100%; - padding: 0 10px 0 10px; box-sizing: border-box; } .component_breadcrumb .breadcrumb .ul > span { display: block; + flex-grow: 1; padding: 7px 0; } .component_breadcrumb .breadcrumb .ul div, .component_breadcrumb .breadcrumb .ul .li { display: inline-block; } .component_breadcrumb .component_logout { - float: right; - display: inline-block; - margin: 0 0px 0 5px; - line-height: 25px; - padding: 7px 0; -} -.component_breadcrumb .component_logout a { - display: block; - vertical-align: middle; + align-self: center; } .component_breadcrumb .component_logout .component_icon { height: 20px; - vertical-align: middle; } .component_breadcrumb .component_saving { padding-left: 1px; @@ -46,6 +37,7 @@ color: rgba(0, 0, 0, 0.75); padding: 4px 5px; } +.component_breadcrumb .component_path-element .label span { display: inline-block; } .component_breadcrumb .component_path-element a.label { position: relative; color: rgba(0, 0, 0, 0.5); @@ -79,6 +71,28 @@ .component_breadcrumb .component_separator img { vertical-align: middle; } + +/* Phone like devices */ +body.touch-yes [is="component-breadcrumb"] .ul span { + overflow-x: auto; + overflow-y: hidden; + -webkit-overflow-scrolling: touch; + box-sizing: border-box; + -moz-box-sizing: border-box; + white-space: nowrap; +} +body.touch-yes [is="component-breadcrumb"] .ul span::-webkit-scrollbar { + height: 0px; +} +body.touch-yes [is="component-breadcrumb"] .ul span::-webkit-scrollbar-track { + background: var(--super-light); +} +body.touch-yes [is="component-breadcrumb"] .ul span::-webkit-scrollbar-thumb { + background: #d2d2d2; + border-radius: 1px; +} + +/* Dark Mode */ .dark-mode .component_breadcrumb .component_separator img { filter: brightness(0.5) invert(1); } @@ -91,41 +105,18 @@ body.touch-no .component_path-element-wrapper a.label:hover span.title { transform: translateY(0px); transition: all 0.15s ease-out; } - body.dark-mode.touch-no .component_path-element-wrapper a.label:hover { background: rgba(255, 255, 255, 0.05); } - -body.touch-yes ul span { - overflow-x: auto; - overflow-y: hidden; - -webkit-overflow-scrolling: touch; - box-sizing: border-box; - -moz-box-sizing: border-box; - white-space: nowrap; +.dark-mode .component_breadcrumb .component_path-element .label { + color: #f1f1f1; + opacity: 0.7; } -body.touch-yes ul span::-webkit-scrollbar { - height: 0px; -} -body.touch-yes ul span::-webkit-scrollbar-track { - background: var(--super-light); -} -body.touch-yes ul span::-webkit-scrollbar-thumb { - background: #d2d2d2; - border-radius: 1px; +.dark-mode .component_breadcrumb .component_path-element a.label { + opacity: 1; } /* ANIMATION */ -.component_breadcrumb .breadcrumb-leave { - display: inline-block; - opacity: 1; - transform: translateY(0px); -} -.component_breadcrumb .breadcrumb-leave.breadcrumb-leave-active { - opacity: 0; - transform: translateY(-10px); - transition: all 0.15s ease-out; -} .component_breadcrumb .breadcrumb-enter { transform: translateX(10px); opacity: 0; @@ -159,11 +150,3 @@ body.touch-yes ul span::-webkit-scrollbar-thumb { transform: scale(1); } } - -.dark-mode .component_breadcrumb .component_path-element .label { - color: #f1f1f1; - opacity: 0.7; -} -.dark-mode .component_breadcrumb .component_path-element a.label { - opacity: 1; -} diff --git a/public/assets/components/breadcrumb.js b/public/assets/components/breadcrumb.js index 168d3380..5543c950 100644 --- a/public/assets/components/breadcrumb.js +++ b/public/assets/components/breadcrumb.js @@ -1,7 +1,5 @@ -import { animate, slideYOut, slideYIn } from "../lib/animate.js"; -import { CSS } from "../helpers/loader.js"; - -const css = await CSS(import.meta.url, "breadcrumb.css"); +import { animate, slideYOut, slideYIn, slideXIn, opacityOut } from "../lib/animate.js"; +import { loadCSS } from "../helpers/loader.js"; class ComponentBreadcrumb extends HTMLDivElement { @@ -11,35 +9,42 @@ class ComponentBreadcrumb extends HTMLDivElement { this.disabled = true; return; } + this.__init(); + } + async __init() { this.innerHTML = `
`; } - attributeChangedCallback(name, previousPath, path) { + attributeChangedCallback(name, oldValue, newValue) { if (this.disabled === true) return; - if (name !== "path") throw new Error("component::breadcrumb.js unknow attribute name: "+ name); - if (path == "") return; - this.render({ path, previous: previousPath || null }) + else if (oldValue === newValue) return; + + switch (name) { + case "path": + if (newValue == "") return; + return this.renderPath({ path: newValue, previous: oldValue || null }); + case "indicator": + return this.renderIndicator() + } + throw new Error("component::breadcrumb.js unknow attribute name: "+ name) } static get observedAttributes() { - return ["path"]; + return ["path", "indicator"]; } - async render({ path = "", previous }) { - path = this._normalised(path); - previous = this._normalised(previous); + async renderPath({ path = "", previous }) { + path = this.__normalised(path); + previous = this.__normalised(previous); let pathChunks = path.split("/"); // STEP1: leaving animation on elements that will be removed @@ -60,15 +65,11 @@ class ComponentBreadcrumb extends HTMLDivElement { this.querySelector(`[data-bind="path"]`).innerHTML = pathChunks.map((chunk, idx) => { const label = idx === 0 ? "Filestash" : chunk; const link = pathChunks.slice(0, idx + 1).join("/") + "/"; - // const minify = (function() { - // if (idx === 0) return false; - // else if (paths.length <= (document.body.clientWidth > 800 ? 5 : 4)) return false; - // else if (idx > paths.length - (document.body.clientWidth > 1000 ? 4 : 3)) return false; - // return true; - // }()); const limitSize = (word, highlight = false) => { - if (highlight === true && word.length > 30) { return word.substring(0, 12).trim() + "..." + - word.substring(word.length - 10, word.length).trim(); } + if (highlight === true && word.length > 30) { + return word.substring(0, 12).trim() + "..." + + word.substring(word.length - 10, word.length).trim(); + } else if (word.length > 27) return word.substring(0, 20).trim() + "..."; return word; }; @@ -77,17 +78,34 @@ class ComponentBreadcrumb extends HTMLDivElement {