From 920c8b3e51cc3e0f29a4ad9797648cc9c143430c Mon Sep 17 00:00:00 2001 From: Sven <38101365+svenvoskamp@users.noreply.github.com> Date: Thu, 7 Sep 2023 09:17:22 +0200 Subject: [PATCH] V 3/tabs feedback (#1315) --- packages/ui/src/composites/wui-tabs/index.ts | 36 ++++++++++--------- packages/ui/src/composites/wui-tabs/styles.ts | 9 ++--- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/packages/ui/src/composites/wui-tabs/index.ts b/packages/ui/src/composites/wui-tabs/index.ts index 572c0f6012..dbf2b89266 100644 --- a/packages/ui/src/composites/wui-tabs/index.ts +++ b/packages/ui/src/composites/wui-tabs/index.ts @@ -73,27 +73,29 @@ export class WuiTabs extends LitElement { const activeBtnBounds = activeBtn?.getBoundingClientRect() const activeBtnTextBounds = activeBtnText?.getBoundingClientRect() - if (passiveBtn && passiveBtnText && !initialAnimation) { + if (passiveBtn && passiveBtnText && !initialAnimation && index !== this.activeTab) { animate(passiveBtnText, { opacity: 0 }, { duration: 0.25 }) - animate(passiveBtn, { width: `20px` }, { duration: 0.25, delay: 0.05 }) + animate(passiveBtn, { width: '34px' }, { duration: 0.5 }) } if (activeBtn && activeBtnBounds && activeBtnTextBounds && activeBtnText) { - this.localTabWidth = `${Math.round( - activeBtnBounds.width + activeBtnTextBounds.width + 6 + 12 - )}px` - - animate( - activeBtn, - { width: `${activeBtnBounds.width + activeBtnTextBounds.width + 6}px` }, - { duration: initialAnimation ? 0 : 0.5, delay: initialAnimation ? 0 : 0.1 } - ) - - animate( - activeBtnText, - { opacity: 1 }, - { duration: initialAnimation ? 0 : 0.25, delay: initialAnimation ? 0 : 0.15 } - ) + if (index !== this.activeTab || initialAnimation) { + this.localTabWidth = `${ + Math.round(activeBtnBounds.width + activeBtnTextBounds.width) + 6 + }px` + + animate( + activeBtn, + { width: `${activeBtnBounds.width + activeBtnTextBounds.width}px` }, + { duration: initialAnimation ? 0 : 0.5 } + ) + + animate( + activeBtnText, + { opacity: 1 }, + { duration: initialAnimation ? 0 : 0.25, delay: initialAnimation ? 0 : 0.05 } + ) + } } } } diff --git a/packages/ui/src/composites/wui-tabs/styles.ts b/packages/ui/src/composites/wui-tabs/styles.ts index 7a243ef803..3267e929b0 100644 --- a/packages/ui/src/composites/wui-tabs/styles.ts +++ b/packages/ui/src/composites/wui-tabs/styles.ts @@ -28,13 +28,14 @@ export default css` } :host([data-type='flex'])::before { - transform: translateX(calc(var(--local-tab) * var(--local-tab-width) / 1.85)); + left: 3px; + transform: translateX(calc((var(--local-tab) * 34px) + (var(--local-tab) * 4px))); } :host([data-type='flex']) { display: flex; - padding: 0px 12px; - gap: 28px; + padding: 0px 0px 0px 12px; + gap: 4px; } :host([data-type='flex']) > button > wui-text { @@ -64,7 +65,7 @@ export default css` } :host([data-type='flex']) > button { - width: 20px; + width: 34px; position: relative; display: flex; justify-content: flex-start;