Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Simple drawer component #2843

Merged
merged 8 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions assets/css/_drawer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* Panel + Drawer(2rem) should have 100% viewport width - 10px to match leaflet margin */
$map-page-search-panel-width: Min(24rem, calc((100vw - 2rem - 10px)));

$z-map-page-context: (
"drawer-backdrop": 199,
"drawer": 200,
);

.c-drawer {
width: $map-page-search-panel-width;
height: 100%;
background-color: $color-gray-50;
position: relative;
z-index: map-get($z-map-page-context, "drawer");
transition: $transition-slide;

&--visible {
left: 0;
}

&--hidden {
width: $map-page-search-panel-width;
left: calc(-1 * #{$map-page-search-panel-width});
}
}

.c-drawer .c-drawer-tab {
@include button-primary-new;
left: 100%;
}

.c-drawer__backdrop-button {
display: none;

.c-drawer--visible ~ & {
display: block;
width: 100%;

// Ignore flex layout and fill screen
position: absolute;
inset: 48.8px 0 0 0;

// Inbetween panel and map
z-index: map-get($z-map-page-context, "drawer-backdrop");

backdrop-filter: blur(3.25px);
}
}
1 change: 0 additions & 1 deletion assets/css/_drawer_tab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
}

.c-drawer-tab__tab-button {
@include button-transparent;
firestack marked this conversation as resolved.
Show resolved Hide resolved
@include button-icon(0.9rem);
font-size: 2rem;
line-height: 1.5rem;
Expand Down
1 change: 1 addition & 0 deletions assets/css/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ $vpp-location-padding: 1rem;
@import "directions_button";
@import "disconnected_modal";
@import "diversion_page";
@import "drawer";
@import "drawer_tab";
@import "dropdown";
@import "filter_accordion";
Expand Down
31 changes: 31 additions & 0 deletions assets/src/components/drawer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React, { ReactElement, useState } from "react"
import DrawerTab from "../components/drawerTab"
import { joinClasses } from "../helpers/dom"

interface Props {
children?: ReactElement<HTMLElement>
}

const Drawer = ({ children }: Props): ReactElement<HTMLDivElement> => {
const [drawerOpen, setDrawerOpen] = useState(true)
const toggleDrawer = () => setDrawerOpen((drawerOpen) => !drawerOpen)
hannahpurcell marked this conversation as resolved.
Show resolved Hide resolved

return (
<>
<div
className={joinClasses([
"c-drawer",
...(drawerOpen
? ["c-drawer--visible"]
: ["c-drawer--hidden", "u-hideable--hidden"]),
])}
>
<DrawerTab isVisible={drawerOpen} toggleVisibility={toggleDrawer} />
{children}
</div>
<button onClick={toggleDrawer} className="c-drawer__backdrop-button" />
</>
)
}

export default Drawer
hannahpurcell marked this conversation as resolved.
Show resolved Hide resolved
Loading