willba-component-library 0.3.25 → 0.3.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/components/FilterBar/hooks/usePanelPosition.d.ts +5 -3
- package/lib/index.esm.js +17 -14
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +17 -14
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +17 -14
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/components/FilterControls/FilterControls.css +4 -0
- package/src/components/FilterBar/components/FilterControls/FilterControls.tsx +2 -2
- package/src/components/FilterBar/components/FilterPanels/FilterPanels.css +0 -2
- package/src/components/FilterBar/components/FilterPanels/FilterPanels.tsx +3 -5
- package/src/components/FilterBar/hooks/usePanelPosition.tsx +12 -13
package/package.json
CHANGED
|
@@ -61,7 +61,7 @@ export const FilterControls = () => {
|
|
|
61
61
|
|
|
62
62
|
return (
|
|
63
63
|
<div
|
|
64
|
-
className={`will-filter-bar-controls ${mode || 'light'}`}
|
|
64
|
+
className={`will-filter-bar-controls ${mode || 'light'} ${selectedFilter ? 'disabled' : ''}`}
|
|
65
65
|
ref={(el) => {
|
|
66
66
|
filtersRef.current = el
|
|
67
67
|
|
|
@@ -70,7 +70,7 @@ export const FilterControls = () => {
|
|
|
70
70
|
}
|
|
71
71
|
}}
|
|
72
72
|
>
|
|
73
|
-
{locations?.data?.length && locations.data.length > 1 && (
|
|
73
|
+
{!!locations?.data?.length && locations.data.length > 1 && (
|
|
74
74
|
<>
|
|
75
75
|
<SelectButton
|
|
76
76
|
ref={(el) => (buttonRefs.current[FilterSections.LOCATIONS] = el)}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
background-color: var(--will-white);
|
|
3
3
|
min-height: 100px;
|
|
4
4
|
position: absolute;
|
|
5
|
-
top: 125px;
|
|
6
5
|
z-index: 111;
|
|
7
6
|
border-radius: 25px;
|
|
8
7
|
box-shadow: var(--will-box-shadow);
|
|
@@ -17,7 +16,6 @@
|
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
.will-filter-bar-panels {
|
|
20
|
-
top: 60px;
|
|
21
19
|
width: 100%;
|
|
22
20
|
z-index: 999;
|
|
23
21
|
}
|
|
@@ -40,12 +40,13 @@ export const FilterPanels = () => {
|
|
|
40
40
|
// Handle close filter section
|
|
41
41
|
const { filterSectionRef } = useCloseFilterSection({ handleSelectedFilter })
|
|
42
42
|
|
|
43
|
-
const {
|
|
43
|
+
const { left, top } = usePanelPosition({
|
|
44
44
|
selectedFilter,
|
|
45
45
|
panelRef,
|
|
46
46
|
filtersRef,
|
|
47
47
|
buttonRefs,
|
|
48
48
|
isMobile,
|
|
49
|
+
tabs,
|
|
49
50
|
})
|
|
50
51
|
|
|
51
52
|
const renderContent = () => {
|
|
@@ -101,10 +102,7 @@ export const FilterPanels = () => {
|
|
|
101
102
|
<div
|
|
102
103
|
ref={panelRef}
|
|
103
104
|
className={`will-filter-bar-panels ${mode || 'light'}`}
|
|
104
|
-
style={{
|
|
105
|
-
...localStyles,
|
|
106
|
-
...((!tabs || tabs.length < 2) && !isMobile ? { top: 66 } : {}),
|
|
107
|
-
}}
|
|
105
|
+
style={{ left, top }}
|
|
108
106
|
>
|
|
109
107
|
{renderContent()}
|
|
110
108
|
</div>
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CSSProperties,
|
|
3
|
-
MutableRefObject,
|
|
4
|
-
RefObject,
|
|
5
|
-
useLayoutEffect,
|
|
6
|
-
useState,
|
|
7
|
-
} from 'react'
|
|
1
|
+
import { MutableRefObject, RefObject, useLayoutEffect, useState } from 'react'
|
|
8
2
|
|
|
9
3
|
type Props = {
|
|
10
4
|
selectedFilter: string | boolean
|
|
@@ -12,6 +6,7 @@ type Props = {
|
|
|
12
6
|
filtersRef: RefObject<HTMLDivElement | null>
|
|
13
7
|
buttonRefs: MutableRefObject<Record<string, HTMLButtonElement | null>>
|
|
14
8
|
isMobile: boolean
|
|
9
|
+
tabs?: unknown[]
|
|
15
10
|
}
|
|
16
11
|
|
|
17
12
|
export const usePanelPosition = ({
|
|
@@ -20,12 +15,16 @@ export const usePanelPosition = ({
|
|
|
20
15
|
filtersRef,
|
|
21
16
|
buttonRefs,
|
|
22
17
|
isMobile,
|
|
18
|
+
tabs,
|
|
23
19
|
}: Props) => {
|
|
24
|
-
const [
|
|
20
|
+
const [left, setLeft] = useState<number | undefined>()
|
|
21
|
+
|
|
22
|
+
const hasMultipleTabs = tabs && tabs.length > 1
|
|
23
|
+
const top = isMobile ? (hasMultipleTabs ? 60 : 0) : hasMultipleTabs ? 125 : 66
|
|
25
24
|
|
|
26
25
|
useLayoutEffect(() => {
|
|
27
26
|
if (!selectedFilter || typeof selectedFilter !== 'string' || isMobile) {
|
|
28
|
-
|
|
27
|
+
setLeft(undefined)
|
|
29
28
|
return
|
|
30
29
|
}
|
|
31
30
|
|
|
@@ -39,15 +38,15 @@ export const usePanelPosition = ({
|
|
|
39
38
|
const containerRect = container.getBoundingClientRect()
|
|
40
39
|
const buttonRect = button.getBoundingClientRect()
|
|
41
40
|
|
|
42
|
-
const buttonLeft = buttonRect.left - containerRect.left - 10
|
|
41
|
+
const buttonLeft = buttonRect.left - containerRect.left - 10
|
|
43
42
|
|
|
44
|
-
const
|
|
43
|
+
const newLeft = Math.max(
|
|
45
44
|
0,
|
|
46
45
|
Math.min(buttonLeft, containerRect.width - panelRect.width)
|
|
47
46
|
)
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
setLeft(newLeft)
|
|
50
49
|
}, [selectedFilter, isMobile])
|
|
51
50
|
|
|
52
|
-
return {
|
|
51
|
+
return { top, left }
|
|
53
52
|
}
|