Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
chgibb committed Sep 12, 2019
1 parent 87015e6 commit ff39ee7
Showing 1 changed file with 65 additions and 61 deletions.
@@ -1,23 +1,23 @@
import * as React from "react";
import Draggable from "react-draggable";
import { style } from "typestyle";
import {style} from "typestyle";

import { Drawer } from "../../../../components/drawer";
import { Grid } from "../../../../components/grid";
import { BorderLeftOutlined } from "../../../../components/icons/borderLeftOutlined";
import { IconButton } from "../../../../components/iconButton";
import { Paper, PaperProps } from "../../../../components/paper";
import { blue } from "../../../../styles/colours";
import { BorderTopOutlined } from "../../../../components/icons/borderTopOutlined";
import { BorderBottomOutlined } from "../../../../components/icons/borderBottomOutlined";
import { BorderRightOutlined } from "../../../../components/icons/borderRightOutlined";
import { BorderHorizontalOutlined } from "../../../../components/icons/borderHorizontalOutlined";
import { Dialog } from "../../../../components/dialog";
import { ChevronLeft } from "../../../../components/icons/chevronLeft";
import { ArrowUpwardOutlined } from "../../../../components/icons/arrowUpwareOutlined";
import { ArrowDownwardOutlined } from "../../../../components/icons/arrowDownwardOutlined";
import { ChevronRight } from "../../../../components/icons/chevronRight";
import { Close } from "../../../../components/icons/close";
import {Drawer} from "../../../../components/drawer";
import {Grid} from "../../../../components/grid";
import {BorderLeftOutlined} from "../../../../components/icons/borderLeftOutlined";
import {IconButton} from "../../../../components/iconButton";
import {Paper, PaperProps} from "../../../../components/paper";
import {blue} from "../../../../styles/colours";
import {BorderTopOutlined} from "../../../../components/icons/borderTopOutlined";
import {BorderBottomOutlined} from "../../../../components/icons/borderBottomOutlined";
import {BorderRightOutlined} from "../../../../components/icons/borderRightOutlined";
import {BorderHorizontalOutlined} from "../../../../components/icons/borderHorizontalOutlined";
import {Dialog} from "../../../../components/dialog";
import {ChevronLeft} from "../../../../components/icons/chevronLeft";
import {ArrowUpwardOutlined} from "../../../../components/icons/arrowUpwareOutlined";
import {ArrowDownwardOutlined} from "../../../../components/icons/arrowDownwardOutlined";
import {ChevronRight} from "../../../../components/icons/chevronRight";
import {Close} from "../../../../components/icons/close";

export type OverlayRestriction = "noDrawerLeft" | "noDrawerRight" | "noDrawerBottom" | "noDrawerTop" | "noModal";

Expand All @@ -30,7 +30,8 @@ export interface OverlayProps {
children: JSX.Element;
}

function DraggablePaper(props: PaperProps) {
function DraggablePaper(props: PaperProps)
{
return (
<Draggable cancel={"[class*=\"MuiDialogContent-root\"]"}>
<Paper {...props} />
Expand All @@ -43,16 +44,17 @@ function IconKindSelect(props: {
restrictions: OverlayProps["restrictions"],
setOverlayKind: (newKind: OverlayProps["kind"]) => void,
onClose: OverlayProps["onClose"]
}): JSX.Element {
}): JSX.Element
{
return (
<div
style={{ marginBottom: "3vh" }}>
style={{marginBottom: "3vh"}}>
<Grid container spacing={1} justify="flex-start">
<Grid item>
<IconButton
edge="start"
color={props.kind == "drawerLeft" ? "primary" : "default"}
classes={{ colorPrimary: blue }}
classes={{colorPrimary: blue}}
onClick={() => props.setOverlayKind("drawerLeft")}
>
<BorderLeftOutlined />
Expand All @@ -62,7 +64,7 @@ function IconKindSelect(props: {
<IconButton
edge="start"
color={props.kind == "drawerTop" ? "primary" : "default"}
classes={{ colorPrimary: blue }}
classes={{colorPrimary: blue}}
onClick={() => props.setOverlayKind("drawerTop")}
>
<BorderTopOutlined />
Expand All @@ -73,7 +75,7 @@ function IconKindSelect(props: {
<IconButton
edge="start"
color={props.kind == "drawerBottom" ? "primary" : "default"}
classes={{ colorPrimary: blue }}
classes={{colorPrimary: blue}}
onClick={() => props.setOverlayKind("drawerBottom")}
>
<BorderBottomOutlined />
Expand All @@ -82,7 +84,7 @@ function IconKindSelect(props: {
<IconButton
edge="start"
color={props.kind == "drawerRight" ? "primary" : "default"}
classes={{ colorPrimary: blue }}
classes={{colorPrimary: blue}}
onClick={() => props.setOverlayKind("drawerRight")}
>
<BorderRightOutlined />
Expand All @@ -92,7 +94,7 @@ function IconKindSelect(props: {
<IconButton
edge="start"
color={props.kind == "modal" ? "primary" : "default"}
classes={{ colorPrimary: blue }}
classes={{colorPrimary: blue}}
onClick={() => props.setOverlayKind("modal")}
>
<BorderHorizontalOutlined />
Expand All @@ -101,7 +103,7 @@ function IconKindSelect(props: {
<IconButton
edge="start"
color="primary"
classes={{ colorPrimary: blue }}
classes={{colorPrimary: blue}}
onClick={props.onClose}
>
{
Expand All @@ -123,47 +125,49 @@ const drawer = style({
marginTop: "6.5vh"
});

export function Overlay(props: OverlayProps): JSX.Element | null {
export function Overlay(props: OverlayProps): JSX.Element | null
{
let [kind, setKind] = React.useState(props.kind);

switch (kind) {
case "drawerLeft":
case "drawerTop":
case "drawerBottom":
case "drawerRight":
return (
<Drawer
anchor={
kind == "drawerLeft" ? "left" :
kind == "drawerTop" ? "top" :
kind == "drawerBottom" ? "bottom" :
kind == "drawerRight" ? "right" :
"left"
}
variant={props.open ? "permanent" : "temporary"}
open={props.open}
>
<div className={drawer}>
<React.Fragment>
<IconKindSelect kind={kind} restrictions={props.restrictions} setOverlayKind={setKind} onClose={props.onClose} />
{props.children}
</React.Fragment>
</div>
</Drawer>
);
case "modal":
return (
<Dialog
open={props.open}
PaperComponent={DraggablePaper}
hideBackdrop={true}
>
switch (kind)
{
case "drawerLeft":
case "drawerTop":
case "drawerBottom":
case "drawerRight":
return (
<Drawer
anchor={
kind == "drawerLeft" ? "left" :
kind == "drawerTop" ? "top" :
kind == "drawerBottom" ? "bottom" :
kind == "drawerRight" ? "right" :
"left"
}
variant={props.open ? "permanent" : "temporary"}
open={props.open}
>
<div className={drawer}>
<React.Fragment>
<IconKindSelect kind={kind} restrictions={props.restrictions} setOverlayKind={setKind} onClose={props.onClose} />
{props.children}
</React.Fragment>
</Dialog>
);
</div>
</Drawer>
);
case "modal":
return (
<Dialog
open={props.open}
PaperComponent={DraggablePaper}
hideBackdrop={true}
>
<React.Fragment>
<IconKindSelect kind={kind} restrictions={props.restrictions} setOverlayKind={setKind} onClose={props.onClose} />
{props.children}
</React.Fragment>
</Dialog>
);
}

return null;
Expand Down

0 comments on commit ff39ee7

Please sign in to comment.