main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 7 weeks ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
988 bytes
|
Line | |
---|
1 | import React, { useState, useEffect, useCallback } from "react";
|
---|
2 | import styles from "./FilterMaps.module.css";
|
---|
3 |
|
---|
4 | export default function FilterMaps({mapTypes,setFilter}) {
|
---|
5 | const [selectedCategory, setSelectedCategory] = useState("all");
|
---|
6 |
|
---|
7 |
|
---|
8 |
|
---|
9 | const mapFilter = useCallback((category) => {
|
---|
10 | setFilter(category)
|
---|
11 | setSelectedCategory(category);
|
---|
12 | },[])
|
---|
13 |
|
---|
14 | return (
|
---|
15 | <div className={styles.wrapper}>
|
---|
16 | <div className={styles.scrollableContainer}>
|
---|
17 | <button
|
---|
18 | className={`${styles.buttonValue} ${selectedCategory === "all" ? styles.active : ""}`}
|
---|
19 | onClick={() => mapFilter("all")}
|
---|
20 | >
|
---|
21 | All
|
---|
22 | </button>
|
---|
23 |
|
---|
24 | {mapTypes?.map((mapType, index) => (
|
---|
25 | <button
|
---|
26 | key={index}
|
---|
27 | className={`${styles.buttonValue} ${selectedCategory === mapType ? styles.active : ""}`}
|
---|
28 | onClick={() => mapFilter(mapType)}
|
---|
29 | >
|
---|
30 | {mapType}
|
---|
31 | </button>
|
---|
32 | ))}
|
---|
33 | </div>
|
---|
34 | </div>
|
---|
35 | );
|
---|
36 | }
|
---|
37 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.