diff --git a/src-ts/lib/form/form-groups/form-input/input-select/InputSelect.tsx b/src-ts/lib/form/form-groups/form-input/input-select/InputSelect.tsx index bf4ed58c6..cc4db7122 100644 --- a/src-ts/lib/form/form-groups/form-input/input-select/InputSelect.tsx +++ b/src-ts/lib/form/form-groups/form-input/input-select/InputSelect.tsx @@ -68,7 +68,7 @@ const InputSelect: FC = (props: InputSelectProps) => { hideInlineErrors={props.hideInlineErrors} ref={triggerRef} > -
!props.disabled && toggleMenu}> +
!props.disabled && toggleMenu()}> {selectedOption ? label(selectedOption) : ''} diff --git a/src-ts/lib/styles/mixins/_icons.mixins.scss b/src-ts/lib/styles/mixins/_icons.mixins.scss index bebd7d98d..3711303c6 100644 --- a/src-ts/lib/styles/mixins/_icons.mixins.scss +++ b/src-ts/lib/styles/mixins/_icons.mixins.scss @@ -25,6 +25,10 @@ width: $space-xxl; } +@mixin icon-xxxl { + height: $space-xxxl; + width: $space-xxxl; +} @mixin icon-xxxxl { height: $space-xxxxl; width: $space-xxxxl; diff --git a/src-ts/lib/tabs-navbar/TabsNavbar.module.scss b/src-ts/lib/tabs-navbar/TabsNavbar.module.scss index f47a3eddc..3f15d0eaa 100644 --- a/src-ts/lib/tabs-navbar/TabsNavbar.module.scss +++ b/src-ts/lib/tabs-navbar/TabsNavbar.module.scss @@ -2,15 +2,60 @@ @import '../styles/typography'; .tabs-wrapper { - display: flex; - background: $blue-10; - border-bottom: 1px solid $black-20; + position: relative; margin-bottom: $space-md; + border-bottom: 1px solid $black-20; + background: $blue-10; +} - position: relative; +.menu-trigger { + display: flex; + align-items: center; + padding-right: $space-md; + + .tab-item { + .tab-label { + @include font-weight-bold; + } + } + + svg { + @include icon-xxxl; + margin-left: auto; + color: $turq-160; + transition: 0.15s ease-in-out; + } + + &.menu-is-visible { + svg { + transform: rotate(180deg); + } + } + + @include ltemd { + &:not(.menu-is-visible) { + + .menu-wrapper { + display: none; + } + } + } +} + +.menu-wrapper { + display: flex; + background: $blue-10; @include ltemd { flex-direction: column; + position: absolute; + top: 100%; + left: 0; + width: 100%; + z-index: 1; + + .tab-item { + border-top: 1px solid $black-20; + } } } @@ -22,7 +67,7 @@ padding: $space-md $space-lg calc($space-md - 2px); color: $black-80; cursor: pointer; - + &:global(.active) { color: $black-100; background-color: $blue-25; @@ -32,10 +77,6 @@ } } - &:global(.active) ~ .active-icon > svg path:last-child { - fill: $blue-25; - } - &:hover:not(:global(.active)) { color: $black-100; background-color: $blue-15; @@ -73,8 +114,11 @@ top: 100%; left: 0; transform: translateX(-50%); - + transition: left 0.15s ease-in-out; + > svg path:last-child { + fill: $blue-25; + } @include ltemd { display: none; } diff --git a/src-ts/lib/tabs-navbar/TabsNavbar.tsx b/src-ts/lib/tabs-navbar/TabsNavbar.tsx index e184129b8..cf148862b 100644 --- a/src-ts/lib/tabs-navbar/TabsNavbar.tsx +++ b/src-ts/lib/tabs-navbar/TabsNavbar.tsx @@ -3,14 +3,17 @@ import { Dispatch, FC, MutableRefObject, + ReactNode, SetStateAction, useCallback, useLayoutEffect, + useMemo, useRef, useState, } from 'react' -import { ActiveTabTipIcon } from '../svgs' +import { useClickOutside } from '../hooks' +import { ActiveTabTipIcon, IconOutline } from '../svgs' import { TabsNavItem } from './tabs-nav-item.model' import styles from './TabsNavbar.module.scss' @@ -28,6 +31,12 @@ const TabsNavbar: FC = (props: TabsNavbarProps) => { const tabRefs: MutableRefObject> = useRef([] as Array) const [tabOpened, setTabOpened]: [string | undefined, Dispatch>] = useState(props.defaultActive) const [offset, setOffset]: [number, Dispatch>] = useState(0) + const [menuIsVisible, setMenuIsVisible]: [boolean, Dispatch>] = useState(false) + const triggerRef: MutableRefObject = useRef(undefined) + + const activeTab: TabsNavItem = useMemo(() => ( + props.tabs.find(tab => tab.id === tabOpened) as TabsNavItem + ), [tabOpened, props.tabs]) const updateOffset: (tabId: string) => void = useCallback((tabId: string) => { @@ -37,8 +46,8 @@ const TabsNavbar: FC = (props: TabsNavbarProps) => { return } - const activeTab: HTMLElement = tabRefs.current[index] - setOffset(activeTab.offsetLeft + activeTab.offsetWidth / 2) + const activatedTab: HTMLElement = tabRefs.current[index] + setOffset(activatedTab.offsetLeft + activatedTab.offsetWidth / 2) }, [ props.tabs, ]) @@ -70,27 +79,54 @@ const TabsNavbar: FC = (props: TabsNavbarProps) => { updateOffset, ]) + const renderTabItem: (tab: TabsNavItem, activeTabId?: string, ref?: (el: HTMLDivElement) => void) => ReactNode = ( + tab: TabsNavItem, + activeTabId?: string, + ref?: (el: HTMLDivElement) => void + ) => ( +
handleActivateTab(tab.id)} + > + + {tab.title} + + {tab.badges?.map((badge, id) => ( + + {badge.count} + + ))} +
+ ) + + useClickOutside(triggerRef.current, () => setMenuIsVisible(false)) + return (
- {props.tabs.map((tab, i) => ( -
tabRefs.current[i] = el as HTMLElement} - className={classNames(styles['tab-item'], tabOpened === tab.id && 'active')} - key={tab.id} - onClick={() => handleActivateTab(tab.id)} - > - - {tab.title} - - {tab.badges?.map((badge, id) => ( - - {badge.count} - - ))} -
- ))}
setMenuIsVisible((menuWasVisible: boolean) => !menuWasVisible)} + ref={triggerRef} + > + {renderTabItem(activeTab)} + +
+ +
+ {props.tabs.map((tab, i) => ( + renderTabItem(tab, tabOpened, el => {tabRefs.current[i] = el as HTMLElement}) + ))} +
+
diff --git a/src-ts/tools/learn/my-learning/completed-tab/CompletedTab.module.scss b/src-ts/tools/learn/my-learning/completed-tab/CompletedTab.module.scss index e3f93db9c..543ef5d12 100644 --- a/src-ts/tools/learn/my-learning/completed-tab/CompletedTab.module.scss +++ b/src-ts/tools/learn/my-learning/completed-tab/CompletedTab.module.scss @@ -4,6 +4,7 @@ display: flex; gap: $space-xxl; flex-wrap: wrap; + flex: 1; > * { flex: 0 1 calc(50% - calc($space-xxl / 2)); diff --git a/src-ts/tools/learn/my-learning/in-progress-tab/InProgressTab.module.scss b/src-ts/tools/learn/my-learning/in-progress-tab/InProgressTab.module.scss index 82ed3dde8..97024c9d8 100644 --- a/src-ts/tools/learn/my-learning/in-progress-tab/InProgressTab.module.scss +++ b/src-ts/tools/learn/my-learning/in-progress-tab/InProgressTab.module.scss @@ -5,6 +5,7 @@ display: flex; flex-direction: column; position: relative; + flex: 1; @include ltemd { gap: $space-xxl;