willba-component-library 0.1.21 → 0.1.22

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.
Files changed (28) hide show
  1. package/lib/components/FilterBar/FilterBarTypes.d.ts +2 -0
  2. package/lib/components/FilterBar/components/buttons/select-button/SelectButton.d.ts +1 -1
  3. package/lib/components/FilterBar/components/guests/GuestCount/GuestCount.d.ts +1 -1
  4. package/lib/index.d.ts +1 -0
  5. package/lib/index.esm.js +147 -144
  6. package/lib/index.esm.js.map +1 -1
  7. package/lib/index.js +147 -144
  8. package/lib/index.js.map +1 -1
  9. package/lib/index.umd.js +147 -144
  10. package/lib/index.umd.js.map +1 -1
  11. package/package.json +1 -1
  12. package/src/components/FilterBar/FilterBar.css +13 -14
  13. package/src/components/FilterBar/FilterBar.stories.tsx +15 -7
  14. package/src/components/FilterBar/FilterBar.tsx +12 -32
  15. package/src/components/FilterBar/FilterBarTypes.ts +2 -0
  16. package/src/components/FilterBar/components/buttons/close-button/CloseButton.css +2 -2
  17. package/src/components/FilterBar/components/buttons/select-button/SelectButton.css +9 -3
  18. package/src/components/FilterBar/components/buttons/select-button/SelectButton.tsx +11 -2
  19. package/src/components/FilterBar/components/buttons/submit-button/SubmitButton.css +1 -1
  20. package/src/components/FilterBar/components/buttons/tab-button/TabButton.css +9 -17
  21. package/src/components/FilterBar/components/calendar/Calendar.css +7 -3
  22. package/src/components/FilterBar/components/calendar/Calendar.tsx +19 -12
  23. package/src/components/FilterBar/components/divider/Divider.css +1 -2
  24. package/src/components/FilterBar/components/guests/GuestCount/GuestCount.css +13 -11
  25. package/src/components/FilterBar/components/guests/GuestCount/GuestCount.tsx +10 -5
  26. package/src/components/FilterBar/components/guests/Guests.css +8 -3
  27. package/src/components/FilterBar/components/guests/Guests.tsx +2 -5
  28. package/src/themes/Default.css +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "willba-component-library",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "A stroybook 6 with TypeScript demo",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
@@ -12,7 +12,7 @@
12
12
  }
13
13
 
14
14
  .will-filter-bar-underlay {
15
- background-color: rgba(0,0,0,.8);
15
+ background-color: transparent;
16
16
  position: absolute;
17
17
  /* top:0; */
18
18
  left: 0;
@@ -30,30 +30,30 @@
30
30
  .will-filter-bar-tabs {
31
31
  display: flex;
32
32
  align-items: center;
33
- width: fit-content;
33
+ justify-content: center;
34
34
  position: relative;
35
35
  z-index: 222;
36
+ background: transparent;
37
+ padding: 10px;
38
+ gap: 10px
36
39
  }
37
40
 
38
41
  /* Header */
39
42
  .will-filter-bar-header {
40
43
  display: flex;
41
44
  justify-content: space-between;
42
- padding: 10px 20px;
45
+ padding: 10px;
43
46
  position: relative;
44
47
  z-index: 222;
45
-
46
-
47
48
  border-radius: 40px;
48
- border-top-left-radius: 0;
49
- background-color: var(--will-white);
50
-
49
+ background-color: var(--will-white);
51
50
  }
52
51
 
53
52
  @media (max-width: 960px) {
54
53
  .will-filter-bar-header {
55
54
  flex-direction: column;
56
55
  padding: 20px;
56
+ border-radius: 25px;
57
57
  }
58
58
  }
59
59
 
@@ -62,13 +62,11 @@
62
62
  .will-filter-bar-container {
63
63
  background-color: var(--will-white);
64
64
  min-height: 100px;
65
-
66
- padding: 90px 40px 30px 40px;
65
+ padding: 40px 20px ;
67
66
  position: absolute;
68
- top: 45px;
67
+ top: 125px;
69
68
  z-index: 111;
70
69
  border-radius: 25px;
71
- width: -webkit-fill-available;
72
70
  box-shadow: var(--will-box-shadow);
73
71
  }
74
72
 
@@ -81,8 +79,9 @@
81
79
  }
82
80
 
83
81
  .will-filter-bar-container {
84
- margin-top: 20px;
85
- padding: 30px 40px;
82
+ margin-top: 10px;
83
+ top:0;
84
+ padding: 30px 20px;
86
85
  position: relative;
87
86
  }
88
87
 
@@ -1,7 +1,8 @@
1
+ import React from 'react'
1
2
  import type { Meta, StoryObj } from '@storybook/react'
3
+
2
4
  import FilterBar from './FilterBar'
3
5
 
4
- // Default metadata of the story https://storybook.js.org/docs/react/api/csf#default-export
5
6
  const meta: Meta<typeof FilterBar> = {
6
7
  title: 'Components/FilterBar',
7
8
  component: FilterBar,
@@ -9,7 +10,6 @@ const meta: Meta<typeof FilterBar> = {
9
10
 
10
11
  export default meta
11
12
 
12
- // The story type for the component https://storybook.js.org/docs/react/api/csf#named-story-exports
13
13
  type Story = StoryObj<typeof FilterBar>
14
14
 
15
15
  export const Primary: Story = {
@@ -18,25 +18,28 @@ export const Primary: Story = {
18
18
  redirectUrl: '',
19
19
  ageCategories: [
20
20
  {
21
- id: '1',
21
+ id: '2',
22
22
  name: 'Alle 6 vuotiaat',
23
23
  minAge: null,
24
24
  maxAge: 6,
25
- minVal: 1,
25
+ minVal: 0,
26
+ sortOrder: 3,
26
27
  },
27
28
  {
28
- id: '2',
29
+ id: '3',
29
30
  name: '6-16 vuotiaat',
30
31
  minAge: 6,
31
32
  maxAge: 17,
32
33
  minVal: 0,
34
+ sortOrder: 2,
33
35
  },
34
36
  {
35
- id: '3',
37
+ id: '1',
36
38
  name: 'Aikuiset',
37
39
  minAge: 17,
38
40
  maxAge: null,
39
- minVal: 0,
41
+ minVal: 2,
42
+ sortOrder: 1,
40
43
  },
41
44
  ],
42
45
  palette: {
@@ -44,4 +47,9 @@ export const Primary: Story = {
44
47
  secondary: '',
45
48
  },
46
49
  },
50
+ render: (args) => (
51
+ <div style={{ background: 'grey', padding: '30px', height: '100vh' }}>
52
+ <FilterBar {...args} />
53
+ </div>
54
+ ),
47
55
  }
@@ -104,42 +104,20 @@ export default function FilterBar({
104
104
 
105
105
  <div className="will-filter-bar-header">
106
106
  <SelectButton
107
- style={fontWeightBold(selectedFilter === 1 || selectedFilter === 2)}
108
- label={t('calendar.startDate')}
107
+ label={'When'}
108
+ description={'Add Check-in and -out'}
109
109
  onClick={() => handleSelectedFilter(1)}
110
- date={
111
- calendarRange?.from
112
- ? format(calendarRange.from, 'dd.MM.yyyy')
113
- : null
114
- }
110
+ style={fontWeightBold(selectedFilter === 1)}
115
111
  />
116
112
 
117
113
  <Divider />
118
-
119
114
  <SelectButton
120
- style={fontWeightBold(selectedFilter === 1 || selectedFilter === 2)}
121
- label={t('calendar.endDate')}
115
+ label={'Who'}
116
+ description={'Add Guests'}
122
117
  onClick={() => handleSelectedFilter(2)}
123
- date={
124
- calendarRange?.to ? format(calendarRange.to, 'dd.MM.yyyy') : null
125
- }
118
+ style={fontWeightBold(selectedFilter === 2)}
126
119
  />
127
120
 
128
- {/* TODO - Add strapi settings to show or hide filter sections */}
129
- {/* <Divider />
130
- <SelectButton
131
- label={t('guests.label')}
132
- onClick={() => handleSelectedFilter(3)}
133
- style={fontWeightBold(selectedFilter === 3)}
134
- /> */}
135
-
136
- {/* <Divider />
137
- <SelectButton
138
- label={t('categories.label')}
139
- onClick={() => handleSelectedFilter(4)}
140
- style={fontWeightBold(selectedFilter === 4)}
141
- /> */}
142
-
143
121
  <SubmitButton onClick={handleSubmit} />
144
122
  </div>
145
123
 
@@ -147,20 +125,20 @@ export default function FilterBar({
147
125
  <div className="will-filter-bar-container">
148
126
  <CloseButton handleClose={() => handleSelectedFilter(false)} />
149
127
 
150
- {(selectedFilter === 1 || selectedFilter === 2) && (
128
+ {selectedFilter === 1 && (
151
129
  <Calendar
152
130
  calendarRange={calendarRange}
153
131
  setCalendarRange={setCalendarRange}
154
132
  />
155
133
  )}
156
- {selectedFilter === 3 && (
134
+ {selectedFilter === 2 && (
157
135
  <Guests
158
136
  updateGuestsCount={updateGuestsCount}
159
137
  ageCategories={ageCategories}
160
138
  ageCategoryCounts={ageCategoryCounts}
161
139
  />
162
140
  )}
163
- {selectedFilter === 4 && (
141
+ {selectedFilter === 3 && (
164
142
  <Categories
165
143
  categories={categories}
166
144
  setCategories={setCategories}
@@ -183,13 +161,15 @@ const AGE_CATEGORIES_FALLBACK = [
183
161
  {
184
162
  id: '1',
185
163
  name: 'Adults',
164
+ sortOrder: 1,
186
165
  minAge: null,
187
166
  maxAge: 6,
188
- minVal: 1,
167
+ minVal: 0,
189
168
  },
190
169
  {
191
170
  id: '2',
192
171
  name: 'Kids',
172
+ sortOrder: 2,
193
173
  minAge: 6,
194
174
  maxAge: 17,
195
175
  minVal: 0,
@@ -8,6 +8,7 @@ export interface AgeCategoryType {
8
8
  minAge: number | null
9
9
  maxAge: number | null
10
10
  minVal: number
11
+ sortOrder: number
11
12
  }
12
13
 
13
14
  export interface GuestsPropsType {
@@ -22,4 +23,5 @@ export interface GuestsCountPropsType {
22
23
  updateGuestsCount: (arg1: number, arg2: number) => void
23
24
  count: number
24
25
  minVal: number
26
+ sortOrder: number
25
27
  }
@@ -13,8 +13,8 @@
13
13
  /* display: none; */
14
14
 
15
15
  position: absolute;
16
- top: 80px;
17
- right: 20px;
16
+ top: 10px;
17
+ right: 10px;
18
18
 
19
19
  min-height: 35px;
20
20
  }
@@ -3,13 +3,18 @@
3
3
  height: auto;
4
4
  background-color: transparent;
5
5
  border: none;
6
- padding: 10px 20px;
6
+ padding: 0 20px;
7
7
  border-radius: 20px;
8
8
  cursor: pointer;
9
- font-size: 15px;
9
+ font-size: 14px;
10
10
  text-align: initial;
11
11
  }
12
12
 
13
+ .will-filter-bar-select-button .select-button-description {
14
+ font-weight: 400;
15
+ opacity: 0.4;
16
+ }
17
+
13
18
  .will-filter-bar-select-button .select-button-wrapper {
14
19
  display: flex;
15
20
  align-items: center;
@@ -20,7 +25,8 @@
20
25
 
21
26
  @media (max-width: 960px) {
22
27
  .will-filter-bar-select-button {
23
- margin: 15px 0;
28
+ margin: 5px 0;
29
+ padding: 10px 20px;
24
30
  }
25
31
 
26
32
  .will-filter-bar-select-button .select-button-wrapper {
@@ -2,7 +2,13 @@ import React from 'react'
2
2
 
3
3
  import './SelectButton.css'
4
4
 
5
- export default function SelectButton({ label, onClick, style, date }: any) {
5
+ export default function SelectButton({
6
+ label,
7
+ onClick,
8
+ style,
9
+ date,
10
+ description,
11
+ }: any) {
6
12
  return (
7
13
  <button
8
14
  className="will-filter-bar-select-button"
@@ -10,7 +16,10 @@ export default function SelectButton({ label, onClick, style, date }: any) {
10
16
  style={style}
11
17
  >
12
18
  <span className="select-button-wrapper">
13
- <span className="select-button-label">{label}</span>
19
+ <div>
20
+ <p className="select-button-label">{label}</p>
21
+ <p className="select-button-description">{description}</p>
22
+ </div>
14
23
 
15
24
  {!!date && (
16
25
  <>
@@ -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: 15px;
25
+ margin-bottom: 5px;
26
26
  }
27
27
  }
@@ -1,39 +1,31 @@
1
1
  .will-filter-bar-tab-button {
2
2
  width: auto;
3
3
  height: auto;
4
- padding: 10px 50px;
4
+ padding: 10px 20px;
5
5
  cursor: pointer;
6
6
  border: none;
7
7
  white-space: nowrap;
8
- text-transform: uppercase;
9
- font-size: 12px;
8
+ font-size: 16px;
10
9
  display: flex;
11
10
  align-items: center;
12
- border: 1px solid var(--will-black);
13
- border-top: none;
14
- background-color: var(--will-transparent-white);
11
+ background-color: transparent;
15
12
  user-select: none;
16
13
  font-weight: 600;
14
+ border-radius: 50px;
15
+ color: var(--will-white)
17
16
  }
18
17
 
19
- /* .will-filter-bar-tab-button:not(:first-child) {
20
- border-left: none;
21
- } */
22
-
18
+
23
19
  .will-filter-bar-tab-button:hover {
24
- background-color: var(--will-white);
20
+ background-color: var(--will-transparent-white);
25
21
  }
26
22
 
27
23
  .will-filter-bar-tab-button.active {
28
- background-color: var(--will-white);
29
- border-color: var(--will-white);
24
+ background-color: var(--will-transparent-white);
25
+
30
26
  }
31
27
 
32
28
 
33
-
34
-
35
-
36
-
37
29
  /* @media (max-width: 960px) {
38
30
  .will-filter-bar-tab-button {
39
31
  justify-content: center;
@@ -1,5 +1,3 @@
1
- /* .will-filter-bar-calendar {} */
2
-
3
1
  .will-calendar-filter-header {
4
2
  padding: 15px 0;
5
3
  border-bottom: 1px solid var(--will-grey);
@@ -15,11 +13,11 @@
15
13
  .will-calendar-filter-container {
16
14
  display: flex;
17
15
  justify-content: center;
18
- padding-top: 20px;
19
16
  }
20
17
 
21
18
  /* Calendar overrides */
22
19
 
20
+
23
21
  .will-calendar-filter-container .DayPicker {
24
22
  font-size: 25px; /* Adjust this value to make the DayPicker bigger */
25
23
  }
@@ -65,6 +63,12 @@
65
63
  opacity: 1;
66
64
  }
67
65
 
66
+ .my-today:not(.rdp-day_selected) {
67
+ font-weight: 700;
68
+ opacity: 1;
69
+ color: var(--will-primary);
70
+ }
71
+
68
72
  @media (max-width: 960px) {
69
73
  .will-calendar-filter-container .rdp-month .rdp-nav {
70
74
  border: none;
@@ -1,7 +1,6 @@
1
1
  import React, { useEffect } from 'react'
2
- //import { useTranslation } from 'react-i18next'
3
2
  import { DateRange, DayPicker } from 'react-day-picker'
4
- import { addDays } from 'date-fns'
3
+ import { addDays, startOfDay, addMonths } from 'date-fns'
5
4
  import { useMediaQuery } from 'react-responsive'
6
5
 
7
6
  import 'react-day-picker/dist/style.css'
@@ -12,21 +11,20 @@ interface CalendarPropsType {
12
11
  setCalendarRange: (range: DateRange | undefined) => void
13
12
  }
14
13
 
15
- const currentMonth = new Date()
16
-
17
14
  export default function Calendar({
18
15
  calendarRange,
19
16
  setCalendarRange,
20
17
  }: CalendarPropsType) {
21
- //const { t } = useTranslation('filterBar')
22
18
  const isTablet = useMediaQuery({ maxWidth: 960 })
23
19
 
24
- // Add default selection
25
- // const defaultCalendarSelected: DateRange = {
26
- // from: currentMonth,
27
- // to: addDays(currentMonth, 0),
28
- // }
29
- //--------------//----------------
20
+ const today = startOfDay(new Date())
21
+
22
+ const disabledDays = [
23
+ {
24
+ from: addDays(today, -2),
25
+ to: addDays(today, -50),
26
+ },
27
+ ]
30
28
 
31
29
  useEffect(() => {
32
30
  if (!calendarRange) setCalendarRange(undefined)
@@ -44,9 +42,18 @@ export default function Calendar({
44
42
  showOutsideDays
45
43
  numberOfMonths={!isTablet ? 2 : 1}
46
44
  weekStartsOn={1}
47
- defaultMonth={currentMonth}
48
45
  selected={calendarRange}
49
46
  onSelect={setCalendarRange}
47
+ modifiersClassNames={{
48
+ today: 'my-today',
49
+ }}
50
+ modifiersStyles={{
51
+ disabled: { opacity: '0.2' },
52
+ }}
53
+ captionLayout="dropdown-buttons"
54
+ defaultMonth={today}
55
+ disabled={disabledDays}
56
+ fromMonth={today}
50
57
  />
51
58
  </div>
52
59
  </div>
@@ -1,13 +1,12 @@
1
1
  .will-filter-bar-divider {
2
2
  width: 1px;
3
3
  margin: 0 10px;
4
- height: 35px;
5
4
  background-color: #384265;
6
5
  }
7
6
 
8
7
  @media (max-width: 960px) {
9
8
  .will-filter-bar-divider {
10
- width: 100%;
9
+ width: auto;
11
10
  margin: 0 10px;
12
11
  height: 1px;
13
12
  background-color: #384265;
@@ -6,21 +6,18 @@
6
6
  .will-guests-filter-inner {
7
7
  display: flex;
8
8
  align-items: center;
9
- }
10
-
11
- .will-guests-filter-inner {
9
+ justify-content: space-between;
12
10
  margin-top: 30px;
13
- margin-right: 50px;
14
11
  }
15
12
 
16
13
  .will-guests-filter-label {
17
14
  display: block;
18
- margin-right: 20px;
19
- font-weight: bold;
15
+ font-weight: 600;
16
+ margin-bottom: 10px;
20
17
 
21
18
  }
22
19
 
23
- .will-guests-filter-inner > div {
20
+ .will-guests-filter-inner .will-guests-filter-counter {
24
21
  display: flex;
25
22
  align-items: center;
26
23
  }
@@ -31,12 +28,13 @@
31
28
  text-align: center;
32
29
  }
33
30
 
34
- .will-guests-filter-button {
31
+ .will-guests-filter-counter-button {
35
32
  border-radius: 50%;
36
33
  border: none;
37
- background-color: var(--will-onahau);
38
- width: 25px;
39
- height: 25px;
34
+ background-color: transparent;
35
+ border: 1px solid var(--will-grey);
36
+ width: 30px;
37
+ height: 30px;
40
38
  display: flex;
41
39
  justify-content: center;
42
40
  align-items: center;
@@ -44,6 +42,10 @@
44
42
  cursor: pointer;
45
43
  }
46
44
 
45
+ .will-guests-filter-counter-button:hover {
46
+ background-color: var(--will-onahau);
47
+ }
48
+
47
49
  @media (max-width: 960px) {
48
50
 
49
51
  .will-guests-filter-inner {
@@ -6,6 +6,7 @@ import './GuestCount.css'
6
6
 
7
7
  export default function GuestCount({
8
8
  label,
9
+ sortOrder,
9
10
  id,
10
11
  updateGuestsCount,
11
12
  count,
@@ -22,11 +23,12 @@ export default function GuestCount({
22
23
  }
23
24
 
24
25
  return (
25
- <div className="will-guests-filter-inner">
26
- <span className="will-guests-filter-label">{label}</span>
27
- <div>
26
+ <div className="will-guests-filter-inner" style={{ order: `${sortOrder}` }}>
27
+ <p className="will-guests-filter-label">{label}</p>
28
+
29
+ <div className="will-guests-filter-counter">
28
30
  <button
29
- className="will-guests-filter-button"
31
+ className="will-guests-filter-counter-button"
30
32
  onClick={handleDecrement}
31
33
  disabled={minVal && count < 2 ? true : false}
32
34
  style={{
@@ -42,7 +44,10 @@ export default function GuestCount({
42
44
  -
43
45
  </button>
44
46
  <span className="will-guests-filter-count">{count}</span>
45
- <button className="will-guests-filter-button" onClick={handleIncrement}>
47
+ <button
48
+ className="will-guests-filter-counter-button"
49
+ onClick={handleIncrement}
50
+ >
46
51
  +
47
52
  </button>
48
53
  </div>
@@ -3,8 +3,7 @@
3
3
  }
4
4
 
5
5
  .will-guests-filter-title {
6
- font-size: 16px;
7
- text-transform: uppercase;
6
+ font-size: 22px;
8
7
  margin: 10px 0;
9
8
  }
10
9
 
@@ -17,11 +16,17 @@
17
16
 
18
17
  .will-guests-filter-container {
19
18
  display: flex;
20
- flex-wrap: wrap;
19
+ flex-direction: column;
20
+ min-width: 300px;
21
+
21
22
  }
22
23
 
23
24
 
24
25
  @media (max-width: 960px) {
26
+ .will-guests-filter-title {
27
+ font-size: 18px;
28
+ }
29
+
25
30
  .will-guests-filter-container {
26
31
  margin-top: 15px;
27
32
  }
@@ -1,5 +1,4 @@
1
1
  import React from 'react'
2
- import { useTranslation } from 'react-i18next'
3
2
 
4
3
  import GuestCount from './GuestCount/GuestCount'
5
4
  import { AgeCategoryCount, GuestsPropsType } from '../../FilterBarTypes'
@@ -11,12 +10,9 @@ export default function Guests({
11
10
  updateGuestsCount,
12
11
  ageCategoryCounts,
13
12
  }: GuestsPropsType) {
14
- const { t } = useTranslation('filterBar')
15
-
16
13
  return (
17
14
  <div className="will-filter-bar-guests">
18
- <h3 className="will-guests-filter-title">{t('guests.title')}</h3>
19
- <p className="will-guests-filter-subtitle">{t('guests.subtitle')}</p>
15
+ <h3 className="will-guests-filter-title">Who's coming?</h3>
20
16
 
21
17
  <div className="will-guests-filter-container">
22
18
  {ageCategories?.map((category) => (
@@ -25,6 +21,7 @@ export default function Guests({
25
21
  id={parseInt(category.id)}
26
22
  label={category.name}
27
23
  minVal={category.minVal}
24
+ sortOrder={category.sortOrder}
28
25
  updateGuestsCount={updateGuestsCount}
29
26
  count={
30
27
  (ageCategoryCounts as AgeCategoryCount)[category.id] ||
@@ -19,7 +19,7 @@
19
19
  --will-black: #000;
20
20
  --will-onahau: #CDEEFF;
21
21
  --will-text: #5A5959;
22
- --will-transparent-white: rgba(255, 255, 255, 0.8);
22
+ --will-transparent-white: rgba(255, 255, 255, 0.30);
23
23
 
24
24
  /* Confines */
25
25
  --will-box-shadow: 0px 6px 11px 0px #a7a4a480;