From db88d2a07078e9d27f36857ff754f211d2d79f1a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 28 Sep 2018 11:39:42 +0200 Subject: [PATCH] Material UI Nestled List Implemented --- client/src/components/DescendentsTree.js | 129 ++++++++++++++++++----- 1 file changed, 100 insertions(+), 29 deletions(-) diff --git a/client/src/components/DescendentsTree.js b/client/src/components/DescendentsTree.js index 74e72fd36..54268cc64 100644 --- a/client/src/components/DescendentsTree.js +++ b/client/src/components/DescendentsTree.js @@ -14,7 +14,19 @@ import Button from '@material-ui/core/Button' import Typography from '@material-ui/core/Typography' import Grid from '@material-ui/core/Grid' -import TextField from '@material-ui/core/TextField' +// Material UI Nestled Lists +import ListSubheader from '@material-ui/core/ListSubheader'; +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 Collapse from '@material-ui/core/Collapse'; +import InboxIcon from '@material-ui/icons/MoveToInbox'; +import DraftsIcon from '@material-ui/icons/Drafts'; +import SendIcon from '@material-ui/icons/Send'; +import ExpandLess from '@material-ui/icons/ExpandLess'; +import ExpandMore from '@material-ui/icons/ExpandMore'; +import StarBorder from '@material-ui/icons/StarBorder'; // components import UserProfile from './UserProfile' @@ -23,11 +35,12 @@ import UserProfile from './UserProfile' import PortraitImage from '../img/portrait.jpg' const styles = theme => ({ - card: { + childrenCard: { maxWidth: 150, minWidth: 150, paddingTop: '30', - marginBottom: 40 + marginBottom: 40, + marginLeft: 10 }, media: { height: 0, @@ -63,7 +76,10 @@ const styles = theme => ({ button: { margin: theme.spacing.unit, marginTop: theme.spacing.unit * 3 - } + }, + nested: { + paddingLeft: theme.spacing.unit * 4, + }, }) class DescendentsTree extends Component { @@ -72,37 +88,35 @@ class DescendentsTree extends Component { super(props) this.state = { - alias: '', - firstName: '', - middleName: '', - lastName: '' + id: '', + open: true } } - displayDescendents () { - let data = this.props.data + handleClick = () => { + this.setState(state => ({ open: !state.open })); +}; + + displayNodeDescendents(node) { + const { classes } = this.props - - if (data.loading) { - return (
Loading Descendents...
) - } else { - if (data.descendents === undefined) { - return (
No Descendents to Display
) - } else { - return data.descendents.map(descendent => { - return ( - - - { - this.setState({ selected: descendent.id}) - } - }> + return node.descendents.map(descendent => { + return ( + + + + + + + + + @@ -116,8 +130,62 @@ class DescendentsTree extends Component { - + + + ) + } + ) + } + + displayDescendents () { + let data = this.props.data + const { classes } = this.props + + if (data.loading) { + return (
Loading Descendents...
) + } else { + if (data.descendents === undefined) { + return (
No Descendents to Display
) + } else { + return data.descendents.map(descendent => { + return ( +
+ + + + + + + + + + + {descendent.alias} + + + + + + + + + + + + + {this.state.open ? : } + + + {this.displayNodeDescendents(descendent)} + + +
) }) } @@ -128,9 +196,12 @@ class DescendentsTree extends Component { const { classes } = this.props return (
- + Nested List Items} + > {this.displayDescendents()} - +
) }