add ability to show/hide sidebar
This commit is contained in:
parent
58d46ff640
commit
34bd1bf63b
|
@ -6,8 +6,8 @@ import { Dispatch } from 'redux';
|
||||||
import * as sanitize from 'sanitize-html';
|
import * as sanitize from 'sanitize-html';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AnchorButton, Card, Classes, Divider, Elevation, HTMLTable, NonIdealState, Position, Tab, Tabs,
|
AnchorButton, Button, Card, Classes, Divider, Elevation, HTMLTable, NonIdealState, Position,
|
||||||
Tooltip
|
Tab, Tabs, Tooltip
|
||||||
} from '@blueprintjs/core';
|
} from '@blueprintjs/core';
|
||||||
import { IconNames } from '@blueprintjs/icons';
|
import { IconNames } from '@blueprintjs/icons';
|
||||||
|
|
||||||
|
@ -21,15 +21,40 @@ interface ISidebarProps {
|
||||||
isLoadingInstanceDetails: boolean;
|
isLoadingInstanceDetails: boolean;
|
||||||
selectAndLoadInstance: (instanceName: string) => void;
|
selectAndLoadInstance: (instanceName: string) => void;
|
||||||
}
|
}
|
||||||
class SidebarImpl extends React.Component<ISidebarProps> {
|
interface ISidebarState {
|
||||||
|
isOpen: boolean;
|
||||||
|
}
|
||||||
|
class SidebarImpl extends React.Component<ISidebarProps, ISidebarState> {
|
||||||
|
|
||||||
|
constructor(props: ISidebarProps) {
|
||||||
|
super(props);
|
||||||
|
const isOpen = window.innerWidth >= 900 ? true : false;
|
||||||
|
this.state = { isOpen };
|
||||||
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
|
const closedClass = this.state.isOpen ? "" : " closed";
|
||||||
|
const buttonIcon = this.state.isOpen ? IconNames.DOUBLE_CHEVRON_RIGHT : IconNames.DOUBLE_CHEVRON_LEFT;
|
||||||
return (
|
return (
|
||||||
<Card className="fediverse-sidebar" elevation={Elevation.THREE}>
|
<div>
|
||||||
|
<Button
|
||||||
|
onClick={this.handleToggle}
|
||||||
|
large={true}
|
||||||
|
icon={buttonIcon}
|
||||||
|
className={"fediverse-sidebar-toggle-button" + closedClass}
|
||||||
|
minimal={true}
|
||||||
|
/>
|
||||||
|
<Card className={"fediverse-sidebar" + closedClass} elevation={Elevation.THREE}>
|
||||||
{this.renderSidebarContents()}
|
{this.renderSidebarContents()}
|
||||||
</Card>
|
</Card>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private handleToggle = () => {
|
||||||
|
this.setState({ isOpen: !this.state.isOpen });
|
||||||
|
}
|
||||||
|
|
||||||
private renderSidebarContents = () => {
|
private renderSidebarContents = () => {
|
||||||
if (this.props.isLoadingInstanceDetails) {
|
if (this.props.isLoadingInstanceDetails) {
|
||||||
return this.renderLoadingState();
|
return this.renderLoadingState();
|
||||||
|
|
|
@ -27,13 +27,44 @@ html, body {
|
||||||
top: 50px;
|
top: 50px;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
min-width: 300px;
|
min-width: 400px;
|
||||||
width: 25%;
|
width: 25%;
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
overflow: scroll;
|
overflow: scroll;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
|
transition-property: all;
|
||||||
|
transition-duration: .5s;
|
||||||
|
transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fediverse-sidebar.closed {
|
||||||
|
right: -400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fediverse-sidebar-toggle-button {
|
||||||
|
position: absolute;
|
||||||
|
top: 50px;
|
||||||
|
right:400px;
|
||||||
|
z-index: 20;
|
||||||
|
transition-property: all;
|
||||||
|
transition-duration: .5s;
|
||||||
|
transition-timing-function: cubic-bezier(0, 1, 0.5, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fediverse-sidebar-toggle-button.closed {
|
||||||
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.fediverse-sidebar-table {
|
.fediverse-sidebar-table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 1600px) {
|
||||||
|
.fediverse-sidebar.closed {
|
||||||
|
right: -25%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fediverse-sidebar-toggle-button {
|
||||||
|
right: 25%;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue