Skip to content

Commit b00ab28

Browse files
Add star filters
1 parent a1989f1 commit b00ab28

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/components/mountains/RoutesFilter.svelte

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
ice,
1515
mixed,
1616
scrollPos,
17+
minStars,
18+
maxStars,
1719
} from '../../stores/mountainFilters'
1820
import Card from '../Card.svelte'
1921
import { fromLonLat } from 'ol/proj'
@@ -54,6 +56,7 @@
5456
(m.latlng &&
5557
containsCoordinate($extent, fromLonLat([m.latlng[1], m.latlng[0]])))
5658
)
59+
// Filter grade
5760
.filter(([, r]) => {
5861
// If we aren't filtering by anything, include everything.
5962
if (!$alpine && !$rock && !$ice && !$mixed) return true
@@ -66,6 +69,12 @@
6669
(grade.mixed && $mixed)
6770
)
6871
})
72+
// Filter stars
73+
.filter(([,r]) => {
74+
if ($minStars !== 'any' && r.quality < $minStars) return false
75+
if ($maxStars !== 'any' && r.quality > $maxStars) return false
76+
return true
77+
})
6978
7079
let sorted: Route[] = []
7180
</script>
@@ -105,6 +114,30 @@
105114
<input type="checkbox" bind:checked={$mixed} />
106115
</label>
107116
</div>
117+
<details>
118+
<summary> Stars </summary>
119+
<div class="flex flex-col">
120+
<label>
121+
Min:
122+
<select bind:value={$minStars}>
123+
<option value='any'>Any</option>
124+
<option value={1}>1</option>
125+
<option value={2}>2</option>
126+
<option value={3}>3</option>
127+
</select>
128+
</label>
129+
<label>
130+
Max:
131+
<select bind:value={$maxStars}>
132+
<option value='any'>Any</option>
133+
<option>0</option>
134+
<option>1</option>
135+
<option>2</option>
136+
<option>3</option>
137+
</select>
138+
</label>
139+
</div>
140+
</details>
108141
<SortyBy
109142
options={[
110143
{ name: 'name', getter: ([m, r]) => r.name },

src/stores/mountainFilters.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ export const alpine = writable(false)
1212
export const rock = writable(false)
1313
export const ice = writable(false)
1414
export const mixed = writable(false)
15+
16+
export const minStars = writable<'any' | 1 | 2 | 3>('any');
17+
export const maxStars = writable<'any' | 0 | 1 | 2 | 3>('any');

0 commit comments

Comments
 (0)