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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "willba-component-library",
3
- "version": "0.3.25",
3
+ "version": "0.3.27",
4
4
  "description": "A custom UI component library",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
@@ -15,4 +15,8 @@
15
15
  border-radius: 25px;
16
16
  overflow: hidden;
17
17
  }
18
+
19
+ .will-filter-bar-controls.disabled {
20
+ opacity: 0.1;
21
+ }
18
22
  }
@@ -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 { localStyles } = usePanelPosition({
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 [localStyles, setLocalStyles] = useState<CSSProperties>({})
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
- setLocalStyles({})
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 // Offset by 10px to account for controls section spacing
41
+ const buttonLeft = buttonRect.left - containerRect.left - 10
43
42
 
44
- const left = Math.max(
43
+ const newLeft = Math.max(
45
44
  0,
46
45
  Math.min(buttonLeft, containerRect.width - panelRect.width)
47
46
  )
48
47
 
49
- setLocalStyles({ left })
48
+ setLeft(newLeft)
50
49
  }, [selectedFilter, isMobile])
51
50
 
52
- return { localStyles }
51
+ return { top, left }
53
52
  }