Skip to content

Commit

Permalink
handle touristic contents search and filters
Browse files Browse the repository at this point in the history
  • Loading branch information
bastyen committed Dec 12, 2023
1 parent 5d9d653 commit f51c165
Show file tree
Hide file tree
Showing 17 changed files with 442 additions and 230 deletions.
5 changes: 5 additions & 0 deletions src/components/grw-app/grw-app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ export class GrwApp {
}

componentWillLoad() {
if (this.treks) {
state.mode = 'treks';
} else if (this.touristicContents) {
state.mode = 'touristicContents';
}
const url = new URL(window.location.toString());
const trekParam = url.searchParams.get('trek');
const parentTrekId = url.searchParams.get('parenttrek');
Expand Down
2 changes: 1 addition & 1 deletion src/components/grw-app/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
| `themes` | `themes` | | `string` | `undefined` |
| `touristicContents` | `touristic-contents` | | `boolean` | `false` |
| `touristicEvents` | `touristic-events` | | `boolean` | `false` |
| `treks` | `treks` | | `boolean` | `false` |
| `treks` | `treks` | | `boolean` | `true` |
| `urlLayer` | `url-layer` | | `string` | `undefined` |
| `useGradient` | `use-gradient` | | `boolean` | `false` |
| `weather` | `weather` | | `boolean` | `false` |
Expand Down
4 changes: 2 additions & 2 deletions src/components/grw-filter/grw-filter.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
font-size: 14px;
font-weight: 500;
margin: 8px 0px 0px 8px;
padding: 8px 16px;
padding: 8px 0px;
.choices__inner {
border: 1px solid var(--color-outline);
border-radius: 8px;
Expand Down Expand Up @@ -67,7 +67,7 @@
}
.choices__list--dropdown,
.choices__list[aria-expanded] {
width: calc(100% - 32px);
width: 100%;
color: var(--color-on-secondary-container);
background-color: var(--color-secondary-container);
border: 1px solid var(--color-outline);
Expand Down
25 changes: 18 additions & 7 deletions src/components/grw-filter/grw-filter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Host, h, Prop, Listen, forceUpdate, Element } from '@stencil/core';
import state from 'store/store';
import { filters, handleFiltersAndSearch } from 'utils/utils';
import { treksFilters, handleTreksFiltersAndSearch, touristicContentsFilters, handleTouristicContentsFiltersAndSearch } from 'utils/utils';
import 'choices.js/public/assets/scripts/choices.min.js';

@Component({
Expand Down Expand Up @@ -32,13 +32,24 @@ export class GrwFilter {
state[this.filterType] = filterFromState;

state[this.segment] = 0;
filters
.filter(filter => filter.segment === this.segment)
.forEach(filter => {
state[this.segment] += state[filter.property].filter(filter => filter.selected).length;
});

state.currentTreks = handleFiltersAndSearch();
if (state.mode === 'treks') {
treksFilters
.filter(filter => filter.segment === this.segment)
.forEach(filter => {
state[this.segment] += state[filter.property].filter(filter => filter.selected).length;
});

state.currentTreks = handleTreksFiltersAndSearch();
} else if (state.mode === 'touristicContents') {
touristicContentsFilters
.filter(filter => filter.segment === this.segment)
.forEach(filter => {
state[this.segment] += state[filter.property].filter(filter => filter.selected).length;
});

state.currentTouristicContents = handleTouristicContentsFiltersAndSearch();
}
}

resetFilter() {
Expand Down
16 changes: 12 additions & 4 deletions src/components/grw-filters/grw-filters.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
width: 100%;
height: 100%;
z-index: 1100;
.filters-treks-container,
.filters-touristic-contents-container {
height: 100%;
}
.segmented-buttons-container {
display: flex;
justify-content: center;
Expand Down Expand Up @@ -56,9 +60,9 @@
}

.filters-segment-container {
overflow-y: scroll;
padding-bottom: 32px;
height: calc(100% - 64px - 42px - 32px);
overflow-y: visible;
height: 100%;
max-height: calc(100% - 64px - 42px - 32px);
}

.back-filters-container {
Expand Down Expand Up @@ -104,7 +108,8 @@
}

.segment-container {
margin-bottom: 64px;
overflow: scroll;
height: 100%;
}

.filter-container {
Expand All @@ -116,4 +121,7 @@
border-top: 1px solid var(--color-outline);
}
}
&:last-child {
margin-bottom: 16px;
}
}
Loading

0 comments on commit f51c165

Please sign in to comment.