Last active
April 29, 2020 22:57
-
-
Save lighth7015/3de9493b335a3179b4edfdf3a5cd8708 to your computer and use it in GitHub Desktop.
Menu component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from "preact"; | |
import { h, Fragment } from "preact"; | |
import Match from "preact-router/match"; | |
import { forwardRef } from "preact/compat"; | |
import { Link } from "preact-router/match"; | |
import Slide from "@material-ui/core/Slide"; | |
import Drawer from "@material-ui/core/Drawer"; | |
import Divider from "@material-ui/core/Divider"; | |
import List from "@material-ui/core/List"; | |
import ListItem from "@material-ui/core/ListItem"; | |
import ListItemIcon from "@material-ui/core/ListItemIcon"; | |
import ListItemText from "@material-ui/core/ListItemText"; | |
import ListItemSecondaryAction from "@material-ui/core/ListItemSecondaryAction"; | |
import KeyboardArrowLeft from "@material-ui/icons/KeyboardArrowLeft"; | |
import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight"; | |
import Typography from "@material-ui/core/Typography"; | |
import SvgIconType from "@material-ui/core/SvgIcon"; | |
import { TransitionProps } from "@material-ui/core/transitions"; | |
import { useDrawerStyles } from "style/styles"; | |
type SvgIcon = typeof SvgIconType; | |
function len(t: any[]): number { | |
return t && t.length || 0; | |
} | |
/* | |
const Transition = forwardRef(function Transition( | |
props: TransitionProps & { children?: React.ReactElement<any, any> }, | |
ref: React.Ref<unknown> | |
) { | |
return <Slide direction="up" ref={ref} {...props} />; | |
}); | |
*/ | |
interface AppDrawerProps { | |
opened?: boolean; | |
shouldCollapse: boolean; | |
} | |
interface AppDrawerState { | |
current: Array<number>; | |
} | |
enum MenuTypes { Category, MenuItem, Divider } | |
interface RouteProps { | |
matches: boolean; | |
path: string; | |
url: string; | |
} | |
interface MenuItem { | |
type: MenuTypes; | |
title?: string; | |
route?: string; | |
image?: SvgIcon; | |
items?: Array<number>; | |
} | |
interface NavItem { | |
type: MenuTypes; | |
title: string; | |
index: number; | |
route?: string; | |
image?: SvgIcon; | |
} | |
type MenuEntries = Array<NavItem>; | |
type ReducerIterator<T = any> = ( items: Array<T>, child: T, indexOf: number ) => Array<T>; | |
type SetStateFunc = (state: AppDrawerState) => void; | |
interface MenuEntryProps { | |
current: Array<number>; | |
children: MenuEntries; | |
onUpdate: SetStateFunc; | |
selection: NavItem; | |
} | |
interface InlineStyle { | |
[prop: string]: any; | |
} | |
interface StyleContainer { | |
[prop: string]: InlineStyle; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current compile "errors"