Skip to content

Commit

Permalink
Merge branch 'main' into jonah/sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
brentyi authored Aug 3, 2023
2 parents 51016e8 + 1840578 commit 796a5cd
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 43 deletions.
2 changes: 2 additions & 0 deletions viser/_message_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,14 @@ def configure_theme(
control_type: Union[
Literal["floating"], Literal["collapsible"], Literal["fixed"]
] = "floating",
dark_mode: bool = False,
) -> None:
"""Configure the viser front-end's visual appearance."""
self._queue(
_messages.ThemeConfigurationMessage(
titlebar_content=titlebar_content,
control_type=control_type,
dark_mode=dark_mode,
),
)

Expand Down
1 change: 1 addition & 0 deletions viser/_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,4 @@ class ThemeConfigurationMessage(Message):

titlebar_content: Optional[theme.TitlebarConfig]
control_type: Union[Literal["floating"], Literal["collapsible"], Literal["fixed"]]
dark_mode: bool
90 changes: 47 additions & 43 deletions viser/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,32 +92,44 @@ function SingleViewer() {

const control_type = viewer.useGui((state) => state.theme.control_type);
return (
<ViewerContext.Provider value={viewer}>
<Titlebar />
<Box
sx={{
width: "100%",
height: "1px",
position: "relative",
flex: "1 0 auto",
display: "flex"
}}
>
<MediaQuery smallerThan={"xs"} styles={{ right: 0, bottom: "3.5em" }}>
<Box
sx={(theme) => ({
width: '1px',
flex: "1 0 auto",
backgroundColor:
theme.colorScheme === "light" ? "#fff" : theme.colors.dark[9],
})}
>
<ViewerCanvas>{memoizedWebsocketInterface}</ViewerCanvas>
</Box>
</MediaQuery>
<ControlPanel control_type={control_type} />
</Box>
</ViewerContext.Provider>
<MantineProvider
withGlobalStyles
withNormalizeCSS
theme={{
colorScheme: viewer.useGui((state) => state.theme.dark_mode)
? "dark"
: "light",
}}
>
<ViewerContext.Provider value={viewer}>
<Titlebar />
<Box
sx={{
width: "100%",
height: "1px",
position: "relative",
flex: "1 0 auto",
}}
>
<MediaQuery smallerThan={"xs"} styles={{ right: 0, bottom: "3.5em" }}>
<Box
sx={(theme) => ({
top: 0,
bottom: 0,
left: 0,
right: fixed_sidebar ? "20em" : 0,
position: "absolute",
backgroundColor:
theme.colorScheme === "light" ? "#fff" : theme.colors.dark[9],
})}
>
<ViewerCanvas>{memoizedWebsocketInterface}</ViewerCanvas>
</Box>
</MediaQuery>
<ControlPanel control_type={control_type} />
</Box>
</ViewerContext.Provider>
</MantineProvider>
);
}

Expand Down Expand Up @@ -172,24 +184,16 @@ function SceneContextSetter() {

export function Root() {
return (
<MantineProvider
withGlobalStyles
withNormalizeCSS
theme={{
colorScheme: "light",
<Box
sx={{
width: "100%",
height: "100%",
position: "relative",
display: "flex",
flexDirection: "column",
}}
>
<Box
sx={{
width: "100%",
height: "100%",
position: "relative",
display: "flex",
flexDirection: "column",
}}
>
<SingleViewer />
</Box>
</MantineProvider>
<SingleViewer />
</Box>
);
}
1 change: 1 addition & 0 deletions viser/client/src/ControlPanel/GuiState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const cleanGuiState: GuiState = {
type: "ThemeConfigurationMessage",
titlebar_content: null,
control_type: 'floating'
dark_mode: false,
},
label: "",
server: "ws://localhost:8080", // Currently this will always be overridden.
Expand Down
1 change: 1 addition & 0 deletions viser/client/src/WebsocketMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ export interface ThemeConfigurationMessage {
} | null;
} | null;
control_type: "floating" | "collapsible" | "fixed";
dark_mode: boolean;
}

export type Message =
Expand Down

0 comments on commit 796a5cd

Please sign in to comment.