-
Notifications
You must be signed in to change notification settings - Fork 834
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Recursive tree component. * Adding an expandByDefault prop. * Swapping a div for a span * Minor accessibility tweaks. * wip a11y example * Fix typescript types around aria labels * Re-use recursive tree's context to determine nesting * Adding i18n to the list instructions. * Renaming to EuiTreeView. * Add EuiI18n to aria-label text * Adding changelog entry. * Closer to eui spec + allows room to expand later
- Loading branch information
1 parent
c7cb88b
commit e6d693e
Showing
19 changed files
with
939 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React from 'react'; | ||
|
||
import { EuiTreeView, EuiToken } from '../../../../src/components'; | ||
|
||
export class TreeViewCompressed extends React.Component { | ||
showAlert = () => { | ||
alert('You squashed a bug!'); | ||
}; | ||
|
||
render() { | ||
const items = [ | ||
{ | ||
label: 'transporter', | ||
id: 'transporter', | ||
icon: <EuiToken size="xs" iconType="tokenObject" />, | ||
children: [ | ||
{ | ||
label: 'service', | ||
id: 'service', | ||
icon: <EuiToken size="xs" iconType="tokenString" />, | ||
}, | ||
{ | ||
label: 'auth', | ||
id: 'auth', | ||
icon: <EuiToken size="xs" iconType="tokenObject" />, | ||
children: [ | ||
{ | ||
label: 'user', | ||
id: 'user', | ||
icon: <EuiToken size="xs" iconType="tokenVariable" />, | ||
}, | ||
{ | ||
label: 'pass', | ||
id: 'pass', | ||
icon: <EuiToken size="xs" iconType="tokenVariable" />, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'getContact', | ||
id: 'getContact', | ||
icon: <EuiToken size="xs" iconType="tokenFunction" />, | ||
children: [ | ||
{ | ||
label: 'render', | ||
id: 'render', | ||
icon: <EuiToken size="xs" iconType="tokenFunction" />, | ||
children: [ | ||
{ | ||
label: 'title', | ||
id: 'title', | ||
icon: <EuiToken size="xs" iconType="tokenString" />, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'postContact', | ||
id: 'postContact', | ||
icon: <EuiToken size="xs" iconType="tokenFunction" />, | ||
children: [ | ||
{ | ||
label: 'errors', | ||
id: 'errors', | ||
icon: <EuiToken size="xs" iconType="tokenConstant" />, | ||
}, | ||
{ | ||
label: 'mailOptions', | ||
id: 'mailOptions', | ||
icon: <EuiToken size="xs" iconType="tokenObject" />, | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'smokeMonster', | ||
id: 'smokeMonster', | ||
icon: <EuiToken size="xs" iconType="tokenMethod" />, | ||
}, | ||
]; | ||
|
||
return ( | ||
<div style={{ width: '20rem' }}> | ||
<EuiTreeView | ||
items={items} | ||
display="compressed" | ||
expandByDefault | ||
showExpansionArrows | ||
aria-label="Document Outline" | ||
/> | ||
</div> | ||
); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React from 'react'; | ||
|
||
import { EuiIcon, EuiTreeView, EuiToken } from '../../../../src/components'; | ||
|
||
export class TreeView extends React.Component { | ||
showAlert = () => { | ||
alert('You squashed a bug!'); | ||
}; | ||
|
||
render() { | ||
const items = [ | ||
{ | ||
label: 'Item One', | ||
id: 'item_one', | ||
icon: <EuiIcon type="folderClosed" />, | ||
iconWhenExpanded: <EuiIcon type="folderOpen" />, | ||
isExpanded: true, | ||
children: [ | ||
{ | ||
label: 'Item A', | ||
id: 'item_a', | ||
icon: <EuiIcon type="document" />, | ||
}, | ||
{ | ||
label: 'Item B', | ||
id: 'item_b', | ||
icon: <EuiIcon type="arrowRight" />, | ||
iconWhenExpanded: <EuiIcon type="arrowDown" />, | ||
children: [ | ||
{ | ||
label: 'A Cloud', | ||
id: 'item_cloud', | ||
icon: <EuiToken iconType="tokenConstant" />, | ||
}, | ||
{ | ||
label: "I'm a Bug", | ||
id: 'item_bug', | ||
icon: <EuiToken iconType="tokenEnum" />, | ||
callback: this.showAlert, | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'Item C', | ||
id: 'item_c', | ||
icon: <EuiIcon type="arrowRight" />, | ||
iconWhenExpanded: <EuiIcon type="arrowDown" />, | ||
children: [ | ||
{ | ||
label: 'Another Cloud', | ||
id: 'item_cloud2', | ||
icon: <EuiToken iconType="tokenConstant" />, | ||
}, | ||
{ | ||
label: 'Another Bug', | ||
id: 'item_bug2', | ||
icon: <EuiToken iconType="tokenEnum" />, | ||
callback: this.showAlert, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
{ | ||
label: 'Item Two', | ||
id: 'item_two', | ||
}, | ||
]; | ||
|
||
return ( | ||
<div style={{ width: '20rem' }}> | ||
<EuiTreeView items={items} aria-label="Sample Folder Tree" /> | ||
</div> | ||
); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import React from 'react'; | ||
|
||
import { renderToHtml } from '../../services'; | ||
|
||
import { GuideSectionTypes } from '../../components'; | ||
|
||
import { EuiCode, EuiTreeView } from '../../../../src/components'; | ||
import { EuiTreeViewNode } from './tree_view_props'; | ||
import { TreeView } from './tree_view'; | ||
import { TreeViewCompressed } from './compressed'; | ||
|
||
const treeViewSource = require('!!raw-loader!./tree_view'); | ||
const treeViewHtml = renderToHtml(TreeView); | ||
|
||
const treeViewCompressedSource = require('!!raw-loader!./compressed'); | ||
const treeViewCompressedHtml = renderToHtml(TreeViewCompressed); | ||
|
||
export const TreeViewExample = { | ||
title: 'Tree View', | ||
sections: [ | ||
{ | ||
source: [ | ||
{ | ||
type: GuideSectionTypes.JS, | ||
code: treeViewSource, | ||
}, | ||
{ | ||
type: GuideSectionTypes.HTML, | ||
code: treeViewHtml, | ||
}, | ||
], | ||
text: ( | ||
<div> | ||
<p> | ||
<EuiCode>EuiTreeView</EuiCode> allows you to render recursive | ||
objects, such as a file directory. The <EuiCode>chilldren</EuiCode>{' '} | ||
prop takes an array of <EuiCode>nodes</EuiCode>. | ||
</p> | ||
<p> | ||
Keyboard navigation allows users to navigate and interact with the | ||
tree using the arrow keys, spacebar, and return. | ||
</p> | ||
<p> | ||
The <EuiCode>icon</EuiCode> prop accepts <EuiCode>EuiIcon</EuiCode>{' '} | ||
and <EuiCode>EuiToken</EuiCode> as react nodes. You can also | ||
specifiy a different icon for the open state with the{' '} | ||
<EuiCode>iconWhenExpanded</EuiCode> prop. | ||
</p> | ||
</div> | ||
), | ||
components: { EuiTreeView }, | ||
demo: <TreeView />, | ||
props: { EuiTreeView, EuiTreeViewNode }, | ||
}, | ||
{ | ||
title: 'Optional styling', | ||
source: [ | ||
{ | ||
type: GuideSectionTypes.JS, | ||
code: treeViewCompressedSource, | ||
}, | ||
{ | ||
type: GuideSectionTypes.HTML, | ||
code: treeViewCompressedHtml, | ||
}, | ||
], | ||
text: ( | ||
<div> | ||
<p> | ||
<EuiCode>EuiTreeView</EuiCode> supports a compressed mode with the{' '} | ||
<EuiCode>display="compressed"</EuiCode> setting. When | ||
using the compressed version it's highly recommended to use the | ||
small size of <EuiCode>EuiIcon</EuiCode> and the extra small size of{' '} | ||
<EuiCode>EuiToken</EuiCode>. This will help prevent awkard alignment | ||
issues when used alongside the{' '} | ||
<EuiCode>showExpansionArrows</EuiCode> prop. | ||
</p> | ||
<p> | ||
The <EuiCode>showExpansionArrows</EuiCode> prop provides an | ||
additional visual indicator. Ideal for when a tree's items use | ||
icons that don't immediately let a user know that there are | ||
nested nodes that may not be visible. | ||
</p> | ||
<p> | ||
In some cases, you may want to automatically expand all the items | ||
with children. In those instances, you can use the{' '} | ||
<EuiCode>expandByDefault</EuiCode> prop, as seen in the example | ||
below. | ||
</p> | ||
</div> | ||
), | ||
components: { EuiTreeView }, | ||
demo: <TreeViewCompressed />, | ||
props: { EuiTreeView, EuiTreeViewNode }, | ||
}, | ||
], | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import { Node } from '../../../../src/components/tree_view/tree_view'; | ||
|
||
export const EuiTreeViewNode: FunctionComponent<Node> = () => <div />; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
export { | ||
EuiToken, | ||
EuiTokenProps, | ||
SIZES as TOKEN_SIZES, | ||
SHAPES as TOKEN_SHAPES, | ||
COLORS as TOKEN_COLORS, | ||
|
Oops, something went wrong.