willba-component-library 0.3.15 → 0.3.17

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.15",
3
+ "version": "0.3.17",
4
4
  "description": "A custom UI component library",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
@@ -1,3 +1,3 @@
1
1
  .will-dates-filter-container {
2
- padding: 0 16px;
2
+ padding: 0 16px 16px 16px;
3
3
  }
@@ -53,7 +53,6 @@
53
53
  @media (max-width: 960px) {
54
54
  .will-guests-filter-inner {
55
55
  width: 100%;
56
- margin: 15px 0;
57
56
  justify-content: space-between;
58
57
  }
59
58
  }
@@ -7,7 +7,13 @@
7
7
  flex-direction: column;
8
8
  min-width: 400px;
9
9
  gap: 20px;
10
- padding: 16px;
10
+ padding: 0 16px 16px 16px;
11
+ }
12
+
13
+ @media (max-width: 960px) {
14
+ .will-guests-filter-container {
15
+ min-width: auto;
16
+ }
11
17
  }
12
18
 
13
19
  /**/
@@ -4,10 +4,9 @@
4
4
 
5
5
  .will-locations-filter-container {
6
6
  display: flex;
7
- gap: 10px;
8
7
  flex-direction: column;
9
8
  min-width: 400px;
10
- padding: 16px 0;
9
+ padding-bottom: 16px;
11
10
  }
12
11
 
13
12
  @media (max-width: 960px) {
@@ -2,7 +2,7 @@ import {
2
2
  CSSProperties,
3
3
  MutableRefObject,
4
4
  RefObject,
5
- useEffect,
5
+ useLayoutEffect,
6
6
  useState,
7
7
  } from 'react'
8
8
 
@@ -23,44 +23,31 @@ export const usePanelPosition = ({
23
23
  }: Props) => {
24
24
  const [localStyles, setLocalStyles] = useState<CSSProperties>({})
25
25
 
26
- useEffect(() => {
26
+ useLayoutEffect(() => {
27
27
  if (!selectedFilter || typeof selectedFilter !== 'string' || isMobile) {
28
28
  setLocalStyles({})
29
29
  return
30
30
  }
31
31
 
32
- let timeoutId: number | null = null
32
+ const panel = panelRef.current
33
+ const container = targetFilterBarRef.current
34
+ const button = buttonRefs.current[selectedFilter]
33
35
 
34
- const calculate = () => {
35
- const panel = panelRef.current
36
- const container = targetFilterBarRef.current
37
- const button = buttonRefs.current[selectedFilter]
36
+ if (!panel || !container || !button) return
38
37
 
39
- if (!panel || !container || !button) return
38
+ const panelRect = panel.getBoundingClientRect()
39
+ const containerRect = container.getBoundingClientRect()
40
+ const buttonRect = button.getBoundingClientRect()
40
41
 
41
- const panelRect = panel.getBoundingClientRect()
42
- if (panelRect.width === 0) {
43
- timeoutId = window.setTimeout(calculate, 10)
44
- return
45
- }
42
+ const buttonLeft = buttonRect.left - containerRect.left
46
43
 
47
- const containerRect = container.getBoundingClientRect()
48
- const buttonRect = button.getBoundingClientRect()
49
- const buttonLeft = buttonRect.left - containerRect.left
50
- const left = Math.min(
51
- buttonLeft,
52
- Math.max(containerRect.width - panelRect.width, 0)
53
- )
44
+ const left = Math.max(
45
+ 0,
46
+ Math.min(buttonLeft, containerRect.width - panelRect.width)
47
+ )
54
48
 
55
- setLocalStyles({ left })
56
- }
57
-
58
- calculate()
59
-
60
- return () => {
61
- if (timeoutId) clearTimeout(timeoutId)
62
- }
63
- }, [selectedFilter, panelRef, targetFilterBarRef, buttonRefs, isMobile])
49
+ setLocalStyles({ left })
50
+ }, [selectedFilter, isMobile])
64
51
 
65
52
  return { localStyles }
66
53
  }