Skip to content

Commit

Permalink
Add query params allowing to force display of UI control
Browse files Browse the repository at this point in the history
  • Loading branch information
vhiribarren committed Jan 20, 2024
1 parent 1feab1a commit 1721bdb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/shaders/FragmentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IconAdjustments } from "@tabler/icons-react";
import styles from "./FragmentView.module.css";
import tunnel from "tunnel-rat";
import { UniformsContext } from "./uniforms";
import { useSearchParams } from "next/navigation";


type ChildrenProps = {
Expand Down Expand Up @@ -47,6 +48,11 @@ export function FragmentView({
const Control = control;
const ui = tunnel();

const searchParams = useSearchParams();
const hasWithControlQueryParam = searchParams.has("withControl");

const displayControl = hasWithControlQueryParam || withUi;

const [loadFragment, setLoadFragment] = useState(control ? false : true);
const [uniforms, setUniforms] = useState({});
const addUniform = (uniformName: string, defaultValue: any) => {
Expand Down Expand Up @@ -88,7 +94,7 @@ export function FragmentView({
}
</FragmentCanvas>

{withUi &&
{ displayControl &&
<Drawer
classNames={{ root: styles.drawerRoot, inner: styles.drawerInner, content: styles.drawerContent }}
title="Parameters"
Expand All @@ -110,7 +116,7 @@ export function FragmentView({

</Flex>

{!isDrawerOpened && withUi &&
{!isDrawerOpened && displayControl &&
<Affix position={{ bottom: 20, right: 20 }}>
<ActionIcon onClick={openDrawer} variant="filled" size="xl" radius="xl" aria-label="Settings">
<IconAdjustments style={{ width: "70%", height: "70%" }} stroke={1.5} />
Expand Down

0 comments on commit 1721bdb

Please sign in to comment.