Skip to content

Commit

Permalink
feat: Add menuOpen option
Browse files Browse the repository at this point in the history
  • Loading branch information
manzt committed Jul 17, 2024
1 parent 9db1270 commit 5c6d5b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const useStyles = makeStyles({
},
});

function Menu() {
function Menu(props: { open?: boolean }) {
const sourceAtoms = useAtomValue(sourceInfoAtomAtoms);
const [hidden, toggle] = useReducer((v) => !v, false);
const [hidden, toggle] = useReducer((v) => !v, !(props.open ?? true));
const classes = useStyles();
return (
<div className={classes.root} style={{ padding: `0px 5px ${hidden ? 0 : 5}px 5px` }}>
Expand Down
4 changes: 2 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface VizarrViewer {
destroy(): void;
}

export function createViewer(element: HTMLElement): Promise<VizarrViewer> {
export function createViewer(element: HTMLElement, options: { menuOpen?: boolean } = {}): Promise<VizarrViewer> {
const ref = React.createRef<VizarrViewer>();
const emitter = typedEmitter<Events>();
const viewStateAtom = atomWithEffect<ViewState | undefined, ViewState>(
Expand Down Expand Up @@ -55,7 +55,7 @@ export function createViewer(element: HTMLElement): Promise<VizarrViewer> {
}, []);
return (
<>
<Menu />
<Menu open={options.menuOpen ?? true} />
<Viewer viewStateAtom={viewStateAtom} />
</>
);
Expand Down

0 comments on commit 5c6d5b6

Please sign in to comment.