Skip to content

Commit 7593e5f

Browse files
authored
Merge pull request #1 from mikengu/dev
feat(sidebar): change arrow indicators
2 parents 33c40a2 + 30c34f7 commit 7593e5f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/components/sidebar/Sidebar.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, {Fragment, useState} from 'react'
22
import PropTypes from 'prop-types'
33
import List from '@material-ui/core/List'
44
import {ListItem, ListItemText, Collapse, ListItemIcon, makeStyles} from '@material-ui/core'
5-
import {ExpandLess, ExpandMore} from '@material-ui/icons'
5+
import {ArrowRight, ArrowDropDown} from '@material-ui/icons'
66
import './sidebar.css'
77

88
const darkTheme = {
@@ -20,7 +20,7 @@ function SidebarItem ({label, name, items, depthStep = 10, depth = 0, Icon}) {
2020
[name]: !currentState[name]
2121
}))
2222
}
23-
const expandBtn = open => open ? <ExpandLess /> : <ExpandMore />
23+
const expandBtn = open => !open ? <ArrowDropDown /> : <ArrowRight />
2424
return (
2525
<Fragment>
2626
<ListItem onClick={handleClick} button dense>
@@ -54,16 +54,17 @@ function SidebarItem ({label, name, items, depthStep = 10, depth = 0, Icon}) {
5454
SidebarItem.propTypes = {
5555
label: PropTypes.string,
5656
name: PropTypes.string,
57+
Icon: PropTypes.node,
5758
items: PropTypes.array,
5859
depth: PropTypes.number,
5960
theme: PropTypes.object,
6061
depthStep: PropTypes.number
6162
}
6263

63-
function Sidebar ({items, theme, icon, width}) {
64+
function Sidebar ({items, theme, backgroundColor, style, icon, width}) {
6465
const useStyles = makeStyles(material => {
6566
let themeColor = {
66-
backgroundColor: material.palette.background.paper,
67+
backgroundColor: backgroundColor || material.palette.background.paper,
6768
color: '#000'
6869
}
6970
if (theme === 'dark') {
@@ -73,6 +74,7 @@ function Sidebar ({items, theme, icon, width}) {
7374
root: {
7475
width: width,
7576
maxWidth: width,
77+
...style,
7678
...themeColor
7779
},
7880
nested: {
@@ -110,6 +112,7 @@ Sidebar.propTypes = {
110112
height: PropTypes.string,
111113
items: PropTypes.array,
112114
onClick: PropTypes.func,
115+
style: PropTypes.object,
113116
theme: PropTypes.string,
114117
width: PropTypes.string
115118
}

src/components/sidebar/Sidebar.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const items = [
2323
{name: 'setting', label: 'Setting', icon: Settings},
2424
];
2525

26-
<Sidebar items={items} />
26+
<Sidebar items={items} backgroundColor={'#eeeeee'} />
2727
```
2828

2929

@@ -95,5 +95,5 @@ const items = [
9595
}
9696
];
9797

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

0 commit comments

Comments
 (0)