@tmf_ciclica/ciclicastorybook 1.0.0
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/.storybook/main.js +21 -0
- package/.storybook/preview.jsx +31 -0
- package/README.md +8 -0
- package/eslint.config.js +38 -0
- package/index.html +13 -0
- package/package.json +67 -0
- package/public/vite.svg +1 -0
- package/src/App.css +0 -0
- package/src/App.jsx +36 -0
- package/src/_variables.scss +56 -0
- package/src/assets/img/arrowDown.svg +3 -0
- package/src/assets/img/closeIcon.svg +4 -0
- package/src/assets/img/copyIcon.svg +17 -0
- package/src/assets/img/deleteIcon.svg +6 -0
- package/src/assets/img/eyeActiveIcon.svg +6 -0
- package/src/assets/img/eyeNotActiveIcon.svg +8 -0
- package/src/assets/img/filtersIcon.svg +6 -0
- package/src/assets/img/langarrow.png +0 -0
- package/src/assets/img/pause.svg +5 -0
- package/src/assets/img/play.svg +4 -0
- package/src/assets/img/processingIcon.svg +20 -0
- package/src/assets/img/sample-image.png +0 -0
- package/src/assets/img/sample2.png +0 -0
- package/src/assets/img/world.svg +3 -0
- package/src/assets/mapStyles/mapStyle.js +781 -0
- package/src/components/AmbitSelector/AmbitItem/AmbitItem.jsx +74 -0
- package/src/components/AmbitSelector/AmbitItem/AmbitItem.module.scss +27 -0
- package/src/components/AmbitSelector/AmbitSelector.jsx +68 -0
- package/src/components/AmbitSelector/AmbitSelector.module.scss +29 -0
- package/src/components/AmbitSelector/AmbitSelector.stories.jsx +21 -0
- package/src/components/ButtonsList/ButtonsList.jsx +92 -0
- package/src/components/ButtonsList/ButtonsList.module.scss +37 -0
- package/src/components/ButtonsList/ButtonsList.stories.jsx +55 -0
- package/src/components/DropdownList/DropdownList.jsx +69 -0
- package/src/components/DropdownList/DropdownList.module.scss +20 -0
- package/src/components/DropdownList/DropdownList.stories.jsx +22 -0
- package/src/components/DropdownList/DropdownListExample/DropDownListExample.jsx +33 -0
- package/src/components/DropdownList/DropdownListExample/DropdownListExample.stories.jsx +11 -0
- package/src/components/EditAmbit/EditAmbit.jsx +7 -0
- package/src/components/FiltersAmbit/AppliedFilters/AppliedFilters.jsx +57 -0
- package/src/components/FiltersAmbit/AppliedFilters/AppliedFilters.module.scss +13 -0
- package/src/components/FiltersAmbit/AppliedFilters/AppliedFilters.stories.jsx +47 -0
- package/src/components/FiltersAmbit/FiltersAmbit.jsx +58 -0
- package/src/components/FiltersAmbit/FiltersAmbit.module.scss +28 -0
- package/src/components/FiltersAmbit/FiltersAmbit.stories.jsx +36 -0
- package/src/components/FiltersAmbit/GeographicFilters/GeographicalFilters.jsx +33 -0
- package/src/components/FiltersAmbit/GeographicFilters/GeographicalFilters.module.scss +13 -0
- package/src/components/FiltersAmbit/GeographicFilters/GeographicalFilters.stories.jsx +47 -0
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFilters.jsx +83 -0
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFilters.module.scss +8 -0
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFilters.stories.jsx +17 -0
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersCategory/TematicalFiltersCategory.jsx +60 -0
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersInput/AbsoluteSlider/AbsoluteSlider.jsx +61 -0
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersInput/AbsoluteSlider/AbsoluteSlider.module.scss +45 -0
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersInput/CategoryCheckbox/CategoryChackbox.module.scss +18 -0
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersInput/CategoryCheckbox/CategoryCheckbox.jsx +47 -0
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersInput/TematicalFiltersInput.jsx +267 -0
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersInput/TematicalFiltersInput.module.scss +31 -0
- package/src/components/FiltersAmbit/TematicalFilters/TematicalFiltersSubcat/TematicalFiltersSubcat.jsx +58 -0
- package/src/components/FiltersAmbit/useAmbitStore.jsx +10 -0
- package/src/components/Graphic/BarChart/BarChart.jsx +146 -0
- package/src/components/Graphic/BarChart/BarChart.module.scss +5 -0
- package/src/components/Graphic/BarChart/BarChart.stories.jsx +18 -0
- package/src/components/Graphic/Graphic.jsx +55 -0
- package/src/components/Graphic/Graphic.module.scss +12 -0
- package/src/components/Graphic/Graphic.stories.jsx +25 -0
- package/src/components/IndicatorsList/Indicator/Indicator.jsx +180 -0
- package/src/components/IndicatorsList/Indicator/Indicator.module.scss +46 -0
- package/src/components/IndicatorsList/IndicatorSubCategory/IndicatorSubCategory.jsx +76 -0
- package/src/components/IndicatorsList/IndicatorSubCategory/IndicatorSubCategory.module.scss +12 -0
- package/src/components/IndicatorsList/IndicatorsCategory/IndicatorsCategory.jsx +122 -0
- package/src/components/IndicatorsList/IndicatorsCategory/IndicatorsCategory.module.scss +20 -0
- package/src/components/IndicatorsList/IndicatorsList.jsx +173 -0
- package/src/components/IndicatorsList/IndicatorsList.module.scss +10 -0
- package/src/components/IndicatorsList/IndicatorsList.stories.jsx +263 -0
- package/src/components/LangSelector/LangSelector.jsx +70 -0
- package/src/components/LangSelector/LangSelector.module.scss +41 -0
- package/src/components/LangSelector/LangSelector.stories.jsx +27 -0
- package/src/components/Legend/Legend.jsx +132 -0
- package/src/components/Legend/Legend.module.scss +121 -0
- package/src/components/Legend/Legend.stories.jsx +53 -0
- package/src/components/LogoApp/LogoApp.jsx +33 -0
- package/src/components/LogoApp/LogoApp.module.scss +7 -0
- package/src/components/LogoApp/LogoApp.stories.jsx +27 -0
- package/src/components/MapboxMap/MapboxMap.jsx +160 -0
- package/src/components/MapboxMap/MapboxMap.module.scss +4 -0
- package/src/components/MapboxMap/MapboxMap.stories.jsx +57 -0
- package/src/components/MaplibreMap/MaplibreMap.jsx +166 -0
- package/src/components/MaplibreMap/MaplibreMap.module.scss +5 -0
- package/src/components/MaplibreMap/MaplibreMap.stories.jsx +55 -0
- package/src/components/SectionBar/SectionBar.jsx +41 -0
- package/src/components/SectionBar/SectionBar.module.scss +40 -0
- package/src/components/SectionBar/SectionBar.stories.jsx +35 -0
- package/src/components/TimeSlider/TimeSlider.jsx +147 -0
- package/src/components/TimeSlider/TimeSlider.module.scss +63 -0
- package/src/components/TimeSlider/TimeSlider.stories.jsx +9 -0
- package/src/components/Tooltip/Tooltip.jsx +40 -0
- package/src/components/Tooltip/Tooltip.module.scss +141 -0
- package/src/components/Tooltip/Tooltip.stories.jsx +51 -0
- package/src/components/TopNavMenu/TopNavMenu.jsx +62 -0
- package/src/components/TopNavMenu/TopNavMenu.module.scss +21 -0
- package/src/components/TopNavMenu/TopNavMenu.stories.jsx +20 -0
- package/src/components/UserMenuTrigger/UserMenuTrigger.jsx +47 -0
- package/src/components/UserMenuTrigger/UserMenuTrigger.module.scss +5 -0
- package/src/components/UserMenuTrigger/UserMenuTrigger.stories.jsx +33 -0
- package/src/components/index.jsx +17 -0
- package/src/constants/indicators.js +1371 -0
- package/src/constants/mapTexts.js +161 -0
- package/src/constants/textLayers.js +639 -0
- package/src/constants/topNavMenuOptions.js +14 -0
- package/src/i18n.js +19 -0
- package/src/index.js +2 -0
- package/src/index.scss +87 -0
- package/src/locales/ca.json +8 -0
- package/src/locales/es.json +15 -0
- package/src/main.jsx +10 -0
- package/src/sections/HeaderSection/HeaderSection.jsx +51 -0
- package/src/sections/HeaderSection/HeaderSection.module.scss +33 -0
- package/src/sections/HeaderSection/HeaderSection.stories.jsx +61 -0
- package/src/sections/RightSidebar/RightSidebar.jsx +35 -0
- package/src/sections/RightSidebar/RightSidebar.module.scss +39 -0
- package/src/sections/RightSidebar/RightSidebar.stories.jsx +21 -0
- package/src/sections/index.js +2 -0
- package/src/store/index.js +1 -0
- package/src/store/mapSlice/index.js +1 -0
- package/src/store/mapSlice/mapSlice.js +30 -0
- package/src/store/rightBarSlice/index.js +1 -0
- package/src/store/rightBarSlice/rightBarSlice.js +28 -0
- package/src/store/routerSlice/index.js +1 -0
- package/src/store/routerSlice/routerSlice.js +14 -0
- package/src/store/store.js +14 -0
- package/src/store/userSlice/index.js +1 -0
- package/src/store/userSlice/userSlice.js +22 -0
- package/vite.config.js +36 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AppliedFilters } from "./AppliedFilters"
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: "Components/AppliedFilters",
|
|
5
|
+
component: AppliedFilters,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
let open = true
|
|
9
|
+
let activeFilters = [
|
|
10
|
+
{
|
|
11
|
+
"type": "cat",
|
|
12
|
+
"code": "us_prn",
|
|
13
|
+
"values": [
|
|
14
|
+
0,
|
|
15
|
+
2
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "cat",
|
|
20
|
+
"code": "al_max_cat",
|
|
21
|
+
"values": [
|
|
22
|
+
0
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"type": "cat",
|
|
27
|
+
"code": "uni_pluri",
|
|
28
|
+
"values": [
|
|
29
|
+
1
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"type": "abs",
|
|
34
|
+
"code": "al_max",
|
|
35
|
+
"min": 1,
|
|
36
|
+
"max": 11
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
export const Default = {
|
|
41
|
+
args: {
|
|
42
|
+
activeFilters,
|
|
43
|
+
isOpen: open,
|
|
44
|
+
textColor: "white",
|
|
45
|
+
backgroundColor: "#605B56"
|
|
46
|
+
},
|
|
47
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useEffect, useState } from "react"
|
|
2
|
+
|
|
3
|
+
import { A } from "storybook/internal/components"
|
|
4
|
+
import { AppliedFilters } from "./AppliedFilters/AppliedFilters"
|
|
5
|
+
import { GeographicalFilters } from "./GeographicFilters/GeographicalFilters"
|
|
6
|
+
import { TematicalFilters } from "./TematicalFilters/TematicalFilters"
|
|
7
|
+
import { filter } from "d3"
|
|
8
|
+
import styles from "./FiltersAmbit.module.scss"
|
|
9
|
+
import { useAmbitStore } from "./useAmbitStore"
|
|
10
|
+
import { useTranslation } from "react-i18next"
|
|
11
|
+
|
|
12
|
+
export const FiltersAmbit = ({
|
|
13
|
+
ambitName,
|
|
14
|
+
ambitDescription,
|
|
15
|
+
defaultFilters,
|
|
16
|
+
}) => {
|
|
17
|
+
const { t } = useTranslation()
|
|
18
|
+
|
|
19
|
+
const { tematicalFiltersSelected } = useAmbitStore((s) => s)
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (defaultFilters && defaultFilters.length > 0) {
|
|
23
|
+
// Initialize the store with default filters
|
|
24
|
+
useAmbitStore.setState((state) => ({
|
|
25
|
+
tematicalFiltersSelected: defaultFilters,
|
|
26
|
+
}))
|
|
27
|
+
}
|
|
28
|
+
}, [defaultFilters])
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
console.log("filtersSelected changed: ", tematicalFiltersSelected)
|
|
31
|
+
}, [tematicalFiltersSelected])
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<div className={styles.FiltersAmbitContainer}>
|
|
35
|
+
<div className={styles.FiltersAmbitHeader}>
|
|
36
|
+
<div className={styles.FiltersAmbitTitle}>{ambitName}</div>
|
|
37
|
+
<div className={styles.FiltersAmbitDescription}>
|
|
38
|
+
<div className={styles.FiltersAmbitDescriptionTitle}>
|
|
39
|
+
{t("Descripción")}
|
|
40
|
+
</div>
|
|
41
|
+
{ambitDescription}
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<AppliedFilters
|
|
46
|
+
title={t('Filtros Aplicados')}
|
|
47
|
+
isOpen={true}
|
|
48
|
+
textColor={"#ffffff"}
|
|
49
|
+
backgroundColor={"#605B5680"}
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
<GeographicalFilters />
|
|
53
|
+
|
|
54
|
+
<TematicalFilters />
|
|
55
|
+
|
|
56
|
+
</div>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.FiltersAmbitContainer {
|
|
2
|
+
width: 100%;
|
|
3
|
+
height: 100%;
|
|
4
|
+
padding: 28.5px 0 0 24px;
|
|
5
|
+
|
|
6
|
+
.FiltersAmbitHeader {
|
|
7
|
+
@include flex(column, start, start, $gap: 30px);
|
|
8
|
+
|
|
9
|
+
.FiltersAmbitTitle {
|
|
10
|
+
@include fontSubtitols;
|
|
11
|
+
padding: 0 0 26px 0;
|
|
12
|
+
border-bottom: 1.5px solid #605B56;
|
|
13
|
+
width: 100%;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.FiltersAmbitDescription {
|
|
17
|
+
@include flex(column, start, start, $gap: 10px);
|
|
18
|
+
padding: 0 0 26px 0;
|
|
19
|
+
// border-bottom: 1.5px solid #605B56;
|
|
20
|
+
@include fontBase;
|
|
21
|
+
|
|
22
|
+
.FiltersAmbitDescriptionTitle {
|
|
23
|
+
@include fontSubtitols;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FiltersAmbit } from "./FiltersAmbit"
|
|
2
|
+
// import indicators from "../../../constants/indicators"
|
|
3
|
+
export default {
|
|
4
|
+
title: "Components/FiltersAmbit",
|
|
5
|
+
component: FiltersAmbit,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const Default = {
|
|
9
|
+
args: {
|
|
10
|
+
ambitName: "Ambito 1",
|
|
11
|
+
ambitDescription:
|
|
12
|
+
"Enim occaecat consequat aute nulla fugiat ullamco proident.Culpa ex minim incididunt laboris magna ipsum. In duis irure enim culpa ex anim nulla deserunt ut voluptate amet. Aliquip id ea ut duis aute minim. Voluptate ut ipsum ea nisi quis do sunt et eu deserunt. Id tempor cupidatat veniam cupidatat enim consequat. Duis nulla velit amet ex cupidatat exercitation laborum sint dolore in dolore velit.",
|
|
13
|
+
defaultFilters: [
|
|
14
|
+
{
|
|
15
|
+
type: "cat",
|
|
16
|
+
code: "uni_pluri",
|
|
17
|
+
values: [1, 2, 3],
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: "cat",
|
|
21
|
+
code: "nom_cluster",
|
|
22
|
+
values: [2, 4, 6, 7, 8, 9, 10, 11, 12],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: "cat",
|
|
26
|
+
code: "any_const_cat",
|
|
27
|
+
values: [2, 3, 4, 5],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: "cat",
|
|
31
|
+
code: "us_prn",
|
|
32
|
+
values: [2, 3, 4, 5, 6, 7, 8, 9, 10],
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect, useState } from "react"
|
|
2
|
+
|
|
3
|
+
import { DropdownList } from "../../DropdownList/DropdownList"
|
|
4
|
+
import PropTypes from "prop-types"
|
|
5
|
+
// import styles from "./GeographicalFilters.module.scss"
|
|
6
|
+
import { useAmbitStore } from "../useAmbitStore"
|
|
7
|
+
import { useTranslation } from "react-i18next"
|
|
8
|
+
|
|
9
|
+
export const GeographicalFilters = ({ title, onClick, isOpen = true, textColor = "#ffffff", backgroundColor = "#605B5680" }) => {
|
|
10
|
+
const { t } = useTranslation()
|
|
11
|
+
|
|
12
|
+
const { tematicalFiltersSelected } = useAmbitStore((s) => s)
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<DropdownList
|
|
16
|
+
isOpen={isOpen}
|
|
17
|
+
onClick={onClick}
|
|
18
|
+
title={title ? t(title) : "Geographical Filters"}
|
|
19
|
+
>
|
|
20
|
+
|
|
21
|
+
A
|
|
22
|
+
</DropdownList>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
GeographicalFilters.propTypes = {
|
|
26
|
+
isOpen: PropTypes.bool,
|
|
27
|
+
onClick: PropTypes.func,
|
|
28
|
+
title: PropTypes.string,
|
|
29
|
+
textColor: PropTypes.string,
|
|
30
|
+
backgroundColor: PropTypes.string,
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
.GeographicalFilters {
|
|
2
|
+
@include flex(row, start, start, $gap: 10px);
|
|
3
|
+
|
|
4
|
+
.AppliedFilterContent {
|
|
5
|
+
@include flex($gap: 10px);
|
|
6
|
+
@include fontBase;
|
|
7
|
+
height: 35px;
|
|
8
|
+
width: fit-content;
|
|
9
|
+
padding: 0px 20px;
|
|
10
|
+
border-radius: 100px;
|
|
11
|
+
// background-color: red;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { GeographicalFilters } from "./GeographicalFilters"
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: "Components/GeographicalFilters",
|
|
5
|
+
component: GeographicalFilters,
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
let open = true
|
|
9
|
+
let activeFilters = [
|
|
10
|
+
{
|
|
11
|
+
"type": "cat",
|
|
12
|
+
"code": "us_prn",
|
|
13
|
+
"values": [
|
|
14
|
+
0,
|
|
15
|
+
2
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"type": "cat",
|
|
20
|
+
"code": "al_max_cat",
|
|
21
|
+
"values": [
|
|
22
|
+
0
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"type": "cat",
|
|
27
|
+
"code": "uni_pluri",
|
|
28
|
+
"values": [
|
|
29
|
+
1
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"type": "abs",
|
|
34
|
+
"code": "al_max",
|
|
35
|
+
"min": 1,
|
|
36
|
+
"max": 11
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
export const Default = {
|
|
41
|
+
// args: {
|
|
42
|
+
// activeFilters,
|
|
43
|
+
// isOpen: open,
|
|
44
|
+
// textColor: "white",
|
|
45
|
+
// backgroundColor: "#605B56"
|
|
46
|
+
// },
|
|
47
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useEffect } from "react"
|
|
2
|
+
import Indicadores from "../../../constants/indicators"
|
|
3
|
+
import { DropdownList } from "../../DropdownList/DropdownList"
|
|
4
|
+
import { useTranslation } from "react-i18next"
|
|
5
|
+
//import styles from "./TematicalFilters.module.scss"
|
|
6
|
+
import { TematicalFiltersCategory } from "./TematicalFiltersCategory/TematicalFiltersCategory"
|
|
7
|
+
import PropTypes from "prop-types"
|
|
8
|
+
import { useAmbitStore } from "../useAmbitStore"
|
|
9
|
+
|
|
10
|
+
//Needs DropdownList, zustand and react-slider component to be used
|
|
11
|
+
export const TematicalFilters = ({
|
|
12
|
+
indicators = Indicadores,
|
|
13
|
+
isOpen = true,
|
|
14
|
+
title,
|
|
15
|
+
fontColor = "#605B56",
|
|
16
|
+
//The color of the slider and the checkbox when is checked
|
|
17
|
+
inputsColor = "#605B56",
|
|
18
|
+
}) => {
|
|
19
|
+
const { tematicalFiltersSelected } = useAmbitStore((s) => s)
|
|
20
|
+
const { t } = useTranslation()
|
|
21
|
+
//This function is used to reset the indicator selected when type is changed
|
|
22
|
+
//Only use it if we cant select both types at the same time.
|
|
23
|
+
// const onChangeBothType = ({ code }) => {
|
|
24
|
+
// setFiltersSelected((actual) => {
|
|
25
|
+
// let foundIndicator = actual.find((f) => f.code == code)
|
|
26
|
+
// //If the indicator is found, we delete the indicator key
|
|
27
|
+
// if (foundIndicator) {
|
|
28
|
+
// let newFiltersSelected = actual.filter((f) => f.code !== code)
|
|
29
|
+
// return newFiltersSelected
|
|
30
|
+
// } else {
|
|
31
|
+
// return actual
|
|
32
|
+
// }
|
|
33
|
+
// })
|
|
34
|
+
// }
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
console.log("filtersSelected changed: ", tematicalFiltersSelected)
|
|
37
|
+
}, [tematicalFiltersSelected])
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
fontColor && useAmbitStore.setState(() => ({ fontColor: fontColor }))
|
|
40
|
+
}, [fontColor])
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
inputsColor && useAmbitStore.setState(() => ({ inputsColor: inputsColor }))
|
|
44
|
+
}, [inputsColor])
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<DropdownList
|
|
48
|
+
isOpen={isOpen}
|
|
49
|
+
title={title ? t(title) : "Tematical filters"}
|
|
50
|
+
color={fontColor}
|
|
51
|
+
>
|
|
52
|
+
{indicators?.map((category, key) => {
|
|
53
|
+
return (
|
|
54
|
+
<TematicalFiltersCategory
|
|
55
|
+
category={category}
|
|
56
|
+
key={`category-${key}`}
|
|
57
|
+
fontColor={fontColor}
|
|
58
|
+
// onChangeBothType={onChangeBothType}
|
|
59
|
+
/>
|
|
60
|
+
)
|
|
61
|
+
})}
|
|
62
|
+
</DropdownList>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
TematicalFilters.propTypes = {
|
|
66
|
+
isOpen: PropTypes.bool,
|
|
67
|
+
title: PropTypes.string,
|
|
68
|
+
indicators: PropTypes.arrayOf(
|
|
69
|
+
PropTypes.shape({
|
|
70
|
+
name: PropTypes.string,
|
|
71
|
+
type: PropTypes.string,
|
|
72
|
+
values: PropTypes.arrayOf(
|
|
73
|
+
PropTypes.shape({
|
|
74
|
+
codename: PropTypes.string,
|
|
75
|
+
title: PropTypes.string,
|
|
76
|
+
})
|
|
77
|
+
),
|
|
78
|
+
})
|
|
79
|
+
),
|
|
80
|
+
fontColor: PropTypes.string,
|
|
81
|
+
onChangeTematicalFilters: PropTypes.func,
|
|
82
|
+
inputsColor: PropTypes.string,
|
|
83
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { TematicalFilters } from "./TematicalFilters"
|
|
2
|
+
import indicators from "../../../constants/indicators"
|
|
3
|
+
export default {
|
|
4
|
+
title: "Components/TematicalFilters",
|
|
5
|
+
component: TematicalFilters,
|
|
6
|
+
}
|
|
7
|
+
let open = true
|
|
8
|
+
export const Default = {
|
|
9
|
+
args: {
|
|
10
|
+
indicators: indicators,
|
|
11
|
+
// activeColor: "#f75321",
|
|
12
|
+
activeColor: "#F8A925",
|
|
13
|
+
fontColor: "#605B56",
|
|
14
|
+
isOpen: open,
|
|
15
|
+
|
|
16
|
+
},
|
|
17
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useState } from "react"
|
|
2
|
+
import { DropdownList } from "../../../DropdownList/DropdownList"
|
|
3
|
+
import { TematicalFiltersSubcat } from "../TematicalFiltersSubcat/TematicalFiltersSubcat"
|
|
4
|
+
import { TematicalFiltersInput } from "../TematicalFiltersInput/TematicalFiltersInput"
|
|
5
|
+
import PropTypes from "prop-types"
|
|
6
|
+
import { useAmbitStore } from "../../useAmbitStore"
|
|
7
|
+
|
|
8
|
+
//Needs DropdownList component to be used
|
|
9
|
+
//If category has subcategories, it will render them as dropdowns, else will render the indicators.
|
|
10
|
+
export const TematicalFiltersCategory = ({
|
|
11
|
+
category,
|
|
12
|
+
// onChangeBothType,
|
|
13
|
+
}) => {
|
|
14
|
+
const { name, subcategories, indicators } = category || {}
|
|
15
|
+
const { activeCategory, fontColor } = useAmbitStore((s) => s)
|
|
16
|
+
return (
|
|
17
|
+
category && (
|
|
18
|
+
<DropdownList
|
|
19
|
+
onClick={() => {
|
|
20
|
+
useAmbitStore.setState((s) => ({
|
|
21
|
+
activeCategory: activeCategory === `id${name}` ? "" : `id${name}`,
|
|
22
|
+
}))
|
|
23
|
+
}}
|
|
24
|
+
title={name}
|
|
25
|
+
isOpen={activeCategory === `id${name}`}
|
|
26
|
+
titleFontStyles={{ fontSize: 18, fontWeight: "bold" }}
|
|
27
|
+
showBottomBar={false}
|
|
28
|
+
color={fontColor}
|
|
29
|
+
>
|
|
30
|
+
{subcategories
|
|
31
|
+
? subcategories.map((subcategory, key) => (
|
|
32
|
+
<TematicalFiltersSubcat
|
|
33
|
+
subcategory={subcategory}
|
|
34
|
+
key={`subcategory-${key}`}
|
|
35
|
+
fontColor={fontColor}
|
|
36
|
+
//onChangeBothType={onChangeBothType}
|
|
37
|
+
/>
|
|
38
|
+
))
|
|
39
|
+
: indicators &&
|
|
40
|
+
indicators.map((indicator, key) => (
|
|
41
|
+
<TematicalFiltersInput
|
|
42
|
+
indicator={indicator}
|
|
43
|
+
key={`indicator-${key}`}
|
|
44
|
+
fontColor={fontColor}
|
|
45
|
+
//onChangeBothType={onChangeBothType}
|
|
46
|
+
/>
|
|
47
|
+
))}
|
|
48
|
+
</DropdownList>
|
|
49
|
+
)
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
TematicalFiltersCategory.propTypes = {
|
|
54
|
+
category: PropTypes.shape({
|
|
55
|
+
name: PropTypes.string.isRequired,
|
|
56
|
+
subcategories: PropTypes.array,
|
|
57
|
+
indicators: PropTypes.array,
|
|
58
|
+
}),
|
|
59
|
+
//onChangeBothType: PropTypes.func,
|
|
60
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import ReactSlider from "react-slider"
|
|
2
|
+
import styles from "./AbsoluteSlider.module.scss"
|
|
3
|
+
import { useTranslation } from "react-i18next"
|
|
4
|
+
import PropTypes from "prop-types"
|
|
5
|
+
|
|
6
|
+
export const AbsoluteSlider = ({
|
|
7
|
+
min = 0,
|
|
8
|
+
max = 100,
|
|
9
|
+
step = 1,
|
|
10
|
+
onChange,
|
|
11
|
+
width = 300,
|
|
12
|
+
unit,
|
|
13
|
+
fontColor = "#605B56",
|
|
14
|
+
value = [min, max],
|
|
15
|
+
}) => {
|
|
16
|
+
const { t } = useTranslation()
|
|
17
|
+
const handleChange = (newValues) => {
|
|
18
|
+
onChange?.({ min: newValues[0], max: newValues[1] })
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div
|
|
23
|
+
className={styles.container}
|
|
24
|
+
style={{ width: `${width}px`, color: `${fontColor}` }}
|
|
25
|
+
>
|
|
26
|
+
<div className={styles.unitLabel}>
|
|
27
|
+
<span>{t(unit)}</span>
|
|
28
|
+
</div>
|
|
29
|
+
<ReactSlider
|
|
30
|
+
className={styles.slider}
|
|
31
|
+
thumbClassName={styles.thumb}
|
|
32
|
+
trackClassName={styles.track}
|
|
33
|
+
min={min}
|
|
34
|
+
max={max}
|
|
35
|
+
step={step}
|
|
36
|
+
value={value}
|
|
37
|
+
onChange={handleChange}
|
|
38
|
+
withTracks={true}
|
|
39
|
+
pearling
|
|
40
|
+
minDistance={1}
|
|
41
|
+
|
|
42
|
+
/>
|
|
43
|
+
<div className={styles.labels}>
|
|
44
|
+
<span>{value[0]}</span>
|
|
45
|
+
<span>{value[1]}</span>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
AbsoluteSlider.propTypes = {
|
|
51
|
+
min: PropTypes.number,
|
|
52
|
+
max: PropTypes.number,
|
|
53
|
+
step: PropTypes.number,
|
|
54
|
+
initialMin: PropTypes.number,
|
|
55
|
+
initialMax: PropTypes.number,
|
|
56
|
+
onChange: PropTypes.func,
|
|
57
|
+
width: PropTypes.number,
|
|
58
|
+
unit: PropTypes.string,
|
|
59
|
+
fontColor: PropTypes.string,
|
|
60
|
+
value: PropTypes.arrayOf(PropTypes.number),
|
|
61
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
padding-top: 15px;
|
|
3
|
+
font-size: 14px;
|
|
4
|
+
span {
|
|
5
|
+
font-size: 14px;
|
|
6
|
+
}
|
|
7
|
+
.unitLabel {
|
|
8
|
+
height: 40px;
|
|
9
|
+
}
|
|
10
|
+
.slider {
|
|
11
|
+
height: 6px;
|
|
12
|
+
background-color: #ddd;
|
|
13
|
+
border-radius: 3px;
|
|
14
|
+
position: relative;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.thumb {
|
|
18
|
+
height: 20px;
|
|
19
|
+
width: 20px;
|
|
20
|
+
background-color: #605b56;
|
|
21
|
+
border-radius: 50%;
|
|
22
|
+
cursor: grab;
|
|
23
|
+
top: -7px;
|
|
24
|
+
position: absolute;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.track {
|
|
28
|
+
top: 0;
|
|
29
|
+
bottom: 0;
|
|
30
|
+
background: #605b56;
|
|
31
|
+
border-radius: 3px;
|
|
32
|
+
|
|
33
|
+
// react-slider asigna automáticamente:
|
|
34
|
+
// - track-0: izquierda del primer thumb
|
|
35
|
+
// - track-1: entre thumbs
|
|
36
|
+
// - track-2: derecha del segundo thumb
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.labels {
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: space-between;
|
|
42
|
+
font-size: 14px;
|
|
43
|
+
margin-top: 10px;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.checkboxContainer {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: 0.5rem;
|
|
5
|
+
font-size: 14px;
|
|
6
|
+
font-weight: 400;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
|
|
9
|
+
input[type="checkbox"] {
|
|
10
|
+
appearance: none; // Oculta el estilo nativo
|
|
11
|
+
-webkit-appearance: none;
|
|
12
|
+
width: 10px;
|
|
13
|
+
height: 10px;
|
|
14
|
+
border-radius: 1px;
|
|
15
|
+
background-color: white;
|
|
16
|
+
cursor: pointer;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import PropTypes from "prop-types"
|
|
2
|
+
import style from "./CategoryChackbox.module.scss"
|
|
3
|
+
import { useTranslation } from "react-i18next"
|
|
4
|
+
import { useAmbitStore } from "../../../useAmbitStore"
|
|
5
|
+
export const CategoryCheckbox = ({
|
|
6
|
+
onClick,
|
|
7
|
+
containerStyles,
|
|
8
|
+
color = "#605B56",
|
|
9
|
+
indicator,
|
|
10
|
+
value,
|
|
11
|
+
}) => {
|
|
12
|
+
const { t } = useTranslation()
|
|
13
|
+
const { title } = indicator || {}
|
|
14
|
+
const { fontColor, inputsColor } = useAmbitStore((s) => s)
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
style={{ ...containerStyles, color: color }}
|
|
18
|
+
role="checkbox"
|
|
19
|
+
className={style.checkboxContainer}
|
|
20
|
+
onClick={onClick}
|
|
21
|
+
>
|
|
22
|
+
<input
|
|
23
|
+
type="checkbox"
|
|
24
|
+
checked={typeof value === "boolean" ? value : true}
|
|
25
|
+
value={value}
|
|
26
|
+
readOnly
|
|
27
|
+
style={{
|
|
28
|
+
border: `1.5px solid ${value ? inputsColor : fontColor}`,
|
|
29
|
+
backgroundColor: value ? inputsColor : "white",
|
|
30
|
+
}}
|
|
31
|
+
/>
|
|
32
|
+
<span className="checkmark">{t(title)}</span>
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
CategoryCheckbox.propTypes = {
|
|
38
|
+
onClick: PropTypes.func,
|
|
39
|
+
value: PropTypes.bool,
|
|
40
|
+
containerStyles: PropTypes.object,
|
|
41
|
+
color: PropTypes.string,
|
|
42
|
+
indicator: PropTypes.shape({
|
|
43
|
+
title: PropTypes.string,
|
|
44
|
+
codename: PropTypes.array,
|
|
45
|
+
}),
|
|
46
|
+
checkedColor: PropTypes.string,
|
|
47
|
+
}
|