willba-component-library 0.1.46 → 0.1.47
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/lib/components/FilterBar/FilterBarTypes.d.ts +10 -5
- package/lib/components/FilterBar/components/buttons/select-button/SelectButton.d.ts +8 -1
- package/lib/components/FilterBar/hooks/useFilterBar.d.ts +3 -3
- package/lib/components/FilterBar/hooks/useScrollInToView.d.ts +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.esm.js +32 -27
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +32 -27
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +32 -27
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBar.tsx +10 -16
- package/src/components/FilterBar/FilterBarTypes.ts +9 -3
- package/src/components/FilterBar/components/buttons/select-button/SelectButton.css +11 -5
- package/src/components/FilterBar/components/buttons/select-button/SelectButton.tsx +15 -9
- package/src/components/FilterBar/hooks/useFilterBar.tsx +2 -2
- package/src/components/FilterBar/hooks/useScrollInToView.tsx +2 -2
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import useTheme, { Palette } from '../../themes/useTheme'
|
|
|
6
6
|
import '../../themes/Default.css'
|
|
7
7
|
|
|
8
8
|
import { parseDates, parseGuests } from './utils'
|
|
9
|
-
import { AgeCategoryType } from './FilterBarTypes'
|
|
9
|
+
import { AgeCategoryType, FilterSections } from './FilterBarTypes'
|
|
10
10
|
import {
|
|
11
11
|
useCloseFilterSection,
|
|
12
12
|
useFilterBar,
|
|
@@ -63,7 +63,7 @@ export default function FilterBar({
|
|
|
63
63
|
setSelectedPath,
|
|
64
64
|
} = useFilterBar({ redirectUrl, currentViewApply, ageCategories })
|
|
65
65
|
|
|
66
|
-
// Default selected tab
|
|
66
|
+
// Default selected tab when tabs are hidden
|
|
67
67
|
useEffect(() => {
|
|
68
68
|
if (currentViewApply === 'roomFilters') {
|
|
69
69
|
setSelectedPath('/rooms')
|
|
@@ -76,6 +76,7 @@ export default function FilterBar({
|
|
|
76
76
|
// Handle close filter section
|
|
77
77
|
const { filtersRef } = useCloseFilterSection({ handleSelectedFilter })
|
|
78
78
|
|
|
79
|
+
// Parsed data for filter section description
|
|
79
80
|
const parsedDates = parseDates({ calendarRange })
|
|
80
81
|
const parsedGuests = parseGuests({ ageCategoryCounts, ageCategories })
|
|
81
82
|
|
|
@@ -112,11 +113,8 @@ export default function FilterBar({
|
|
|
112
113
|
? t('calendar.roomsLabelPlaceholder')
|
|
113
114
|
: t('calendar.eventsLabelPlaceholder')
|
|
114
115
|
}
|
|
115
|
-
onClick={() => handleSelectedFilter(
|
|
116
|
-
|
|
117
|
-
date={
|
|
118
|
-
calendarRange?.to ? format(calendarRange.to, 'dd.MM.yyyy') : null
|
|
119
|
-
}
|
|
116
|
+
onClick={() => handleSelectedFilter(FilterSections.CALENDAR)}
|
|
117
|
+
active={selectedFilter === FilterSections.CALENDAR}
|
|
120
118
|
/>
|
|
121
119
|
|
|
122
120
|
{selectedPath === '/rooms' && (
|
|
@@ -128,8 +126,8 @@ export default function FilterBar({
|
|
|
128
126
|
description={
|
|
129
127
|
parsedGuests ? parsedGuests : t('guests.labelPlaceholder')
|
|
130
128
|
}
|
|
131
|
-
onClick={() => handleSelectedFilter(
|
|
132
|
-
|
|
129
|
+
onClick={() => handleSelectedFilter(FilterSections.GUESTS)}
|
|
130
|
+
active={selectedFilter === FilterSections.GUESTS}
|
|
133
131
|
/>
|
|
134
132
|
</>
|
|
135
133
|
)}
|
|
@@ -144,14 +142,14 @@ export default function FilterBar({
|
|
|
144
142
|
>
|
|
145
143
|
<CloseButton handleClose={() => handleSelectedFilter(false)} />
|
|
146
144
|
|
|
147
|
-
{selectedFilter ===
|
|
145
|
+
{selectedFilter === FilterSections.CALENDAR && (
|
|
148
146
|
<Calendar
|
|
149
147
|
calendarRange={calendarRange}
|
|
150
148
|
setCalendarRange={setCalendarRange}
|
|
151
149
|
ref={filtersRef}
|
|
152
150
|
/>
|
|
153
151
|
)}
|
|
154
|
-
{selectedFilter ===
|
|
152
|
+
{selectedFilter === FilterSections.GUESTS && (
|
|
155
153
|
<Guests
|
|
156
154
|
updateGuestsCount={updateGuestsCount}
|
|
157
155
|
ageCategories={ageCategories}
|
|
@@ -159,7 +157,7 @@ export default function FilterBar({
|
|
|
159
157
|
ref={filtersRef}
|
|
160
158
|
/>
|
|
161
159
|
)}
|
|
162
|
-
{selectedFilter ===
|
|
160
|
+
{selectedFilter === FilterSections.CATEGORIES && (
|
|
163
161
|
<Categories categories={categories} setCategories={setCategories} />
|
|
164
162
|
)}
|
|
165
163
|
</div>
|
|
@@ -170,10 +168,6 @@ export default function FilterBar({
|
|
|
170
168
|
|
|
171
169
|
////////////
|
|
172
170
|
|
|
173
|
-
const fontWeightBold = (input: boolean) => {
|
|
174
|
-
return { fontWeight: input ? 'bold' : 'initial' }
|
|
175
|
-
}
|
|
176
|
-
|
|
177
171
|
const AGE_CATEGORIES_FALLBACK = [
|
|
178
172
|
{
|
|
179
173
|
id: '1',
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type AgeCategoryCount = {
|
|
2
2
|
[categoryId: string]: number
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
export
|
|
5
|
+
export type AgeCategoryType = {
|
|
6
6
|
id: string
|
|
7
7
|
name: string
|
|
8
8
|
minVal: number
|
|
9
9
|
sortOrder: number
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export type GuestsCountPropsType = {
|
|
13
13
|
label: string
|
|
14
14
|
id: number
|
|
15
15
|
updateGuestsCount: (arg1: string, arg2: number) => void
|
|
@@ -17,3 +17,9 @@ export interface GuestsCountPropsType {
|
|
|
17
17
|
minVal: number
|
|
18
18
|
sortOrder: number
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
export enum FilterSections {
|
|
22
|
+
CALENDAR = 'calendar',
|
|
23
|
+
GUESTS = 'guests',
|
|
24
|
+
CATEGORIES = 'categories',
|
|
25
|
+
}
|
|
@@ -10,8 +10,6 @@
|
|
|
10
10
|
text-align: initial;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
13
|
.will-filter-bar-select-button .select-button-wrapper {
|
|
16
14
|
display: flex;
|
|
17
15
|
align-items: center;
|
|
@@ -24,16 +22,24 @@
|
|
|
24
22
|
display: grid
|
|
25
23
|
}
|
|
26
24
|
|
|
25
|
+
.will-filter-bar-select-button .select-button-label {
|
|
26
|
+
font-weight: 500;
|
|
27
|
+
}
|
|
28
|
+
|
|
27
29
|
.will-filter-bar-select-button .select-button-description {
|
|
28
30
|
font-weight: 400;
|
|
29
|
-
opacity: 0.
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
opacity: 0.8;
|
|
32
|
+
|
|
32
33
|
white-space: nowrap;
|
|
33
34
|
overflow: hidden;
|
|
34
35
|
text-overflow: ellipsis;
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
.will-filter-bar-select-button .select-button-label.active,
|
|
39
|
+
.will-filter-bar-select-button .select-button-description.active {
|
|
40
|
+
font-weight: 600;
|
|
41
|
+
}
|
|
42
|
+
|
|
37
43
|
@media (max-width: 960px) {
|
|
38
44
|
.will-filter-bar-select-button {
|
|
39
45
|
padding: 15px 0;
|
|
@@ -5,21 +5,27 @@ import './SelectButton.css'
|
|
|
5
5
|
type Props = {
|
|
6
6
|
label: string
|
|
7
7
|
onClick: () => void
|
|
8
|
-
style: Object
|
|
9
8
|
description: string
|
|
9
|
+
active?: boolean
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
export const SelectButton = ({
|
|
12
|
+
export const SelectButton = ({
|
|
13
|
+
active,
|
|
14
|
+
label,
|
|
15
|
+
onClick,
|
|
16
|
+
|
|
17
|
+
description,
|
|
18
|
+
}: Props) => {
|
|
13
19
|
return (
|
|
14
|
-
<button
|
|
15
|
-
className="will-filter-bar-select-button"
|
|
16
|
-
onClick={onClick}
|
|
17
|
-
style={style}
|
|
18
|
-
>
|
|
20
|
+
<button className="will-filter-bar-select-button" onClick={onClick}>
|
|
19
21
|
<span className="select-button-wrapper">
|
|
20
22
|
<div>
|
|
21
|
-
<p className=
|
|
22
|
-
|
|
23
|
+
<p className={`select-button-label ${active ? 'active' : ''}`}>
|
|
24
|
+
{label}
|
|
25
|
+
</p>
|
|
26
|
+
<p className={`select-button-description ${active ? 'active' : ''}`}>
|
|
27
|
+
{description}
|
|
28
|
+
</p>
|
|
23
29
|
</div>
|
|
24
30
|
</span>
|
|
25
31
|
</button>
|
|
@@ -17,7 +17,7 @@ export const useFilterBar = ({
|
|
|
17
17
|
}: Props) => {
|
|
18
18
|
const [selectedPath, setSelectedPath] = useState('/events')
|
|
19
19
|
|
|
20
|
-
const [selectedFilter, setSelectedFilter] = useState<
|
|
20
|
+
const [selectedFilter, setSelectedFilter] = useState<string | boolean>(false)
|
|
21
21
|
const [calendarRange, setCalendarRange] = useState<DateRange | undefined>()
|
|
22
22
|
|
|
23
23
|
const [categories, setCategories] = useState<number>(0)
|
|
@@ -80,7 +80,7 @@ export const useFilterBar = ({
|
|
|
80
80
|
}))
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
const handleSelectedFilter = (id:
|
|
83
|
+
const handleSelectedFilter = (id: string | boolean) => {
|
|
84
84
|
setSelectedFilter(id)
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from 'react'
|
|
2
2
|
|
|
3
3
|
type Props = {
|
|
4
|
-
selectedFilter:
|
|
4
|
+
selectedFilter: string | boolean
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export const useScrollInToView = ({ selectedFilter }: Props) => {
|
|
@@ -9,7 +9,7 @@ export const useScrollInToView = ({ selectedFilter }: Props) => {
|
|
|
9
9
|
const targetFilterBarRef = useRef<HTMLDivElement | null>(null)
|
|
10
10
|
|
|
11
11
|
useEffect(() => {
|
|
12
|
-
if (window !== undefined && window.innerWidth > 960) {
|
|
12
|
+
if (typeof window !== 'undefined' && window.innerWidth > 960) {
|
|
13
13
|
setIsMobile(false)
|
|
14
14
|
return
|
|
15
15
|
}
|