Skip to content

Commit

Permalink
Sidebar: Access typed controls state within component
Browse files Browse the repository at this point in the history
Instead of passing down from Main.

Also take the opportunity to convert this file to TypeScript.
  • Loading branch information
victorlin committed Oct 23, 2023
1 parent de36e48 commit f965ddf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/components/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,9 @@ class Main extends React.Component {
handler={this.toggleSidebar}
/>
<Sidebar
sidebarOpen={this.props.sidebarOpen}
width={sidebarWidth}
height={availableHeight}
displayNarrative={this.props.displayNarrative}
panelsToDisplay={this.props.panelsToDisplay}
narrativeTitle={this.props.narrativeTitle}
navBarHandler={this.toggleSidebar}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import React from "react";
import { useSelector } from "react-redux";
import {ThemeProvider} from 'styled-components';
import Narrative from "../narrative";
import NavBar from "../navBar";
import Controls from "../controls/controls";
import { SidebarContainer, sidebarTheme } from "./styles";
import { narrativeNavBarHeight } from "../../util/globals";
import { RootState } from "../../store";


export const Sidebar = (
{sidebarOpen, width, height, displayNarrative, panelsToDisplay, narrativeTitle, navBarHandler}
{ width, height, displayNarrative, narrativeTitle, navBarHandler}
) => {
const sidebarOpen = useSelector((state: RootState) => state.controls.sidebarOpen);
const panelsToDisplay = useSelector((state: RootState) => state.controls.panelsToDisplay);

return (
<ThemeProvider theme={sidebarTheme}>
<SidebarContainer left={sidebarOpen ? 0 : -1 * width} width={width} height={height}>
Expand Down

0 comments on commit f965ddf

Please sign in to comment.