Skip to content

Commit

Permalink
Merge pull request #1 from mikengu/dev
Browse files Browse the repository at this point in the history
feat(sidebar): change arrow indicators
  • Loading branch information
mikengu authored Jan 20, 2020
2 parents 33c40a2 + 30c34f7 commit 7593e5f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions src/components/sidebar/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {Fragment, useState} from 'react'
import PropTypes from 'prop-types'
import List from '@material-ui/core/List'
import {ListItem, ListItemText, Collapse, ListItemIcon, makeStyles} from '@material-ui/core'
import {ExpandLess, ExpandMore} from '@material-ui/icons'
import {ArrowRight, ArrowDropDown} from '@material-ui/icons'
import './sidebar.css'

const darkTheme = {
Expand All @@ -20,7 +20,7 @@ function SidebarItem ({label, name, items, depthStep = 10, depth = 0, Icon}) {
[name]: !currentState[name]
}))
}
const expandBtn = open => open ? <ExpandLess /> : <ExpandMore />
const expandBtn = open => !open ? <ArrowDropDown /> : <ArrowRight />
return (
<Fragment>
<ListItem onClick={handleClick} button dense>
Expand Down Expand Up @@ -54,16 +54,17 @@ function SidebarItem ({label, name, items, depthStep = 10, depth = 0, Icon}) {
SidebarItem.propTypes = {
label: PropTypes.string,
name: PropTypes.string,
Icon: PropTypes.node,
items: PropTypes.array,
depth: PropTypes.number,
theme: PropTypes.object,
depthStep: PropTypes.number
}

function Sidebar ({items, theme, icon, width}) {
function Sidebar ({items, theme, backgroundColor, style, icon, width}) {
const useStyles = makeStyles(material => {
let themeColor = {
backgroundColor: material.palette.background.paper,
backgroundColor: backgroundColor || material.palette.background.paper,
color: '#000'
}
if (theme === 'dark') {
Expand All @@ -73,6 +74,7 @@ function Sidebar ({items, theme, icon, width}) {
root: {
width: width,
maxWidth: width,
...style,
...themeColor
},
nested: {
Expand Down Expand Up @@ -110,6 +112,7 @@ Sidebar.propTypes = {
height: PropTypes.string,
items: PropTypes.array,
onClick: PropTypes.func,
style: PropTypes.object,
theme: PropTypes.string,
width: PropTypes.string
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/sidebar/Sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const items = [
{name: 'setting', label: 'Setting', icon: Settings},
];

<Sidebar items={items} />
<Sidebar items={items} backgroundColor={'#eeeeee'} />
```


Expand Down Expand Up @@ -95,5 +95,5 @@ const items = [
}
];

<Sidebar items={items} theme={'dark'} />
<Sidebar items={items} style={{height: '80vh'}} theme={'dark'} />
```

0 comments on commit 7593e5f

Please sign in to comment.