Skip to content

Commit

Permalink
add toggle for edit mode, disabled in prod
Browse files Browse the repository at this point in the history
  • Loading branch information
vmork committed Sep 13, 2024
1 parent 779e972 commit 7d4004e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/app/student/map/_components/MainView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ import {
import { useState } from "react"
import { BoothID, BoothMap } from "../lib/booths"
import { LocationId, locations } from "../lib/locations"
import { Button } from "@/components/ui/button"

export default function MainView({
boothsByLocation,
boothsById,
exhibitorsById,
editorMode = false
exhibitorsById
}: {
boothsByLocation: Map<LocationId, BoothMap>
boothsById: BoothMap
exhibitorsById: Map<number, Exhibitor>
editorMode?: boolean
}) {
const [locationId, setLocationId] = useState<LocationId>("nymble/1")
const location = locations.find(loc => loc.id === locationId)!
Expand All @@ -33,6 +32,8 @@ export default function MainView({
const [activeBoothId, setActiveBoothId] = useState<BoothID | null>(null)
const [hoveredBoothId, setHoveredBoothId] = useState<BoothID | null>(null)

const [editorMode, setEditorMode] = useState(false)

return (
<div className="relative flex h-full w-full">
{!editorMode ? (
Expand Down Expand Up @@ -63,10 +64,22 @@ export default function MainView({
/>
)}

{process.env.NODE_ENV === "development" && <EditorToggle />}

<SelectLocation />
</div>
)

function EditorToggle() {
return (
<Button
className="absolute bottom-2 left-2"
onClick={() => setEditorMode(prev => !prev)}>
{editorMode ? "Switch to normal mode" : "Switch to edit mode"}
</Button>
)
}

function SelectLocation() {
return (
<div className="absolute top-2 justify-self-center rounded-full sm:right-2">
Expand Down

0 comments on commit 7d4004e

Please sign in to comment.