Skip to content

Commit 2b2113a

Browse files
committed
style: Updated Filters menu to no longer use "offcanvas"
to prevent being hidden by elements on the host site
1 parent 22d579c commit 2b2113a

File tree

4 files changed

+49
-27
lines changed

4 files changed

+49
-27
lines changed

index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css"
1414
/>
1515
<script type="module">
16-
const baseUrl = "http://localhost:63313/dist";
16+
const baseUrl = "http://localhost:53956/dist";
1717
import {
1818
onRampsResourceCatalog,
1919
shadowTarget,
20-
} from "http://localhost:63313/dist/xras-ui.js";
20+
} from "http://localhost:53956/dist/xras-ui.js";
2121
onRampsResourceCatalog({
2222
target: shadowTarget(
2323
document.getElementById("resource-catalog-react"),
+26-22
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,43 @@
1-
import React, { useState } from "react";
1+
import React, { useRef, useState } from "react";
22
import Filters from "./Filters";
3-
import { Offcanvas } from "react-bootstrap";
3+
import styles from "./ResourceCatalog.module.scss";
44

55
const FilterBar = () => {
66
const [show, setShow] = useState(false);
7-
const handleClose = () => setShow(false);
8-
const handleOpen = () => setShow(true);
7+
const menuRef = useRef(null);
8+
9+
const toggleMenu = () => {
10+
const menu = menuRef.current
11+
if(!show){
12+
menu.style.height = menu.scrollHeight + "px";
13+
menu.classList.remove(styles.filtersHidden);
14+
menu.classList.add(styles.filtersVisible);
15+
} else {
16+
menu.style.height = '0px';
17+
menu.classList.remove(styles.filtersVisible);
18+
menu.classList.add(styles.filtersHidden);
19+
}
20+
21+
setShow(!show);
22+
23+
}
924

1025
return (
11-
<>
12-
<div className={`offcanvas offcanvas-start ${show ? 'show' : ''}`} tabIndex="-1" id="offcanvas" aria-labelledby="offcanvasLabel">
13-
<div className="offcanvas-header">
14-
<h5 className="offcanvas-title" id="offcanvasLabel">Filters</h5>
15-
<button
16-
type="button"
17-
className="btn-close"
18-
onClick={handleClose}
19-
aria-label="Close"></button>
20-
</div>
21-
<div className="offcanvas-body">
22-
<Filters />
23-
</div>
24-
</div>
26+
<div className={styles.filterBar}>
2527
<div className={`row mb-2`}>
2628
<div className="col pt-2 pb-2">
2729
<div className="p-1 pb-0 border-bottom bg-white shadow">
28-
<button className="btn btn-outline-primary mb-1 mt-1" type="button" onClick={handleOpen}>
30+
<button className="btn btn-outline-primary mb-1 mt-1" type="button" onClick={toggleMenu}>
2931
<i className="bi bi-filter"></i> Filters
3032
</button>
33+
<div className={`${styles.filtersHidden} pe-2 ps-2`} id="filtersList" ref={menuRef}>
34+
<Filters onReset={toggleMenu} />
35+
</div>
3136
</div>
3237
</div>
3338
</div>
34-
35-
</>
36-
)
39+
</div>
40+
);
3741
}
3842

3943
export default FilterBar;

src/onramps-resource-catalog/Filters.jsx

+10-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { resetFilters, selectFilters, selectCatalogs } from "./helpers/catalogSl
33
import FilterCategory from "./FilterCategory";
44
import CatalogList from "./CatalogList";
55

6-
const Filters = () => {
6+
const Filters = ({ onReset }) => {
77
const dispatch = useDispatch();
88
const catalogs = useSelector( selectCatalogs );
99
const filters = useSelector( selectFilters );
@@ -14,7 +14,7 @@ const Filters = () => {
1414
const catalogFilters = Object.keys(catalogs).map((c) => catalogs[c]);
1515

1616
return (
17-
<div>
17+
<>
1818
{/* {catalogFilters.length > 0 ? <CatalogList catalogs={catalogFilters} /> : ''} */}
1919
{filters.map((f) => (
2020
<FilterCategory category={f} key={f.categoryId} />
@@ -26,7 +26,14 @@ const Filters = () => {
2626
>
2727
Reset Filters
2828
</button>
29-
</div>
29+
30+
<button
31+
className="btn btn-outline-primary ms-3 mt-2 mb-2"
32+
onClick={onReset}
33+
>
34+
Close Menu
35+
</button>
36+
</>
3037
);
3138
};
3239

src/onramps-resource-catalog/ResourceCatalog.module.scss

+11
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,14 @@ $warning: #ef7537;
5454
background-color: #fecd4d !important;
5555
border-color: #feca42 !important;
5656
}
57+
58+
.filtersHidden {
59+
height: 0px;
60+
overflow: hidden;
61+
transition: height 0.5s ease-out;
62+
}
63+
64+
.filtersVisible {
65+
height: auto;
66+
transition: height 0.5s ease-out;
67+
}

0 commit comments

Comments
 (0)