willba-component-library 0.1.60 → 0.1.61
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/components/calendar/Calendar.d.ts +1 -0
- package/lib/components/FilterBar/utils/parseGuests.d.ts +11 -1
- package/lib/index.esm.js +478 -82
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +478 -82
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +478 -82
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBar.tsx +12 -9
- package/src/components/FilterBar/components/buttons/select-button/SelectButton.css +6 -3
- package/src/components/FilterBar/components/buttons/select-button/SelectButton.tsx +1 -3
- package/src/components/FilterBar/components/calendar/Calendar.tsx +12 -3
- package/src/components/FilterBar/utils/parseGuests.tsx +21 -9
- package/src/locales/en/filterBar.json +2 -1
- package/src/locales/fi/filterBar.json +2 -1
package/package.json
CHANGED
|
@@ -107,8 +107,14 @@ export default function FilterBar({
|
|
|
107
107
|
|
|
108
108
|
// Parsed data for filter section description
|
|
109
109
|
const parsedDates = parseDates({ calendarRange })
|
|
110
|
-
const parsedGuests = parseGuests({
|
|
111
|
-
|
|
110
|
+
const parsedGuests = parseGuests({
|
|
111
|
+
ageCategoryCounts,
|
|
112
|
+
ageCategories,
|
|
113
|
+
guestsPlaceholder: t('guests.labelPlaceholder'),
|
|
114
|
+
guestLabel: t('guests.guestLabel'),
|
|
115
|
+
guestsLabel: t('guests.guestsLabel'),
|
|
116
|
+
})
|
|
117
|
+
console.log(parsedGuests)
|
|
112
118
|
return (
|
|
113
119
|
<div
|
|
114
120
|
className={`will-root ${fullWidth ? 'is-full-width' : ''}`}
|
|
@@ -150,7 +156,7 @@ export default function FilterBar({
|
|
|
150
156
|
: t('calendar.eventsLabelPlaceholder')
|
|
151
157
|
}
|
|
152
158
|
onClick={() => handleSelectedFilter(FilterSections.CALENDAR)}
|
|
153
|
-
active={
|
|
159
|
+
active={!!parsedDates}
|
|
154
160
|
/>
|
|
155
161
|
|
|
156
162
|
{selectedPath === Pages.ROOMS && (
|
|
@@ -159,13 +165,9 @@ export default function FilterBar({
|
|
|
159
165
|
|
|
160
166
|
<SelectButton
|
|
161
167
|
label={t('guests.label')}
|
|
162
|
-
description={
|
|
163
|
-
parsedGuests
|
|
164
|
-
? t('guests.guestsLabel') + parsedGuests
|
|
165
|
-
: t('guests.labelPlaceholder')
|
|
166
|
-
}
|
|
168
|
+
description={parsedGuests.content}
|
|
167
169
|
onClick={() => handleSelectedFilter(FilterSections.GUESTS)}
|
|
168
|
-
active={
|
|
170
|
+
active={!!parsedGuests.data.total}
|
|
169
171
|
/>
|
|
170
172
|
</>
|
|
171
173
|
)}
|
|
@@ -187,6 +189,7 @@ export default function FilterBar({
|
|
|
187
189
|
ref={filtersRef}
|
|
188
190
|
calendarOffset={calendarOffset}
|
|
189
191
|
selectedPath={selectedPath}
|
|
192
|
+
locale={language}
|
|
190
193
|
/>
|
|
191
194
|
)}
|
|
192
195
|
{selectedFilter === FilterSections.GUESTS && (
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
.will-filter-bar-select-button .select-button-label {
|
|
26
|
-
font-weight:
|
|
26
|
+
font-weight: 600;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
.will-filter-bar-select-button .select-button-description {
|
|
30
30
|
font-weight: 400;
|
|
31
|
-
opacity: 0.
|
|
31
|
+
opacity: 0.5;
|
|
32
32
|
|
|
33
33
|
white-space: nowrap;
|
|
34
34
|
|
|
@@ -41,7 +41,10 @@
|
|
|
41
41
|
|
|
42
42
|
.will-filter-bar-select-button .select-button-label.active,
|
|
43
43
|
.will-filter-bar-select-button .select-button-description.active {
|
|
44
|
-
font-weight:
|
|
44
|
+
font-weight: 700;
|
|
45
|
+
font-size: 15px;
|
|
46
|
+
opacity: 1;
|
|
47
|
+
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
@media (max-width: 960px) {
|
|
@@ -20,9 +20,7 @@ export const SelectButton = ({
|
|
|
20
20
|
<button className="will-filter-bar-select-button" onClick={onClick}>
|
|
21
21
|
<span className="select-button-wrapper">
|
|
22
22
|
<div>
|
|
23
|
-
<p className={`select-button-label
|
|
24
|
-
{label}
|
|
25
|
-
</p>
|
|
23
|
+
<p className={`select-button-label`}>{label}</p>
|
|
26
24
|
<p
|
|
27
25
|
className={`select-button-description ${active ? 'active' : ''}`}
|
|
28
26
|
dangerouslySetInnerHTML={{ __html: description }}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { forwardRef, useEffect } from 'react'
|
|
2
2
|
import { DateRange, DayPicker } from 'react-day-picker'
|
|
3
|
-
import { addDays, startOfDay
|
|
3
|
+
import { addDays, startOfDay } from 'date-fns'
|
|
4
|
+
import { fi, enUS } from 'date-fns/locale'
|
|
4
5
|
import { useMediaQuery } from 'react-responsive'
|
|
5
6
|
|
|
6
7
|
import { CalendarOffset } from '../../FilterBarTypes'
|
|
@@ -13,11 +14,18 @@ type Props = {
|
|
|
13
14
|
setCalendarRange: (range: DateRange | undefined) => void
|
|
14
15
|
calendarOffset: CalendarOffset
|
|
15
16
|
selectedPath: string
|
|
17
|
+
locale?: string
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export const Calendar = forwardRef<HTMLDivElement, Props>(
|
|
19
21
|
(
|
|
20
|
-
{
|
|
22
|
+
{
|
|
23
|
+
calendarRange,
|
|
24
|
+
setCalendarRange,
|
|
25
|
+
calendarOffset,
|
|
26
|
+
selectedPath,
|
|
27
|
+
locale,
|
|
28
|
+
}: Props,
|
|
21
29
|
ref
|
|
22
30
|
) => {
|
|
23
31
|
const isTablet = useMediaQuery({ maxWidth: 960 })
|
|
@@ -49,6 +57,7 @@ export const Calendar = forwardRef<HTMLDivElement, Props>(
|
|
|
49
57
|
<DayPicker
|
|
50
58
|
id="will-calendar"
|
|
51
59
|
mode="range"
|
|
60
|
+
locale={locale === 'en' ? enUS : fi}
|
|
52
61
|
numberOfMonths={!isTablet ? 2 : 1}
|
|
53
62
|
weekStartsOn={1}
|
|
54
63
|
selected={calendarRange}
|
|
@@ -60,7 +69,7 @@ export const Calendar = forwardRef<HTMLDivElement, Props>(
|
|
|
60
69
|
disabled: { opacity: '0.2' },
|
|
61
70
|
}}
|
|
62
71
|
captionLayout="dropdown-buttons"
|
|
63
|
-
defaultMonth={selectedStartDate ||
|
|
72
|
+
defaultMonth={selectedStartDate || disabledDays[0].from}
|
|
64
73
|
disabled={disabledDays}
|
|
65
74
|
fromMonth={today}
|
|
66
75
|
/>
|
|
@@ -3,6 +3,9 @@ import { AgeCategoryCount, AgeCategoryType } from '../FilterBarTypes'
|
|
|
3
3
|
type Props = {
|
|
4
4
|
ageCategoryCounts: AgeCategoryCount
|
|
5
5
|
ageCategories: AgeCategoryType[]
|
|
6
|
+
guestLabel: string
|
|
7
|
+
guestsLabel: string
|
|
8
|
+
guestsPlaceholder: string
|
|
6
9
|
}
|
|
7
10
|
|
|
8
11
|
type AccType = {
|
|
@@ -10,7 +13,13 @@ type AccType = {
|
|
|
10
13
|
html: string[]
|
|
11
14
|
}
|
|
12
15
|
|
|
13
|
-
export const parseGuests = ({
|
|
16
|
+
export const parseGuests = ({
|
|
17
|
+
guestLabel,
|
|
18
|
+
guestsLabel,
|
|
19
|
+
guestsPlaceholder,
|
|
20
|
+
ageCategoryCounts,
|
|
21
|
+
ageCategories,
|
|
22
|
+
}: Props) => {
|
|
14
23
|
const parsedData = Object.entries(ageCategoryCounts).reduce(
|
|
15
24
|
(acc: AccType, [key, value]) => {
|
|
16
25
|
const ageCategoryId = key[key.length - 1]
|
|
@@ -19,10 +28,7 @@ export const parseGuests = ({ ageCategoryCounts, ageCategories }: Props) => {
|
|
|
19
28
|
if (ageCategory && value) {
|
|
20
29
|
return {
|
|
21
30
|
total: acc.total + value,
|
|
22
|
-
html: [
|
|
23
|
-
...acc.html,
|
|
24
|
-
`<span style="display: inline-block; width: 21px, text-align: center">${value}</span>`,
|
|
25
|
-
],
|
|
31
|
+
html: [...acc.html, `${value}`],
|
|
26
32
|
}
|
|
27
33
|
}
|
|
28
34
|
|
|
@@ -34,8 +40,14 @@ export const parseGuests = ({ ageCategoryCounts, ageCategories }: Props) => {
|
|
|
34
40
|
const htmlString =
|
|
35
41
|
parsedData.html.length > 1 ? parsedData.html.join(' + ') : ''
|
|
36
42
|
|
|
37
|
-
return
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
return {
|
|
44
|
+
content: parsedData.total
|
|
45
|
+
? `<span style="display: inline-block; min-width: 10px">${
|
|
46
|
+
parsedData.total
|
|
47
|
+
}</span> ${parsedData.total > 1 ? guestsLabel : guestLabel}${
|
|
48
|
+
htmlString ? ` ( ${htmlString} )` : ''
|
|
49
|
+
}`
|
|
50
|
+
: guestsPlaceholder,
|
|
51
|
+
data: parsedData,
|
|
52
|
+
}
|
|
41
53
|
}
|