willba-component-library 0.3.20 → 0.3.21
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/components/FilterPanels/Locations/Locations.d.ts +0 -1
- package/lib/components/FilterBar/components/FilterTabs/FilterTabs.d.ts +1 -1
- package/lib/components/FilterBar/hooks/index.d.ts +1 -1
- package/lib/components/FilterBar/hooks/useFilterRefs.d.ts +8 -0
- package/lib/index.esm.js +26 -28
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +26 -28
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +26 -28
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBar.tsx +1 -2
- package/src/components/FilterBar/components/FilterControls/FilterControls.tsx +1 -1
- package/src/components/FilterBar/components/FilterPanels/Dates/Dates.css +7 -1
- package/src/components/FilterBar/components/FilterPanels/FilterPanels.tsx +0 -1
- package/src/components/FilterBar/components/FilterPanels/Guests/Guests.css +2 -1
- package/src/components/FilterBar/components/FilterPanels/Locations/Locations.tsx +1 -3
- package/src/components/FilterBar/components/FilterPanels/SectionHeader/SectionHeader.css +5 -1
- package/src/components/FilterBar/components/FilterTabs/FilterTabs.tsx +26 -23
- package/src/components/FilterBar/components/ImageCard/ImageCard.css +7 -1
- package/src/components/FilterBar/hooks/index.ts +1 -1
- package/src/components/FilterBar/hooks/{useFilterUi.tsx → useFilterRefs.tsx} +1 -1
- package/src/components/FilterBar/hooks/usePanelPosition.tsx +1 -1
- package/src/components/FilterBar/providers/FilterBarProvider.tsx +6 -6
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@ import '../../themes/Default.css'
|
|
|
11
11
|
import './FilterBar.css'
|
|
12
12
|
|
|
13
13
|
export const FilterBar = ({
|
|
14
|
-
language
|
|
14
|
+
language,
|
|
15
15
|
ageCategories,
|
|
16
16
|
redirectUrl = REDIRECT_URL_FALLBACK,
|
|
17
17
|
palette,
|
|
@@ -62,4 +62,3 @@ export const FilterBar = ({
|
|
|
62
62
|
////////////
|
|
63
63
|
|
|
64
64
|
const REDIRECT_URL_FALLBACK = 'http://localhost:3000/'
|
|
65
|
-
const LANGUAGE_FALLBACK = 'en'
|
|
@@ -7,12 +7,13 @@
|
|
|
7
7
|
flex-direction: column;
|
|
8
8
|
min-width: 400px;
|
|
9
9
|
gap: 20px;
|
|
10
|
-
padding: 0
|
|
10
|
+
padding: 0 30px 16px 30px;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
@media (max-width: 960px) {
|
|
14
14
|
.will-guests-filter-container {
|
|
15
15
|
min-width: auto;
|
|
16
|
+
padding: 0 20px 16px 20px;
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -10,7 +10,6 @@ import './Locations.css'
|
|
|
10
10
|
|
|
11
11
|
type Props = {
|
|
12
12
|
locations?: Location[]
|
|
13
|
-
language?: string
|
|
14
13
|
selectedLocations: Location[]
|
|
15
14
|
setSelectedLocations: (locations: Location[]) => void
|
|
16
15
|
autoFocus?: boolean
|
|
@@ -22,7 +21,6 @@ export const Locations = forwardRef<HTMLDivElement, Props>(
|
|
|
22
21
|
(
|
|
23
22
|
{
|
|
24
23
|
locations,
|
|
25
|
-
language,
|
|
26
24
|
selectedLocations,
|
|
27
25
|
setSelectedLocations,
|
|
28
26
|
autoFocus,
|
|
@@ -71,7 +69,7 @@ export const Locations = forwardRef<HTMLDivElement, Props>(
|
|
|
71
69
|
/>
|
|
72
70
|
|
|
73
71
|
<div className="will-locations-filter-container">
|
|
74
|
-
{!!
|
|
72
|
+
{!!locations?.length &&
|
|
75
73
|
locations.map((location, index) => {
|
|
76
74
|
return (
|
|
77
75
|
<ImageCard
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
display: flex;
|
|
3
3
|
justify-content: space-between;
|
|
4
4
|
align-items: center;
|
|
5
|
-
padding: 16px;
|
|
5
|
+
padding: 16px 30px;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
.will-filter-section-title {
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
@media (max-width: 960px) {
|
|
27
|
+
.will-filter-section-header {
|
|
28
|
+
padding: 16px 20px;
|
|
29
|
+
}
|
|
30
|
+
|
|
27
31
|
.will-filter-section-title {
|
|
28
32
|
font-size: 18px;
|
|
29
33
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react'
|
|
1
|
+
import React, { useMemo } from 'react'
|
|
2
2
|
|
|
3
3
|
import { useTranslation } from 'react-i18next'
|
|
4
4
|
|
|
@@ -15,33 +15,36 @@ export const FilterTabs = () => {
|
|
|
15
15
|
selectedPath,
|
|
16
16
|
mode,
|
|
17
17
|
tabs,
|
|
18
|
+
tabsRef,
|
|
18
19
|
handleSelectedFilter,
|
|
19
20
|
setSelectedPath,
|
|
20
21
|
handleResetFilters,
|
|
21
|
-
//
|
|
22
|
-
tabsRef,
|
|
23
22
|
} = useFilterBar()
|
|
24
23
|
|
|
24
|
+
const sortedTabs = useMemo(
|
|
25
|
+
() => [...(tabs ?? [])].sort((a, b) => a.order - b.order),
|
|
26
|
+
[tabs]
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
const handleTabClick = (path: string) => {
|
|
30
|
+
setSelectedPath(path)
|
|
31
|
+
handleResetFilters()
|
|
32
|
+
handleSelectedFilter(false)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (sortedTabs.length <= 1) return null
|
|
36
|
+
|
|
25
37
|
return (
|
|
26
|
-
tabs
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
handleResetFilters()
|
|
38
|
-
handleSelectedFilter(false)
|
|
39
|
-
}}
|
|
40
|
-
active={selectedPath === tab.path}
|
|
41
|
-
mode={mode}
|
|
42
|
-
/>
|
|
43
|
-
))}
|
|
44
|
-
</div>
|
|
45
|
-
)
|
|
38
|
+
<div className="will-filter-bar-tabs" ref={tabsRef}>
|
|
39
|
+
{sortedTabs.map((tab) => (
|
|
40
|
+
<TabButton
|
|
41
|
+
key={tab.path}
|
|
42
|
+
label={tab.label || t(`tabs.${tab.path.slice(1)}`)}
|
|
43
|
+
onClick={() => handleTabClick(tab.path)}
|
|
44
|
+
active={selectedPath === tab.path}
|
|
45
|
+
mode={mode}
|
|
46
|
+
/>
|
|
47
|
+
))}
|
|
48
|
+
</div>
|
|
46
49
|
)
|
|
47
50
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
gap: 20px;
|
|
4
4
|
justify-content: space-between;
|
|
5
5
|
align-items: center;
|
|
6
|
-
padding: 8px
|
|
6
|
+
padding: 8px 30px;
|
|
7
7
|
cursor: pointer;
|
|
8
8
|
user-select: none;
|
|
9
9
|
min-height: 40px;
|
|
@@ -22,3 +22,9 @@
|
|
|
22
22
|
height: 68px;
|
|
23
23
|
object-fit: cover;
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
@media (max-width: 960px) {
|
|
27
|
+
.will-image-card {
|
|
28
|
+
padding: 8px 20px;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { useScrollInToView } from './useScrollInToView'
|
|
2
2
|
export { useFilterState } from './useFilterState'
|
|
3
3
|
export { useFilterActions } from './useFilterActions'
|
|
4
|
-
export {
|
|
4
|
+
export { useFilterRefs } from './useFilterRefs'
|
|
5
5
|
export { usePanelPosition } from './usePanelPosition'
|
|
@@ -2,7 +2,7 @@ import { useRef } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { useScrollInToView } from './useScrollInToView'
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const useFilterRefs = (selectedFilter: string | boolean) => {
|
|
6
6
|
const buttonRefs = useRef<Record<string, HTMLButtonElement | null>>({})
|
|
7
7
|
const panelRef = useRef<HTMLDivElement | null>(null)
|
|
8
8
|
const previouslyFocusedButtonRef = useRef<HTMLButtonElement | null>(null)
|
|
@@ -39,7 +39,7 @@ export const usePanelPosition = ({
|
|
|
39
39
|
const containerRect = container.getBoundingClientRect()
|
|
40
40
|
const buttonRect = button.getBoundingClientRect()
|
|
41
41
|
|
|
42
|
-
const buttonLeft = buttonRect.left - containerRect.left
|
|
42
|
+
const buttonLeft = buttonRect.left - containerRect.left - 30 // Offset by 30px to account for controls section spacing
|
|
43
43
|
|
|
44
44
|
const left = Math.max(
|
|
45
45
|
0,
|
|
@@ -9,7 +9,7 @@ import React, {
|
|
|
9
9
|
import { DateRange } from 'react-day-picker'
|
|
10
10
|
|
|
11
11
|
import { AgeCategoryCount, Location, FilterBarTypes } from '../FilterBarTypes'
|
|
12
|
-
import { useFilterActions, useFilterState,
|
|
12
|
+
import { useFilterActions, useFilterState, useFilterRefs } from '../hooks'
|
|
13
13
|
|
|
14
14
|
type FilterBarProviderProps = PropsWithChildren<FilterBarTypes>
|
|
15
15
|
|
|
@@ -96,7 +96,7 @@ export const FilterBarProvider = ({
|
|
|
96
96
|
setInnerLoading,
|
|
97
97
|
})
|
|
98
98
|
|
|
99
|
-
const
|
|
99
|
+
const filterRefs = useFilterRefs(selectedFilter)
|
|
100
100
|
|
|
101
101
|
const contextValue = useMemo(
|
|
102
102
|
() => ({
|
|
@@ -129,7 +129,7 @@ export const FilterBarProvider = ({
|
|
|
129
129
|
outerLoading,
|
|
130
130
|
locations,
|
|
131
131
|
|
|
132
|
-
...
|
|
132
|
+
...filterRefs,
|
|
133
133
|
}),
|
|
134
134
|
[
|
|
135
135
|
selectedFilter,
|
|
@@ -150,9 +150,9 @@ export const FilterBarProvider = ({
|
|
|
150
150
|
tabs,
|
|
151
151
|
outerLoading,
|
|
152
152
|
locations,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
filterRefs.isMobile,
|
|
154
|
+
filterRefs.tabsRef,
|
|
155
|
+
filterRefs.filtersRef,
|
|
156
156
|
]
|
|
157
157
|
)
|
|
158
158
|
|