-
Notifications
You must be signed in to change notification settings - Fork 432
Add Tree Grid Component #2181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Tree Grid Component #2181
Changes from 4 commits
159f67f
595c3ed
60339b4
367ff3b
5038e4a
16040a9
789638e
7b51c8d
647ddd2
07ee9f5
72f02af
5aa8534
d0f48a4
db6dbcf
515f34e
8fb89bc
f3f9b9c
a52fec1
8ad82e2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { TREE_GRID } from '../../../utilities/constants'; | ||
import Default from '../__examples__/default'; | ||
import Nested from '../__examples__/nested'; | ||
import PreSelected from '../__examples__/pre-selected'; | ||
import SingleSelect from '../__examples__/single-select'; | ||
|
||
|
||
storiesOf(TREE_GRID, module) | ||
.addDecorator((getStory) => ( | ||
<div className="slds-p-around_medium">{getStory()}</div> | ||
)) | ||
.add('Default', () => <Default />) | ||
.add('w/ Nesting', () => <Nested />) | ||
.add('w/ Pre-Selection', () => <PreSelected />) | ||
.add('w/ Single Select', () => <SingleSelect />); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import React from 'react'; | ||
import TreeGrid from '~/components/tree-grid'; | ||
import IconSettings from '~/components/icon-settings'; | ||
|
||
const data = { | ||
cols: [ | ||
{ | ||
id: '1', | ||
label: 'Account Name', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
id: '2', | ||
label: 'Employees', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
id: '3', | ||
label: 'Phone Number', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
id: '4', | ||
label: 'Account Owner', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
id: '5', | ||
label: 'Billing City', | ||
href: 'javascript:void(0);', | ||
}, | ||
], | ||
rows: [ | ||
{ | ||
id: '1', | ||
cols: [ | ||
{ | ||
label: 'Rewis Inc', | ||
}, | ||
{ | ||
label: '3100', | ||
}, | ||
{ | ||
label: '837-555-1212', | ||
}, | ||
{ | ||
label: 'Jane Doe', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
label: 'Phoenix, AZ', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: '2', | ||
cols: [ | ||
{ | ||
label: 'Acme Corporation', | ||
}, | ||
{ | ||
label: '10000', | ||
}, | ||
{ | ||
label: '837-555-1212', | ||
}, | ||
{ | ||
label: 'Jane Doe', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
label: 'San Francisco, CA', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: '3', | ||
cols: [ | ||
{ | ||
label: 'Rohde Enterprises', | ||
}, | ||
{ | ||
label: '6000', | ||
}, | ||
{ | ||
label: '837-555-1212', | ||
}, | ||
{ | ||
label: 'Jane Doe', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
label: 'New York, NY', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: '4', | ||
cols: [ | ||
{ | ||
label: 'Cheese Corp', | ||
}, | ||
{ | ||
label: '1234', | ||
}, | ||
{ | ||
label: '837-555-1212', | ||
}, | ||
{ | ||
label: 'Jane Doe', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
label: 'Paris, France', | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
class Example extends React.Component { | ||
static displayName = 'treeGridExample'; | ||
|
||
render() { | ||
return ( | ||
<IconSettings iconPath="/assets/icons"> | ||
<TreeGrid data={data} /> | ||
</IconSettings> | ||
); | ||
} | ||
} | ||
|
||
export default Example; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
import React from 'react'; | ||
import TreeGrid from '~/components/tree-grid'; | ||
import IconSettings from '~/components/icon-settings'; | ||
|
||
const data = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The columns should be child components. See There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the Lightning component data for instance.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The data should be very similar. I would change |
||
cols: [ | ||
{ | ||
id: '1', | ||
label: 'Account Name', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
id: '2', | ||
label: 'Employees', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
id: '3', | ||
label: 'Phone Number', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
id: '4', | ||
label: 'Account Owner', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
id: '5', | ||
label: 'Billing City', | ||
href: 'javascript:void(0);', | ||
}, | ||
], | ||
rows: [ | ||
{ | ||
id: '1', | ||
cols: [ | ||
{ | ||
label: 'Rewis Inc', | ||
}, | ||
{ | ||
label: '3100', | ||
}, | ||
{ | ||
label: '837-555-1212', | ||
}, | ||
{ | ||
label: 'Jane Doe', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
label: 'Phoenix, AZ', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: '2', | ||
childOpen: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
|
||
cols: [ | ||
{ | ||
label: 'Acme Corporation', | ||
}, | ||
{ | ||
label: '10000', | ||
}, | ||
{ | ||
label: '837-555-1212', | ||
}, | ||
{ | ||
label: 'Jane Doe', | ||
href: 'javascript:void(0);', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default cell render should be just a string. If you'd like to scope this project to only output strings I'm cool with that. We can add custom rendering later
|
||
}, | ||
{ | ||
label: 'San Francisco, CA', | ||
}, | ||
], | ||
subRows: [ | ||
{ | ||
cols: [ | ||
{ | ||
label: 'Acme Corporation (Oakland)', | ||
}, | ||
{ | ||
label: '745', | ||
}, | ||
{ | ||
label: '837-555-1212', | ||
}, | ||
{ | ||
label: 'Jane Doe', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
label: 'New York, NY', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
id: '3', | ||
cols: [ | ||
{ | ||
label: 'Rohde Enterprises', | ||
}, | ||
{ | ||
label: '6000', | ||
}, | ||
{ | ||
label: '837-555-1212', | ||
}, | ||
{ | ||
label: 'Jane Doe', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
label: 'New York, NY', | ||
}, | ||
], | ||
}, | ||
{ | ||
id: '4', | ||
cols: [ | ||
{ | ||
label: 'Cheese Corp', | ||
}, | ||
{ | ||
label: '1234', | ||
}, | ||
{ | ||
label: '837-555-1212', | ||
}, | ||
{ | ||
label: 'Jane Doe', | ||
href: 'javascript:void(0);', | ||
}, | ||
{ | ||
label: 'Paris, France', | ||
}, | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
class Example extends React.Component { | ||
static displayName = 'treeGridNestedExample'; | ||
|
||
render() { | ||
return ( | ||
<IconSettings iconPath="/assets/icons"> | ||
<TreeGrid data={data} /> | ||
</IconSettings> | ||
); | ||
} | ||
} | ||
|
||
export default Example; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there were no nested rows, then a dev would use a DataTable. I don't think we need this example and base should be nested.