-
Notifications
You must be signed in to change notification settings - Fork 388
New tree view integration #864
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
Merged
jeff-phillips-18
merged 16 commits into
patternfly:master
from
brumik:wooden-tree-integration
Mar 18, 2019
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d481611
Removed 'jest' from dependencies to fix testing.
47d56fc
Set up wooden-tree-component for storybook
9e12a1c
Moved the tree view to its own package.
5f3ebfb
Added props spread to the tree
89927ca
Added the link to the npm page of the tree.
a7e0518
Rename the package
de053da
Renamed the package again and added basic readme
ff6aced
Moved the default data to a separate file and provided propTypes
2230fc9
Reworked to re-export the original component
b3e321e
Revert "Reworked to re-export the original component"
5c8e151
Added dependency prop-types - passes lint
946e9a7
Revert "Revert "Reworked to re-export the original component""
43cdfa6
Added prop types dependency to the package
479c01a
Updated yarn.lock file
b64dc9d
Removed class variable and constructor from the example
ce54691
Renamed to Wooden Tree View, description changes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 @@ | ||
| { | ||
| "presets": ["../.babelrc.js"] | ||
| } |
2 changes: 2 additions & 0 deletions
2
packages/patternfly-3/patternfly-react-wooden-tree/.npmignore
This file contains hidden or 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,2 @@ | ||
| src | ||
| build |
13 changes: 13 additions & 0 deletions
13
packages/patternfly-3/patternfly-react-wooden-tree/README.md
This file contains hidden or 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,13 @@ | ||
| # react-wooden-tree | ||
|
|
||
| ## Getting Started | ||
|
|
||
| ``` | ||
| yarn add patternfly-react-wooden-tree | ||
| ``` | ||
|
|
||
| or | ||
|
|
||
| ``` | ||
| npm install patternfly-react-wooden-tree --save | ||
| ``` |
39 changes: 39 additions & 0 deletions
39
packages/patternfly-3/patternfly-react-wooden-tree/package.json
This file contains hidden or 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,39 @@ | ||
| { | ||
| "name": "patternfly-react-wooden-tree", | ||
| "version": "1.0.0", | ||
| "description": "Reexport react-wooden-tree with Patternfly design.", | ||
| "main": "dist/js/index.js", | ||
| "module": "dist/esm/index.js", | ||
| "types": "dist/js/index.d.ts", | ||
| "sideEffects": false, | ||
| "publishConfig": { | ||
| "access": "public" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/patternfly/patternfly-react.git" | ||
| }, | ||
| "keywords": [ | ||
| "react", | ||
| "patternfly", | ||
| "treeview" | ||
| ], | ||
| "author": "Red Hat", | ||
| "license": "MIT", | ||
| "bugs": { | ||
| "url": "https://github.com/patternfly/patternfly-react/issues" | ||
| }, | ||
| "homepage": "https://github.com/patternfly/patternfly-react/blob/master/packages/patternfly-react-wooden-tree/README.md", | ||
| "scripts": { | ||
| "build": "yarn build:babel", | ||
| "build:babel": "concurrently \"yarn build:babel:cjs\" \"yarn build:babel:esm\"", | ||
| "build:babel:cjs": "cross-env BABEL_ENV=production:cjs babel src --out-dir dist/js", | ||
| "build:babel:esm": "cross-env BABEL_ENV=production:esm babel src --out-dir dist/esm" | ||
| }, | ||
| "dependencies": { | ||
| "prop-types": "^15.6.2", | ||
| "react": "^16.6.1", | ||
| "react-wooden-tree": "^1.1.2" | ||
| }, | ||
| "devDependencies": {} | ||
| } |
33 changes: 33 additions & 0 deletions
33
...ges/patternfly-3/patternfly-react-wooden-tree/src/components/TreeView/TreeView.stories.js
This file contains hidden or 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,33 @@ | ||
| import React from 'react'; | ||
| import { storiesOf } from '@storybook/react'; | ||
| import { withInfo } from '@storybook/addon-info/dist/index'; | ||
| import { defaultTemplate } from 'storybook/decorators/storyTemplates'; | ||
| import { storybookPackageName } from 'storybook/constants/siteConstants'; | ||
| import { name } from '../../../package.json'; | ||
| import TreeViewExample from './TreeViewExample'; | ||
|
|
||
| const stories = storiesOf(`${storybookPackageName(name)}/Wooden Tree View`, module); | ||
|
|
||
| stories.addDecorator( | ||
| defaultTemplate({ | ||
| title: 'Wooden Tree View', | ||
| description: ( | ||
| <div> | ||
| This is a Tree View component to display trees and hierarchical data using React Wooden Tree. | ||
| The tree uses the <a href="https://www.npmjs.com/package/react-wooden-tree">https://www.npmjs.com/package/react-wooden-tree</a> component. | ||
| </div> | ||
| ) | ||
| }) | ||
| ); | ||
|
|
||
| stories.add( | ||
| 'Wooden Tree View', | ||
| withInfo({ | ||
| source: false, | ||
| propTables: [TreeViewExample] | ||
| })(() => ( | ||
| <div style={{ display: 'flex' }}> | ||
| <TreeViewExample /> | ||
| </div> | ||
| )) | ||
| ); | ||
87 changes: 87 additions & 0 deletions
87
...ages/patternfly-3/patternfly-react-wooden-tree/src/components/TreeView/TreeViewExample.js
This file contains hidden or 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,87 @@ | ||
| import React from 'react'; | ||
| import WoodenTreeView from './index'; | ||
|
|
||
| const data = [ | ||
| { | ||
| text: 'Parent 1', | ||
| icon: 'fa fa-folder', | ||
| nodes: [ | ||
| { | ||
| text: 'Child 1', | ||
| nodes: [{ text: 'Grandchild 1' }, { text: 'Grandchild 2' }] | ||
| }, | ||
| { | ||
| text: 'Child 2', | ||
| nodes: [{ text: 'Grandchild 1' }, { text: 'Grandchild 2' }] | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| text: 'Parent 2', | ||
| icon: 'fa fa-folder', | ||
| nodes: [{ text: 'Child 1' }] | ||
| }, | ||
| { | ||
| text: 'Parent 3', | ||
| icon: 'fa fa-folder' | ||
| }, | ||
| { | ||
| text: 'Parent 4', | ||
| icon: 'fa fa-folder' | ||
| }, | ||
| { | ||
| text: 'Parent 5', | ||
| icon: 'fa fa-folder' | ||
| } | ||
| ]; | ||
|
|
||
| const EXPANDED = 'state.expanded'; | ||
| const CHECKED = 'state.checked'; | ||
| const DISABLED = 'state.disabled'; | ||
| const SELECTED = 'state.selected'; | ||
| const NODES = 'nodes'; | ||
| const LOADING = 'loading'; | ||
|
|
||
| const actionMapper = { | ||
| [EXPANDED]: WoodenTreeView.nodeExpanded, | ||
| [CHECKED]: WoodenTreeView.nodeChecked, | ||
| [DISABLED]: WoodenTreeView.nodeDisabled, | ||
| [SELECTED]: WoodenTreeView.nodeSelected, | ||
| [NODES]: WoodenTreeView.nodeChildren, | ||
| [LOADING]: WoodenTreeView.nodeLoading | ||
| }; | ||
|
|
||
| class TreeViewExample extends React.Component { | ||
| state = { | ||
| tree: WoodenTreeView.initTree(data) | ||
| }; | ||
|
|
||
| /** | ||
| * The callback function for changing data in the tree. | ||
| * | ||
| * @param {string} nodeId The nodeId of the node. | ||
| * @param {string} type The field name which changed. | ||
| * @param {boolean} value The new value to assign. | ||
| */ | ||
| onDataChange = (nodeId, type, value) => { | ||
| let node = WoodenTreeView.nodeSelector(this.state.tree, nodeId); | ||
| if (node == null) { | ||
| return; | ||
| } | ||
|
|
||
| if (actionMapper.hasOwnProperty(type)) { | ||
| node = actionMapper[type](node, value); | ||
| this.setState({ tree: WoodenTreeView.nodeUpdater(this.state.tree, node) }); | ||
| } | ||
| }; | ||
|
|
||
| render() { | ||
| return ( | ||
| <div className="App"> | ||
| <WoodenTreeView nodeIcon="fa fa-file-o" data={this.state.tree} onDataChange={this.onDataChange} {...this.props} /> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export default TreeViewExample; |
8 changes: 8 additions & 0 deletions
8
packages/patternfly-3/patternfly-react-wooden-tree/src/components/TreeView/index.js
This file contains hidden or 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,8 @@ | ||
| import { Tree } from 'react-wooden-tree'; | ||
|
|
||
| require('react-wooden-tree/dist/react-wooden-tree.css'); | ||
| require('./style.css'); | ||
|
|
||
| class WoodenTreeView extends Tree {} | ||
|
|
||
| export default WoodenTreeView; |
7 changes: 7 additions & 0 deletions
7
packages/patternfly-3/patternfly-react-wooden-tree/src/components/TreeView/style.css
This file contains hidden or 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,7 @@ | ||
| .Tree .Icon { | ||
| margin-right: 0; | ||
| } | ||
|
|
||
| .Tree .NoOpenButton { | ||
| margin-left: 1em; | ||
| } |
1 change: 1 addition & 0 deletions
1
packages/patternfly-3/patternfly-react-wooden-tree/src/index.js
This file contains hidden or 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 @@ | ||
| export { default as WoodenTreeView } from './components/TreeView'; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.