Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/ui/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ function SidebarSettings() {
store,
(state) => state.restoreParamsDefault
);
const isSidebarOnLeftHand = useStore(
store,
(state) => state.isSidebarOnLeftHand
);
const setIsSidebarOnLeftHand = useStore(
store,
(state) => state.setIsSidebarOnLeftHand
);

return (
<Box>
Expand All @@ -113,6 +121,26 @@ function SidebarSettings() {
/>
</FormGroup>
</Tooltip>
<Tooltip
title={
"When turned off, the Sidebar appears at the right end of the screen."
}
disableInteractive
>
<FormControlLabel
control={
<Switch
checked={isSidebarOnLeftHand}
size="small"
color="warning"
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
setIsSidebarOnLeftHand(event.target.checked);
}}
/>
}
label="Sidebar on the Lefthand Side"
/>
</Tooltip>
<Tooltip
title={"Enable Debug Mode, e.g., show pod IDs"}
disableInteractive
Expand Down
9 changes: 9 additions & 0 deletions packages/ui/src/lib/store/settingSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export interface SettingSlice {
setContextualZoom: (b: boolean) => void;
showLineNumbers?: boolean;
setShowLineNumbers: (b: boolean) => void;
isSidebarOnLeftHand: boolean;
setIsSidebarOnLeftHand: (b: boolean) => void;
}

export const createSettingSlice: StateCreator<MyState, [], [], SettingSlice> = (
Expand Down Expand Up @@ -143,4 +145,11 @@ export const createSettingSlice: StateCreator<MyState, [], [], SettingSlice> = (
JSON.stringify({ ...updatedParams })
);
},
isSidebarOnLeftHand: localStorage.getItem("isSidebarOnLeftHand")
? JSON.parse(localStorage.getItem("isSidebarOnLeftHand")!)
: false,
setIsSidebarOnLeftHand: (b: boolean) => {
set({ isSidebarOnLeftHand: b });
localStorage.setItem("isSidebarOnLeftHand", JSON.stringify(b));
},
});
23 changes: 20 additions & 3 deletions packages/ui/src/pages/repo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ function RepoHeader({ id }) {
* Wrap the repo page with a header, a sidebar and a canvas.
*/
function HeaderWrapper({ children, id }) {
const store = useContext(RepoContext)!;
const isSidebarOnLeftHand = useStore(
store,
(state) => state.isSidebarOnLeftHand
);
const [open, setOpen] = useState(true);
let sidebar_width = "240px";
let header_height = "50px";
Expand All @@ -240,7 +245,7 @@ function HeaderWrapper({ children, id }) {
},
}}
variant="persistent"
anchor="right"
anchor={isSidebarOnLeftHand ? "left" : "right"}
open={open}
>
<Box
Expand All @@ -263,7 +268,8 @@ function HeaderWrapper({ children, id }) {
position: "absolute",
margin: "5px",
top: header_height,
right: open ? sidebar_width : 0,
...(isSidebarOnLeftHand && { left: open ? sidebar_width : 0 }),
...(!isSidebarOnLeftHand && { right: open ? sidebar_width : 0 }),
transition: "all .2s",
zIndex: 100,
}}
Expand All @@ -275,7 +281,17 @@ function HeaderWrapper({ children, id }) {
size="small"
color="primary"
>
{open ? <ChevronRightIcon /> : <ChevronLeftIcon />}
{isSidebarOnLeftHand ? (
open ? (
<ChevronLeftIcon />
) : (
<ChevronRightIcon />
)
) : open ? (
<ChevronRightIcon />
) : (
<ChevronLeftIcon />
)}
</IconButton>
</Box>

Expand All @@ -286,6 +302,7 @@ function HeaderWrapper({ children, id }) {
flexGrow: 1,
verticalAlign: "top",
height: "100%",
...(isSidebarOnLeftHand && { ml: open ? sidebar_width : 0 }),
width: open ? `calc(100% - ${sidebar_width})` : "100%",
overflow: "scroll",
}}
Expand Down