Add SVG Sidebar
This commit is contained in:
parent
7e74be6d3b
commit
17aa2b0961
3 changed files with 45 additions and 11 deletions
32
src/App.tsx
32
src/App.tsx
|
@ -1,6 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import './App.scss';
|
import './App.scss';
|
||||||
import Sidebar from './Components/Sidebar/Sidebar';
|
import Sidebar from './Components/Sidebar/Sidebar';
|
||||||
|
import { SVGSidebar } from './Components/SVGSidebar/SVGSidebar';
|
||||||
import { AvailableContainer } from './Interfaces/AvailableContainer';
|
import { AvailableContainer } from './Interfaces/AvailableContainer';
|
||||||
import { Configuration } from './Interfaces/Configuration';
|
import { Configuration } from './Interfaces/Configuration';
|
||||||
import { SVG } from './SVG/SVG';
|
import { SVG } from './SVG/SVG';
|
||||||
|
@ -10,6 +11,7 @@ interface IAppProps {
|
||||||
|
|
||||||
interface IAppState {
|
interface IAppState {
|
||||||
isSidebarOpen: boolean,
|
isSidebarOpen: boolean,
|
||||||
|
isSVGSidebarOpen: boolean,
|
||||||
configuration: Configuration
|
configuration: Configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +22,7 @@ class App extends React.Component<IAppProps> {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
isSidebarOpen: true,
|
isSidebarOpen: true,
|
||||||
|
isSVGSidebarOpen: true,
|
||||||
configuration: {
|
configuration: {
|
||||||
AvailableContainers: [],
|
AvailableContainers: [],
|
||||||
AvailableSymbols: [],
|
AvailableSymbols: [],
|
||||||
|
@ -30,25 +33,34 @@ class App extends React.Component<IAppProps> {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
fetchConfiguration().then((configuration: Configuration) => {
|
fetchConfiguration().then((configuration: Configuration) => {
|
||||||
this.setState({
|
this.setState(prevState => ({
|
||||||
isSidebarOpen: this.state.isSidebarOpen,
|
...prevState,
|
||||||
configuration
|
configuration
|
||||||
});
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToggleMenu() {
|
public ToggleSidebar() {
|
||||||
this.setState({
|
this.setState(prevState => ({
|
||||||
isSidebarOpen: !this.state.isSidebarOpen,
|
...prevState,
|
||||||
configuration: this.state.configuration
|
isSidebarOpen: !this.state.isSidebarOpen
|
||||||
});
|
} as IAppState));
|
||||||
|
}
|
||||||
|
|
||||||
|
public ToggleSVGSidebar() {
|
||||||
|
this.setState(prevState => ({
|
||||||
|
...prevState,
|
||||||
|
isSVGSidebarOpen: !this.state.isSVGSidebarOpen
|
||||||
|
} as IAppState));
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="App font-sans h-full">
|
<div className="App font-sans h-full">
|
||||||
<Sidebar componentOptions={this.state.configuration.AvailableContainers} isOpen={this.state.isSidebarOpen} onClick={() => this.ToggleMenu()} />
|
<Sidebar componentOptions={this.state.configuration.AvailableContainers} isOpen={this.state.isSidebarOpen} onClick={() => this.ToggleSidebar()} />
|
||||||
<button className='fixed z-0 top-4 left-4 text-lg bg-slate-200 hover:bg-slate-300 transition-all drop-shadow-md hover:drop-shadow-lg py-2 px-3 rounded-lg' onClick={() => this.ToggleMenu()}>☰ Menu</button>
|
<button className='fixed z-0 top-4 left-4 text-lg bg-blue-200 hover:bg-blue-300 transition-all drop-shadow-md hover:drop-shadow-lg py-2 px-3 rounded-lg' onClick={() => this.ToggleSidebar()}>☰ Menu</button>
|
||||||
|
<SVGSidebar isOpen={this.state.isSVGSidebarOpen} onClick={() => this.ToggleSVGSidebar()}/>
|
||||||
|
<button className='fixed z-0 top-4 right-4 text-lg bg-slate-200 hover:bg-slate-300 transition-all drop-shadow-md hover:drop-shadow-lg py-2 px-3 rounded-lg' onClick={() => this.ToggleSVGSidebar()}>☰ Menu</button>
|
||||||
<SVG MainContainer={this.state.configuration.MainContainer} />
|
<SVG MainContainer={this.state.configuration.MainContainer} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
22
src/Components/SVGSidebar/SVGSidebar.tsx
Normal file
22
src/Components/SVGSidebar/SVGSidebar.tsx
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
|
interface ISVGSidebarProps {
|
||||||
|
isOpen: boolean;
|
||||||
|
onClick: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SVGSidebar extends React.Component<ISVGSidebarProps> {
|
||||||
|
public render() {
|
||||||
|
const isOpenClasses = this.props.isOpen ? 'right-0' : '-right-64';
|
||||||
|
return (
|
||||||
|
<div className={`fixed bg-slate-400 text-white transition-all h-screen w-64 overflow-y-auto z-10 ${isOpenClasses}`}>
|
||||||
|
<div className='w-full h-auto p-4 flex justify-start' onClick={this.props.onClick}>
|
||||||
|
<button className='text-lg'>×</button>
|
||||||
|
</div>
|
||||||
|
<div className='bg-slate-500 sidebar-row'>
|
||||||
|
Liste des éléments
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,7 @@ interface ISidebarProps {
|
||||||
export default class Sidebar extends React.Component<ISidebarProps> {
|
export default class Sidebar extends React.Component<ISidebarProps> {
|
||||||
public render() {
|
public render() {
|
||||||
const listElements = this.props.componentOptions.map(componentOption =>
|
const listElements = this.props.componentOptions.map(componentOption =>
|
||||||
<button className='hover:bg-blue-600 transition-all sidebar-row' key='{componentOption.Type}'>
|
<button className='hover:bg-blue-600 transition-all sidebar-row' key={componentOption.Type}>
|
||||||
{componentOption.Type}
|
{componentOption.Type}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue