willba-component-library 0.1.3 → 0.1.5

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 (31) hide show
  1. package/README.md +57 -57
  2. package/lib/index.esm.js +9 -9
  3. package/lib/index.esm.js.map +1 -1
  4. package/lib/index.js +9 -9
  5. package/lib/index.js.map +1 -1
  6. package/lib/index.umd.js +9 -9
  7. package/lib/index.umd.js.map +1 -1
  8. package/package.json +51 -51
  9. package/src/components/FilterBar/FilterBarTypes.ts +25 -25
  10. package/src/components/FilterBar/components/calendar/Calendar.css +76 -76
  11. package/src/components/FilterBar/components/calendar/Calendar.tsx +54 -54
  12. package/src/components/FilterBar/components/categories/Categories.css +21 -21
  13. package/src/components/FilterBar/components/categories/Categories.tsx +41 -41
  14. package/src/components/FilterBar/components/close-button/CloseButton.css +26 -26
  15. package/src/components/FilterBar/components/close-button/CloseButton.tsx +16 -16
  16. package/src/components/FilterBar/components/divider/Divider.css +14 -14
  17. package/src/components/FilterBar/components/divider/Divider.tsx +7 -7
  18. package/src/components/FilterBar/components/guests/GuestCount/GuestCount.css +53 -53
  19. package/src/components/FilterBar/components/guests/GuestCount/GuestCount.tsx +51 -51
  20. package/src/components/FilterBar/components/guests/Guests.css +27 -27
  21. package/src/components/FilterBar/components/guests/Guests.tsx +38 -38
  22. package/src/components/FilterBar/components/select-button/SelectButton.css +20 -20
  23. package/src/components/FilterBar/components/select-button/SelectButton.tsx +15 -15
  24. package/src/components/FilterBar/components/submit-button/SubmitButton.css +27 -27
  25. package/src/components/FilterBar/components/submit-button/SubmitButton.tsx +18 -18
  26. package/src/components/FilterBar/hooks/useFilterBar.tsx +106 -106
  27. package/src/i18n.ts +25 -25
  28. package/src/locales/en/filterBar.json +20 -20
  29. package/src/locales/fi/filterBar.json +20 -20
  30. package/src/themes/Default.css +51 -51
  31. package/src/themes/useTheme.tsx +14 -14
package/package.json CHANGED
@@ -1,51 +1,51 @@
1
- {
2
- "name": "willba-component-library",
3
- "version": "0.1.3",
4
- "description": "A stroybook 6 with TypeScript demo",
5
- "main": "lib/index.js",
6
- "module": "lib/index.esm.js",
7
- "types": "lib/index.d.ts",
8
- "scripts": {
9
- "test": "echo \"Error: no test specified\" && exit 1",
10
- "storybook": "storybook dev -p 6006",
11
- "build-storybook": "storybook build",
12
- "build": "rollup -c"
13
- },
14
- "author": "Willba",
15
- "license": "MIT",
16
- "dependencies": {
17
- "@rollup/plugin-json": "^6.0.0",
18
- "classnames": "^2.3.2",
19
- "react-day-picker": "^8.8.0",
20
- "react-i18next": "^13.1.2",
21
- "react-icons": "^4.10.1",
22
- "react-responsive": "^9.0.2"
23
- },
24
- "peerDependencies": {
25
- "react": "^17.0.2",
26
- "react-dom": "^17.0.2"
27
- },
28
- "devDependencies": {
29
- "@rollup/plugin-commonjs": "^25.0.3",
30
- "@rollup/plugin-node-resolve": "^15.1.0",
31
- "@rollup/plugin-typescript": "^11.1.2",
32
- "@storybook/addon-essentials": "^7.2.1",
33
- "@storybook/addon-interactions": "^7.2.1",
34
- "@storybook/addon-links": "^7.2.1",
35
- "@storybook/addon-onboarding": "^1.0.8",
36
- "@storybook/blocks": "^7.2.1",
37
- "@storybook/react": "^7.2.1",
38
- "@storybook/react-vite": "^7.2.1",
39
- "@storybook/testing-library": "^0.2.0",
40
- "@types/react": "^18.2.19",
41
- "postcss": "^8.4.27",
42
- "react": "^17.0.2",
43
- "react-dom": "^17.0.2",
44
- "rollup": "^3.28.0",
45
- "rollup-plugin-dts": "^5.3.1",
46
- "rollup-plugin-peer-deps-external": "^2.2.4",
47
- "rollup-plugin-postcss": "^4.0.2",
48
- "storybook": "^7.2.1",
49
- "typescript": "^5.1.6"
50
- }
51
- }
1
+ {
2
+ "name": "willba-component-library",
3
+ "version": "0.1.5",
4
+ "description": "A stroybook 6 with TypeScript demo",
5
+ "main": "lib/index.js",
6
+ "module": "lib/index.esm.js",
7
+ "types": "lib/index.d.ts",
8
+ "scripts": {
9
+ "test": "echo \"Error: no test specified\" && exit 1",
10
+ "storybook": "storybook dev -p 6006",
11
+ "build-storybook": "storybook build",
12
+ "build": "rollup -c"
13
+ },
14
+ "author": "Willba",
15
+ "license": "MIT",
16
+ "dependencies": {
17
+ "@rollup/plugin-json": "^6.0.0",
18
+ "classnames": "^2.3.2",
19
+ "react-day-picker": "^8.8.0",
20
+ "react-i18next": "^13.1.2",
21
+ "react-icons": "^4.10.1",
22
+ "react-responsive": "^9.0.2"
23
+ },
24
+ "peerDependencies": {
25
+ "react": "^18.2.0",
26
+ "react-dom": "^18.2.0"
27
+ },
28
+ "devDependencies": {
29
+ "@rollup/plugin-commonjs": "^25.0.3",
30
+ "@rollup/plugin-node-resolve": "^15.1.0",
31
+ "@rollup/plugin-typescript": "^11.1.2",
32
+ "@storybook/addon-essentials": "^7.2.1",
33
+ "@storybook/addon-interactions": "^7.2.1",
34
+ "@storybook/addon-links": "^7.2.1",
35
+ "@storybook/addon-onboarding": "^1.0.8",
36
+ "@storybook/blocks": "^7.2.1",
37
+ "@storybook/react": "^7.2.1",
38
+ "@storybook/react-vite": "^7.2.1",
39
+ "@storybook/testing-library": "^0.2.0",
40
+ "@types/react": "^18.2.19",
41
+ "postcss": "^8.4.27",
42
+ "react": "^18.2.0",
43
+ "react-dom": "^18.2.0",
44
+ "rollup": "^3.28.0",
45
+ "rollup-plugin-dts": "^5.3.1",
46
+ "rollup-plugin-peer-deps-external": "^2.2.4",
47
+ "rollup-plugin-postcss": "^4.0.2",
48
+ "storybook": "^7.2.1",
49
+ "typescript": "^5.1.6"
50
+ }
51
+ }
@@ -1,25 +1,25 @@
1
- export interface AgeCategoryCount {
2
- [categoryId: string]: number
3
- }
4
-
5
- export interface AgeCategoryType {
6
- id: string
7
- name: string
8
- minAge: number | null
9
- maxAge: number | null
10
- minVal: number
11
- }
12
-
13
- export interface GuestsPropsType {
14
- ageCategories: AgeCategoryType[]
15
- updateGuestsCount: (arg1: number, arg2: number) => void
16
- ageCategoryCounts: AgeCategoryCount | {}
17
- }
18
-
19
- export interface GuestsCountPropsType {
20
- label: string
21
- id: number
22
- updateGuestsCount: (arg1: number, arg2: number) => void
23
- count: number
24
- minVal: number
25
- }
1
+ export interface AgeCategoryCount {
2
+ [categoryId: string]: number
3
+ }
4
+
5
+ export interface AgeCategoryType {
6
+ id: string
7
+ name: string
8
+ minAge: number | null
9
+ maxAge: number | null
10
+ minVal: number
11
+ }
12
+
13
+ export interface GuestsPropsType {
14
+ ageCategories: AgeCategoryType[]
15
+ updateGuestsCount: (arg1: number, arg2: number) => void
16
+ ageCategoryCounts: AgeCategoryCount | {}
17
+ }
18
+
19
+ export interface GuestsCountPropsType {
20
+ label: string
21
+ id: number
22
+ updateGuestsCount: (arg1: number, arg2: number) => void
23
+ count: number
24
+ minVal: number
25
+ }
@@ -1,76 +1,76 @@
1
- /* .will-filter-bar-calendar {} */
2
-
3
- .will-calendar-filter-header {
4
- padding: 15px 0;
5
- border-bottom: 1px solid var(--will-grey);
6
- }
7
-
8
- .will-calendar-filter-title {
9
- font-size: 16px;
10
- text-transform: uppercase;
11
- margin: 10px 0;
12
- text-align: left;
13
- }
14
-
15
- .will-calendar-filter-container {
16
- display: flex;
17
- justify-content: center;
18
- padding-top: 20px;
19
- }
20
-
21
- /* Calendar overrides */
22
-
23
- .will-calendar-filter-container .DayPicker {
24
- font-size: 25px; /* Adjust this value to make the DayPicker bigger */
25
- }
26
-
27
- .will-calendar-filter-container .rdp-month {
28
- position: relative;
29
- }
30
-
31
- .will-calendar-filter-container .rdp-month.rdp-caption_start {
32
- padding-left: 70px;
33
- }
34
-
35
- .will-calendar-filter-container .rdp-month.rdp-caption_end {
36
- padding-right: 70px;
37
- }
38
-
39
- .will-calendar-filter-container .rdp-month .rdp-nav {
40
- border: 1px solid var(--will-primary);
41
- border-radius: 50%;
42
- left: 25;
43
- }
44
-
45
- .will-calendar-filter-container .rdp-month .rdp-nav svg {
46
- color: var(--will-primary);
47
- }
48
-
49
-
50
- .will-calendar-filter-container .rdp-month .rdp-caption {
51
- position: initial;
52
- }
53
-
54
- .will-calendar-filter-container .rdp-month .rdp-caption > .rdp-caption_label,
55
- .will-calendar-filter-container .rdp-table .rdp-head {
56
- opacity: .6;
57
- }
58
-
59
- .will-calendar-filter-container .rdp-button_reset.rdp-button.rdp-day {
60
- opacity: 0.7;
61
- }
62
-
63
- .will-calendar-filter-container .rdp-button_reset.rdp-button.rdp-day.rdp-day_selected {
64
- background-color: var(--will-primary);
65
- opacity: 1;
66
- }
67
-
68
- @media (max-width: 960px) {
69
- .will-calendar-filter-container .rdp-month .rdp-nav {
70
- border: none;
71
- border-radius: initial;
72
-
73
- }
74
- }
75
-
76
-
1
+ /* .will-filter-bar-calendar {} */
2
+
3
+ .will-calendar-filter-header {
4
+ padding: 15px 0;
5
+ border-bottom: 1px solid var(--will-grey);
6
+ }
7
+
8
+ .will-calendar-filter-title {
9
+ font-size: 16px;
10
+ text-transform: uppercase;
11
+ margin: 10px 0;
12
+ text-align: left;
13
+ }
14
+
15
+ .will-calendar-filter-container {
16
+ display: flex;
17
+ justify-content: center;
18
+ padding-top: 20px;
19
+ }
20
+
21
+ /* Calendar overrides */
22
+
23
+ .will-calendar-filter-container .DayPicker {
24
+ font-size: 25px; /* Adjust this value to make the DayPicker bigger */
25
+ }
26
+
27
+ .will-calendar-filter-container .rdp-month {
28
+ position: relative;
29
+ }
30
+
31
+ .will-calendar-filter-container .rdp-month.rdp-caption_start {
32
+ padding-left: 70px;
33
+ }
34
+
35
+ .will-calendar-filter-container .rdp-month.rdp-caption_end {
36
+ padding-right: 70px;
37
+ }
38
+
39
+ .will-calendar-filter-container .rdp-month .rdp-nav {
40
+ border: 1px solid var(--will-primary);
41
+ border-radius: 50%;
42
+ left: 25;
43
+ }
44
+
45
+ .will-calendar-filter-container .rdp-month .rdp-nav svg {
46
+ color: var(--will-primary);
47
+ }
48
+
49
+
50
+ .will-calendar-filter-container .rdp-month .rdp-caption {
51
+ position: initial;
52
+ }
53
+
54
+ .will-calendar-filter-container .rdp-month .rdp-caption > .rdp-caption_label,
55
+ .will-calendar-filter-container .rdp-table .rdp-head {
56
+ opacity: .6;
57
+ }
58
+
59
+ .will-calendar-filter-container .rdp-button_reset.rdp-button.rdp-day {
60
+ opacity: 0.7;
61
+ }
62
+
63
+ .will-calendar-filter-container .rdp-button_reset.rdp-button.rdp-day.rdp-day_selected {
64
+ background-color: var(--will-primary);
65
+ opacity: 1;
66
+ }
67
+
68
+ @media (max-width: 960px) {
69
+ .will-calendar-filter-container .rdp-month .rdp-nav {
70
+ border: none;
71
+ border-radius: initial;
72
+
73
+ }
74
+ }
75
+
76
+
@@ -1,54 +1,54 @@
1
- import React, { useEffect } from 'react'
2
- import { useTranslation } from 'react-i18next'
3
- import { DateRange, DayPicker } from 'react-day-picker'
4
- import { addDays } from 'date-fns'
5
- import { useMediaQuery } from 'react-responsive'
6
-
7
- import 'react-day-picker/dist/style.css'
8
- import './Calendar.css'
9
-
10
- interface CalendarPropsType {
11
- calendarRange: DateRange | undefined
12
- setCalendarRange: (range: DateRange | undefined) => void
13
- }
14
-
15
- const currentMonth = new Date()
16
-
17
- export default function Calendar({
18
- calendarRange,
19
- setCalendarRange,
20
- }: CalendarPropsType) {
21
- const { t } = useTranslation('filterBar')
22
- const isTablet = useMediaQuery({ maxWidth: 960 })
23
-
24
- const defaultCalendarSelected: DateRange = {
25
- from: currentMonth,
26
- to: addDays(currentMonth, 0),
27
- }
28
-
29
- useEffect(() => {
30
- if (!calendarRange) setCalendarRange(defaultCalendarSelected)
31
- }, [])
32
-
33
- return (
34
- <div className="will-filter-bar-calendar">
35
- <div className="will-calendar-filter-header">
36
- <h3 className="will-calendar-filter-title">{t('calendar.title')}</h3>
37
- </div>
38
- <div className="will-calendar-filter-container">
39
- <DayPicker
40
- id="will-calendar"
41
- mode="range"
42
- showOutsideDays
43
- fixedWeeks
44
- numberOfMonths={!isTablet ? 2 : 1}
45
- weekStartsOn={1}
46
- max={31}
47
- defaultMonth={currentMonth}
48
- selected={calendarRange}
49
- onSelect={setCalendarRange}
50
- />
51
- </div>
52
- </div>
53
- )
54
- }
1
+ import React, { useEffect } from 'react'
2
+ import { useTranslation } from 'react-i18next'
3
+ import { DateRange, DayPicker } from 'react-day-picker'
4
+ import { addDays } from 'date-fns'
5
+ import { useMediaQuery } from 'react-responsive'
6
+
7
+ import 'react-day-picker/dist/style.css'
8
+ import './Calendar.css'
9
+
10
+ interface CalendarPropsType {
11
+ calendarRange: DateRange | undefined
12
+ setCalendarRange: (range: DateRange | undefined) => void
13
+ }
14
+
15
+ const currentMonth = new Date()
16
+
17
+ export default function Calendar({
18
+ calendarRange,
19
+ setCalendarRange,
20
+ }: CalendarPropsType) {
21
+ const { t } = useTranslation('filterBar')
22
+ const isTablet = useMediaQuery({ maxWidth: 960 })
23
+
24
+ const defaultCalendarSelected: DateRange = {
25
+ from: currentMonth,
26
+ to: addDays(currentMonth, 0),
27
+ }
28
+
29
+ useEffect(() => {
30
+ if (!calendarRange) setCalendarRange(defaultCalendarSelected)
31
+ }, [])
32
+
33
+ return (
34
+ <div className="will-filter-bar-calendar">
35
+ <div className="will-calendar-filter-header">
36
+ <h3 className="will-calendar-filter-title">{t('calendar.title')}</h3>
37
+ </div>
38
+ <div className="will-calendar-filter-container">
39
+ <DayPicker
40
+ id="will-calendar"
41
+ mode="range"
42
+ showOutsideDays
43
+ fixedWeeks
44
+ numberOfMonths={!isTablet ? 2 : 1}
45
+ weekStartsOn={1}
46
+ max={31}
47
+ defaultMonth={currentMonth}
48
+ selected={calendarRange}
49
+ onSelect={setCalendarRange}
50
+ />
51
+ </div>
52
+ </div>
53
+ )
54
+ }
@@ -1,21 +1,21 @@
1
- .will-filter-bar-categories {
2
- text-align: center;
3
- }
4
-
5
- .will-categories-filter-title {
6
- font-size: 16px;
7
- text-transform: uppercase;
8
- margin: 10px 0 30px 0;
9
- }
10
-
11
- .will-categories-filter-inner {
12
- display: flex;
13
- align-items: center;
14
- justify-content: center;
15
- gap: 20px;
16
- }
17
-
18
- .will-categories-filter-inner input {
19
- cursor: pointer;
20
- margin-right: 10px;
21
- }
1
+ .will-filter-bar-categories {
2
+ text-align: center;
3
+ }
4
+
5
+ .will-categories-filter-title {
6
+ font-size: 16px;
7
+ text-transform: uppercase;
8
+ margin: 10px 0 30px 0;
9
+ }
10
+
11
+ .will-categories-filter-inner {
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ gap: 20px;
16
+ }
17
+
18
+ .will-categories-filter-inner input {
19
+ cursor: pointer;
20
+ margin-right: 10px;
21
+ }
@@ -1,41 +1,41 @@
1
- import React, { useState } from 'react'
2
- import { useTranslation } from 'react-i18next'
3
-
4
- import './Categories.css'
5
-
6
- export default function Categories({ categories, setCategories }: any) {
7
- const { t } = useTranslation('filterBar')
8
-
9
- const categoriesPlaceholder = [
10
- 'Weekend',
11
- 'Week',
12
- 'Summer camp',
13
- 'Winter camp',
14
- ]
15
-
16
- const [selectedCategory, setSelectedCategory] = useState('')
17
-
18
- const handleCategoryChange = (selectedCategory: any) => {
19
- setSelectedCategory(selectedCategory)
20
- setCategories(selectedCategory)
21
- }
22
-
23
- return (
24
- <div className="will-filter-bar-categories">
25
- <h3 className="will-categories-filter-title">{t('categories.label')}</h3>
26
- <div className="will-categories-filter-inner">
27
- {categoriesPlaceholder.map((itm, idx) => (
28
- <div key={idx}>
29
- <input
30
- type="radio"
31
- value={itm}
32
- checked={selectedCategory === itm}
33
- onChange={() => handleCategoryChange(itm)}
34
- />
35
- <span>{itm}</span>
36
- </div>
37
- ))}
38
- </div>
39
- </div>
40
- )
41
- }
1
+ import React, { useState } from 'react'
2
+ import { useTranslation } from 'react-i18next'
3
+
4
+ import './Categories.css'
5
+
6
+ export default function Categories({ categories, setCategories }: any) {
7
+ const { t } = useTranslation('filterBar')
8
+
9
+ const categoriesPlaceholder = [
10
+ 'Weekend',
11
+ 'Week',
12
+ 'Summer camp',
13
+ 'Winter camp',
14
+ ]
15
+
16
+ const [selectedCategory, setSelectedCategory] = useState('')
17
+
18
+ const handleCategoryChange = (selectedCategory: any) => {
19
+ setSelectedCategory(selectedCategory)
20
+ setCategories(selectedCategory)
21
+ }
22
+
23
+ return (
24
+ <div className="will-filter-bar-categories">
25
+ <h3 className="will-categories-filter-title">{t('categories.label')}</h3>
26
+ <div className="will-categories-filter-inner">
27
+ {categoriesPlaceholder.map((itm, idx) => (
28
+ <div key={idx}>
29
+ <input
30
+ type="radio"
31
+ value={itm}
32
+ checked={selectedCategory === itm}
33
+ onChange={() => handleCategoryChange(itm)}
34
+ />
35
+ <span>{itm}</span>
36
+ </div>
37
+ ))}
38
+ </div>
39
+ </div>
40
+ )
41
+ }
@@ -1,26 +1,26 @@
1
- .will-filter-bar-close-button {
2
- width: auto;
3
- height: auto;
4
- background-color: var(--will-grey);
5
- color: var(--will-white);
6
- padding: 2px 7px;
7
- border-radius: 50%;
8
- cursor: pointer;
9
- border: none;
10
- display: flex;
11
- align-items: center;
12
- font-size: 25px;
13
- margin-left: 15px;
14
- display: none;
15
- }
16
-
17
- @media (max-width: 960px) {
18
- .will-filter-bar-close-button {
19
- min-height: 35px;
20
- border-radius: 25px;
21
- margin-left:0;
22
- margin-bottom: 25px;
23
- display: flex;
24
- justify-content: center;
25
- }
26
- }
1
+ .will-filter-bar-close-button {
2
+ width: auto;
3
+ height: auto;
4
+ background-color: var(--will-grey);
5
+ color: var(--will-white);
6
+ padding: 2px 7px;
7
+ border-radius: 50%;
8
+ cursor: pointer;
9
+ border: none;
10
+ display: flex;
11
+ align-items: center;
12
+ font-size: 25px;
13
+ margin-left: 15px;
14
+ display: none;
15
+ }
16
+
17
+ @media (max-width: 960px) {
18
+ .will-filter-bar-close-button {
19
+ min-height: 35px;
20
+ border-radius: 25px;
21
+ margin-left:0;
22
+ margin-bottom: 25px;
23
+ display: flex;
24
+ justify-content: center;
25
+ }
26
+ }
@@ -1,16 +1,16 @@
1
- import React from 'react'
2
- import { IoIosCloseCircleOutline } from 'react-icons/io'
3
-
4
- import './CloseButton.css'
5
-
6
- interface CloseButtonPropsType {
7
- handleClose: () => void
8
- }
9
-
10
- export default function CloseButton({ handleClose }: CloseButtonPropsType) {
11
- return (
12
- <button className="will-filter-bar-close-button" onClick={handleClose}>
13
- <IoIosCloseCircleOutline />
14
- </button>
15
- )
16
- }
1
+ import React from 'react'
2
+ import { IoIosCloseCircleOutline } from 'react-icons/io'
3
+
4
+ import './CloseButton.css'
5
+
6
+ interface CloseButtonPropsType {
7
+ handleClose: () => void
8
+ }
9
+
10
+ export default function CloseButton({ handleClose }: CloseButtonPropsType) {
11
+ return (
12
+ <button className="will-filter-bar-close-button" onClick={handleClose}>
13
+ <IoIosCloseCircleOutline />
14
+ </button>
15
+ )
16
+ }
@@ -1,15 +1,15 @@
1
- .will-filter-bar-divider {
2
- width: 1px;
3
- margin: 0 10px;
4
- height: 35px;
5
- background-color: #384265;
6
- }
7
-
8
- @media (max-width: 960px) {
9
- .will-filter-bar-divider {
10
- width: 100%;
11
- margin: 0 10px;
12
- height: 1px;
13
- background-color: #384265;
14
- }
1
+ .will-filter-bar-divider {
2
+ width: 1px;
3
+ margin: 0 10px;
4
+ height: 35px;
5
+ background-color: #384265;
6
+ }
7
+
8
+ @media (max-width: 960px) {
9
+ .will-filter-bar-divider {
10
+ width: 100%;
11
+ margin: 0 10px;
12
+ height: 1px;
13
+ background-color: #384265;
14
+ }
15
15
  }
@@ -1,7 +1,7 @@
1
- import React from 'react'
2
-
3
- import './Divider.css'
4
-
5
- export default function Divider() {
6
- return <div className="will-filter-bar-divider" />
7
- }
1
+ import React from 'react'
2
+
3
+ import './Divider.css'
4
+
5
+ export default function Divider() {
6
+ return <div className="will-filter-bar-divider" />
7
+ }