willba-component-library 0.1.32 → 0.1.33

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.1.32",
3
+ "version": "0.1.33",
4
4
  "description": "A stroybook 6 with TypeScript demo",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
@@ -88,6 +88,27 @@ export default function FilterBar({
88
88
  }
89
89
  }, [selectedFilter])
90
90
 
91
+ const renderDates =
92
+ calendarRange?.to && calendarRange?.from
93
+ ? `${format(calendarRange.from, 'dd.MM.yyyy')} -
94
+ ${format(calendarRange.to, 'dd.MM.yyyy')}`
95
+ : null
96
+
97
+ const renderGuests = Object.entries(ageCategoryCounts).reduce(
98
+ (acc, [key, value]) => {
99
+ const ageCategory = ageCategories.find(
100
+ (c) => c.id === key[key.length - 1]
101
+ )
102
+
103
+ if (ageCategory) {
104
+ acc += `${acc ? ' -' : ''} ${ageCategory.name}: ${value}`
105
+ }
106
+
107
+ return acc
108
+ },
109
+ ''
110
+ )
111
+
91
112
  return (
92
113
  <>
93
114
  {selectedFilter && (
@@ -104,7 +125,10 @@ export default function FilterBar({
104
125
  style={themePalette}
105
126
  >
106
127
  {!currentViewApply && (
107
- <div className="will-filter-bar-tabs" ref={targetFilterBarRef}>
128
+ <div
129
+ className="will-filter-bar-tabs"
130
+ ref={!currentViewApply ? targetFilterBarRef : null}
131
+ >
108
132
  <TabButton
109
133
  label={t('tabs.events')}
110
134
  onClick={() => setSelectedPath('/events')}
@@ -118,12 +142,24 @@ export default function FilterBar({
118
142
  </div>
119
143
  )}
120
144
 
121
- <div className="will-filter-bar-header">
145
+ <div
146
+ className="will-filter-bar-header"
147
+ ref={currentViewApply ? targetFilterBarRef : null}
148
+ >
122
149
  <SelectButton
123
150
  label={t('calendar.label')}
124
- description={t('calendar.labelPlaceholder')}
151
+ description={
152
+ renderDates
153
+ ? renderDates
154
+ : selectedPath === '/rooms'
155
+ ? t('calendar.roomsLabelPlaceholder')
156
+ : t('calendar.eventsLabelPlaceholder')
157
+ }
125
158
  onClick={() => handleSelectedFilter(1)}
126
159
  style={fontWeightBold(selectedFilter === 1)}
160
+ date={
161
+ calendarRange?.to ? format(calendarRange.to, 'dd.MM.yyyy') : null
162
+ }
127
163
  />
128
164
 
129
165
  {selectedPath === '/rooms' && (
@@ -132,7 +168,9 @@ export default function FilterBar({
132
168
 
133
169
  <SelectButton
134
170
  label={t('guests.label')}
135
- description={t('guests.labelPlaceholder')}
171
+ description={
172
+ renderGuests ? renderGuests : t('guests.labelPlaceholder')
173
+ }
136
174
  onClick={() => handleSelectedFilter(2)}
137
175
  style={fontWeightBold(selectedFilter === 2)}
138
176
  />
@@ -25,9 +25,12 @@
25
25
 
26
26
  @media (max-width: 960px) {
27
27
  .will-filter-bar-select-button {
28
- margin: 5px 0;
29
- padding: 10px 20px;
30
- }
28
+ padding: 15px 0;
29
+ }
30
+
31
+ .will-filter-bar-select-button:first-child {
32
+ padding: 0 0 15px 0;
33
+ }
31
34
 
32
35
  .will-filter-bar-select-button .select-button-wrapper {
33
36
  justify-content: center;
@@ -2,11 +2,17 @@ import React from 'react'
2
2
 
3
3
  import './SelectButton.css'
4
4
 
5
+ type Props = {
6
+ label: string
7
+ onClick: () => void
8
+ style: Object
9
+ description: string
10
+ }
11
+
5
12
  export default function SelectButton({
6
13
  label,
7
14
  onClick,
8
15
  style,
9
- date,
10
16
  description,
11
17
  }: any) {
12
18
  return (
@@ -20,13 +26,6 @@ export default function SelectButton({
20
26
  <p className="select-button-label">{label}</p>
21
27
  <p className="select-button-description">{description}</p>
22
28
  </div>
23
-
24
- {!!date && (
25
- <>
26
- <span className="select-button-divider">|</span>
27
- <span className="select-button-date"> {date}</span>
28
- </>
29
- )}
30
29
  </span>
31
30
  </button>
32
31
  )
@@ -22,6 +22,6 @@
22
22
  @media (max-width: 960px) {
23
23
  .will-filter-bar-submit-button {
24
24
  justify-content: center;
25
- margin-bottom: 5px;
25
+
26
26
  }
27
27
  }
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "calendar": {
3
3
  "label": "When",
4
- "labelPlaceholder": "Add check-in and check-out",
4
+ "roomsLabelPlaceholder": "Add check-in and check-out",
5
+ "eventsLabelPlaceholder": "Add search dates",
5
6
  "startDate": "Start date",
6
7
  "endDate": "End date",
7
8
  "title": "Calendar"
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "calendar": {
3
3
  "label": "Milloin",
4
- "labelPlaceholder": "Lisää check-in ja check-out",
4
+ "roomsLabelPlaceholder": "Lisää check-in ja check-out",
5
+ "eventsLabelPlaceholder": "Lisää aikaväli",
5
6
  "startDate": "Alku",
6
7
  "endDate": "Loppu",
7
8
  "title": "Kalenteri"