diff --git a/src/App.tsx b/src/App.tsx index 8a0893d..89fae1a 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,7 @@ import React from 'react'; import './App.scss'; import Sidebar from './Components/Sidebar/Sidebar'; +import { SVGSidebar } from './Components/SVGSidebar/SVGSidebar'; import { AvailableContainer } from './Interfaces/AvailableContainer'; import { Configuration } from './Interfaces/Configuration'; import { SVG } from './SVG/SVG'; @@ -10,6 +11,7 @@ interface IAppProps { interface IAppState { isSidebarOpen: boolean, + isSVGSidebarOpen: boolean, configuration: Configuration } @@ -20,6 +22,7 @@ class App extends React.Component { super(props); this.state = { isSidebarOpen: true, + isSVGSidebarOpen: true, configuration: { AvailableContainers: [], AvailableSymbols: [], @@ -30,25 +33,34 @@ class App extends React.Component { componentDidMount() { fetchConfiguration().then((configuration: Configuration) => { - this.setState({ - isSidebarOpen: this.state.isSidebarOpen, + this.setState(prevState => ({ + ...prevState, configuration - }); + })); }); } - public ToggleMenu() { - this.setState({ - isSidebarOpen: !this.state.isSidebarOpen, - configuration: this.state.configuration - }); + public ToggleSidebar() { + this.setState(prevState => ({ + ...prevState, + isSidebarOpen: !this.state.isSidebarOpen + } as IAppState)); + } + + public ToggleSVGSidebar() { + this.setState(prevState => ({ + ...prevState, + isSVGSidebarOpen: !this.state.isSVGSidebarOpen + } as IAppState)); } render() { return (
- this.ToggleMenu()} /> - + this.ToggleSidebar()} /> + + this.ToggleSVGSidebar()}/> +
); diff --git a/src/Components/SVGSidebar/SVGSidebar.tsx b/src/Components/SVGSidebar/SVGSidebar.tsx new file mode 100644 index 0000000..2a00072 --- /dev/null +++ b/src/Components/SVGSidebar/SVGSidebar.tsx @@ -0,0 +1,22 @@ +import * as React from 'react'; + +interface ISVGSidebarProps { + isOpen: boolean; + onClick: () => void; +} + +export class SVGSidebar extends React.Component { + public render() { + const isOpenClasses = this.props.isOpen ? 'right-0' : '-right-64'; + return ( +
+
+ +
+
+ Liste des éléments +
+
+ ); + } +} diff --git a/src/Components/Sidebar/Sidebar.tsx b/src/Components/Sidebar/Sidebar.tsx index c8fd740..41bcd14 100644 --- a/src/Components/Sidebar/Sidebar.tsx +++ b/src/Components/Sidebar/Sidebar.tsx @@ -10,7 +10,7 @@ interface ISidebarProps { export default class Sidebar extends React.Component { public render() { const listElements = this.props.componentOptions.map(componentOption => - );