-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
354 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { MswLogo } from "@/shared/icons" | ||
import { cn } from "@/shared/lib/cn" | ||
import { Button } from "@/shared/ui/button" | ||
import { ButtonHTMLAttributes } from "react" | ||
import { match } from "ts-pattern" | ||
import { Position } from ".." | ||
|
||
type DevtoolsFloatingButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & { | ||
position: Position | ||
} | ||
|
||
export const DevtoolsFloatingButton = ({ | ||
position = "bottom-right", | ||
...rest | ||
}: DevtoolsFloatingButtonProps) => { | ||
const positionClassName = match(position) | ||
.with("top-left", () => "top-[16px] left-[16px]") | ||
.with("top-right", () => "top-[16px] right-[16px]") | ||
.with("bottom-left", () => "bottom-[16px] left-[16px]") | ||
.with("bottom-right", () => "bottom-[16px] right-[16px]") | ||
.otherwise(() => "top-[16px] right-[16px]") | ||
|
||
return ( | ||
<div | ||
className={cn( | ||
"z-[100000] fixed p-[4px] text-left flex items-center justify-center rounded-full ", | ||
positionClassName | ||
)} | ||
> | ||
{/* TODO: LOGO CHANGE (temporary logo) */} | ||
<Button | ||
className="[&>svg]:absolute w-[64px] h-[64px] shadow-md shadow-black transition-transform duration-200 ease-in-out hover:scale-[1.02]" | ||
variant="destructive" | ||
{...rest} | ||
> | ||
<MswLogo /> | ||
</Button> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,49 @@ | ||
import { FixedLayout } from "@/shared/ui/FixedLayout" | ||
import { FixedLayout } from "@/shared/ui/fixed-layout" | ||
import { RouteEditPanel } from "./RouteEditPanel" | ||
import { Separator } from "@/shared/ui/separator" | ||
import { DevtoolsHandlerList } from "./DevtoolsHandlerList" | ||
import { MswControllerHeader } from "./MswControllerHeader" | ||
import { useEditorRouteState } from "@/providers/useMswDevtoolsContext" | ||
import { | ||
useEditorRouteState, | ||
useFloatingState, | ||
} from "@/providers/useMswDevtoolsContext" | ||
import { DevtoolsFloatingButton } from "./DevtoolsFloatingButton" | ||
import { Position } from ".." | ||
|
||
export const MSWDevtoolsPanel = () => { | ||
type MSWDevtoolsPanelProps = { | ||
position?: Position | ||
} | ||
|
||
export const MSWDevtoolsPanel = ({ | ||
position = "bottom-right", | ||
}: MSWDevtoolsPanelProps) => { | ||
const { isOpenEditorPanel } = useEditorRouteState() | ||
const { isFloatingOpen, setIsFloatingOpen } = useFloatingState() | ||
|
||
return ( | ||
<FixedLayout> | ||
{isOpenEditorPanel ? ( | ||
<RouteEditPanel /> | ||
<> | ||
{isFloatingOpen ? ( | ||
<FixedLayout> | ||
{isOpenEditorPanel ? ( | ||
<RouteEditPanel /> | ||
) : ( | ||
<> | ||
<MswControllerHeader /> | ||
<Separator /> | ||
<div className="p-[16px] h-full"> | ||
<DevtoolsHandlerList /> | ||
</div> | ||
</> | ||
)} | ||
</FixedLayout> | ||
) : ( | ||
<> | ||
<MswControllerHeader /> | ||
<Separator /> | ||
<div className="p-[16px]"> | ||
<DevtoolsHandlerList /> | ||
</div> | ||
</> | ||
<DevtoolsFloatingButton | ||
position={position} | ||
onClick={() => { | ||
setIsFloatingOpen(true) | ||
}} | ||
/> | ||
)} | ||
</FixedLayout> | ||
</> | ||
) | ||
} |
Oops, something went wrong.