This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[terra-folder-tree] Add expand/collapse
- Loading branch information
Showing
47 changed files
with
248 additions
and
54 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
2 changes: 1 addition & 1 deletion
2
packages/terra-folder-tree/src/clinical-lowlight-theme/FolderTree.module.scss
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,5 @@ | ||
import FolderTree from './FolderTree'; | ||
import FolderTreeItem from './subcomponents/FolderTreeItem'; | ||
|
||
FolderTree.Item = FolderTreeItem; | ||
export default FolderTree; |
1 change: 0 additions & 1 deletion
1
packages/terra-folder-tree/src/orion-fusion-theme/FolderTree.module.scss
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,6 +1,5 @@ | ||
:local { | ||
.orion-fusion-theme { | ||
--terra-folder-tree-item-background-color-hover: #f4fafe; | ||
// --terra-folder-tree-item-background-color-selected: ; | ||
} | ||
} |
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
93 changes: 56 additions & 37 deletions
93
packages/terra-folder-tree/tests/jest/FolderTree.test.jsx
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,66 +1,85 @@ | ||
import React from 'react'; | ||
import ActionHeader from 'terra-action-header'; | ||
/* eslint-disable-next-line import/no-extraneous-dependencies */ | ||
import { shallowWithIntl } from 'terra-enzyme-intl'; | ||
import { mountWithIntl, shallowWithIntl } from 'terra-enzyme-intl'; | ||
import FolderTree from '../../src/FolderTree'; | ||
import FolderTreeItem from '../../src/subcomponents/FolderTreeItem'; | ||
|
||
describe('basic folder tree', () => { | ||
it('renders a folder tree with one level of children and no subfolders', () => { | ||
const wrapper = shallowWithIntl( | ||
<FolderTree title="Documents"> | ||
<FolderTree.Item label="Cat" /> | ||
<FolderTree.Item label="Dog" /> | ||
<FolderTree.Item label="Rabbit" /> | ||
<FolderTreeItem label="Cat" /> | ||
<FolderTreeItem label="Dog" /> | ||
<FolderTreeItem label="Rabbit" /> | ||
</FolderTree>, | ||
); | ||
|
||
expect(wrapper.find(ActionHeader).length).toBe(1); | ||
expect(wrapper.find(ActionHeader).prop('text')).toBe('Documents'); | ||
|
||
expect(wrapper.find(FolderTree.Item).length).toBe(3); | ||
expect(wrapper.find(FolderTree.Item).at(0).prop('label')).toBe('Cat'); | ||
// TODO: Fix these tests | ||
// expect(wrapper.find(FolderTree.Item).at(0).prop('level')).toBe(0); | ||
expect(wrapper.find(FolderTree.Item).at(1).prop('label')).toBe('Dog'); | ||
// expect(wrapper.find(FolderTree.Item).at(1).prop('level')).toBe(0); | ||
expect(wrapper.find(FolderTree.Item).at(2).prop('label')).toBe('Rabbit'); | ||
// expect(wrapper.find(FolderTree.Item).at(2).prop('level')).toBe(0); | ||
expect(wrapper.find(FolderTreeItem).length).toBe(3); | ||
expect(wrapper.find(FolderTreeItem).at(0).prop('label')).toBe('Cat'); | ||
expect(wrapper.find(FolderTreeItem).at(0).dive().prop('level')).toBe(0); | ||
expect(wrapper.find(FolderTreeItem).at(1).prop('label')).toBe('Dog'); | ||
expect(wrapper.find(FolderTreeItem).at(1).dive().prop('level')).toBe(0); | ||
expect(wrapper.find(FolderTreeItem).at(2).prop('label')).toBe('Rabbit'); | ||
expect(wrapper.find(FolderTreeItem).at(2).dive().prop('level')).toBe(0); | ||
}); | ||
|
||
it('renders a folder tree with subfolders', () => { | ||
it('renders a folder tree item with subitems', () => { | ||
const wrapper = mountWithIntl( | ||
<FolderTreeItem | ||
subfolderItems={[ | ||
(<FolderTreeItem label="item 1" />), | ||
(<FolderTreeItem label="item 2" />), | ||
(<FolderTreeItem label="item 3" />), | ||
]} | ||
/>, | ||
); | ||
|
||
const subfolder = wrapper.find('.subfolder'); | ||
|
||
expect(subfolder.find('span.fill.fill-block').length).toBe(3); | ||
expect(subfolder.find('span.fill.fill-block').at(0).text()).toBe('item 1'); | ||
expect(subfolder.find('span.fill.fill-block').at(1).text()).toBe('item 2'); | ||
expect(subfolder.find('span.fill.fill-block').at(2).text()).toBe('item 3'); | ||
}); | ||
|
||
it('hides folder items when enclosing folder is collapsed', () => { | ||
const wrapper = shallowWithIntl( | ||
<FolderTree title="Documents"> | ||
<FolderTree.Item | ||
<FolderTreeItem | ||
label="Animals" | ||
subfolderItems={[ | ||
(<FolderTree.Item label="Dog" />), | ||
(<FolderTreeItem label="Dog" />), | ||
]} | ||
/> | ||
</FolderTree>, | ||
); | ||
|
||
const firstSubfolder = wrapper.find(FolderTree.Item); | ||
expect(firstSubfolder.prop('label')).toBe('Animals'); | ||
// TODO: Fix these tests | ||
// expect(firstSubfolder.prop('level')).toBe(0); | ||
// const secondSubfolder = wrapper.find(FolderTree.Item).dive(); | ||
// expect(secondSubfolder.find(FolderTree.Item).length).toBe(1); | ||
// expect(secondSubfolder.find(FolderTree.Item).prop('label')).toBe('Dog'); | ||
// expect(secondSubfolder.find(FolderTree.Item).prop('level')).toBe(1); | ||
const collapsedFolder = wrapper.find(FolderTreeItem).dive().dive(); | ||
|
||
expect(collapsedFolder.find('.folder-tree-item').prop('aria-expanded')).toBe(false); | ||
expect(collapsedFolder.find('.subfolder').prop('hidden')).toBe(true); | ||
}); | ||
|
||
// TODO: Fix these tests | ||
// it('renders a folder tree item with subitems', () => { | ||
// const wrapper = shallowWithIntl( | ||
// <FolderTree.Item | ||
// label="Animals" | ||
// subfolderItems={[ | ||
// (<FolderTree.Item label="Dog"/>), | ||
// (<FolderTree.Item label="Cat"/>), | ||
// (<FolderTree.Item label="Rabbit"/>), | ||
// ]} | ||
// />, | ||
// ); | ||
// expect(wrapper.find(FolderTree.Item).length).toBe(3); | ||
// }); | ||
it('shows folder items when enclosing folder is expanded', () => { | ||
const wrapper = shallowWithIntl( | ||
<FolderTree title="Documents"> | ||
<FolderTreeItem | ||
label="Animals" | ||
subfolderItems={[ | ||
(<FolderTreeItem label="Dog" />), | ||
]} | ||
/> | ||
</FolderTree>, | ||
); | ||
|
||
const expandedFolder = wrapper.find(FolderTreeItem).dive().dive(); | ||
expandedFolder.find('.folder-tree-item').simulate('click'); | ||
|
||
expect(expandedFolder.find('.folder-tree-item').prop('aria-expanded')).toBe(true); | ||
expect(expandedFolder.find('.subfolder').prop('hidden')).toBe(false); | ||
}); | ||
}); |
Binary file removed
BIN
-34.9 KB
.../clinical-lowlight-theme/en/chrome_large/folder-tree-spec/basic_folder_tree.png
Binary file not shown.
Binary file removed
BIN
-35.8 KB
...-lowlight-theme/en/chrome_large/folder-tree-spec/basic_folder_tree_selected.png
Binary file not shown.
Binary file modified
BIN
-25.8 KB
(25%)
...clinical-lowlight-theme/en/chrome_medium/folder-tree-spec/basic_folder_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-25.8 KB
(27%)
...lowlight-theme/en/chrome_medium/folder-tree-spec/basic_folder_tree_selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.44 KB
.../clinical-lowlight-theme/en/chrome_medium/folder-tree-spec/collapsed_folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.11 KB
...e/clinical-lowlight-theme/en/chrome_medium/folder-tree-spec/expanded_folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.3 KB
.../clinical-lowlight-theme/en/chrome_small/folder-tree-spec/basic_folder_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.19 KB
...-lowlight-theme/en/chrome_small/folder-tree-spec/basic_folder_tree_selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.31 KB
...e/clinical-lowlight-theme/en/chrome_small/folder-tree-spec/collapsed_folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.92 KB
...ce/clinical-lowlight-theme/en/chrome_small/folder-tree-spec/expanded_folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file removed
BIN
-30.5 KB
...rence/orion-fusion-theme/en/chrome_large/folder-tree-spec/basic_folder_tree.png
Binary file not shown.
Binary file removed
BIN
-31.3 KB
...on-fusion-theme/en/chrome_large/folder-tree-spec/basic_folder_tree_selected.png
Binary file not shown.
Binary file modified
BIN
-22 KB
(27%)
...ence/orion-fusion-theme/en/chrome_medium/folder-tree-spec/basic_folder_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-22 KB
(29%)
...n-fusion-theme/en/chrome_medium/folder-tree-spec/basic_folder_tree_selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.49 KB
...rence/orion-fusion-theme/en/chrome_medium/folder-tree-spec/collapsed_folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.77 KB
...erence/orion-fusion-theme/en/chrome_medium/folder-tree-spec/expanded_folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.81 KB
...rence/orion-fusion-theme/en/chrome_small/folder-tree-spec/basic_folder_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.64 KB
...on-fusion-theme/en/chrome_small/folder-tree-spec/basic_folder_tree_selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.38 KB
...erence/orion-fusion-theme/en/chrome_small/folder-tree-spec/collapsed_folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.61 KB
...ference/orion-fusion-theme/en/chrome_small/folder-tree-spec/expanded_folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file removed
BIN
-35.7 KB
...ence/terra-default-theme/en/chrome_large/folder-tree-spec/basic_folder_tree.png
Binary file not shown.
Binary file removed
BIN
-36.4 KB
...a-default-theme/en/chrome_large/folder-tree-spec/basic_folder_tree_selected.png
Binary file not shown.
Binary file modified
BIN
-26.5 KB
(25%)
...nce/terra-default-theme/en/chrome_medium/folder-tree-spec/basic_folder_tree.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-26.4 KB
(26%)
...-default-theme/en/chrome_medium/folder-tree-spec/basic_folder_tree_selected.png
Oops, something went wrong.
Binary file added
BIN
+4.47 KB
...ence/terra-default-theme/en/chrome_medium/folder-tree-spec/collapsed_folder.png
Oops, something went wrong.
Binary file added
BIN
+7.16 KB
...rence/terra-default-theme/en/chrome_medium/folder-tree-spec/expanded_folder.png
Oops, something went wrong.
Binary file added
BIN
+8.47 KB
...ence/terra-default-theme/en/chrome_small/folder-tree-spec/basic_folder_tree.png
Oops, something went wrong.
Binary file added
BIN
+9.21 KB
...a-default-theme/en/chrome_small/folder-tree-spec/basic_folder_tree_selected.png
Oops, something went wrong.
Binary file added
BIN
+4.35 KB
...rence/terra-default-theme/en/chrome_small/folder-tree-spec/collapsed_folder.png
Oops, something went wrong.
Binary file added
BIN
+6.98 KB
...erence/terra-default-theme/en/chrome_small/folder-tree-spec/expanded_folder.png
Oops, something went wrong.
File renamed without changes
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
3 changes: 3 additions & 0 deletions
3
...rc/terra-dev-site/doc/folder-tree/Examples.2/ExpandCollapseFolderTree.2.doc.mdx
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,3 @@ | ||
import ExpandCollapseFolderTree from './ExpandCollapseFolderTree?dev-site-example'; | ||
|
||
<ExpandCollapseFolderTree /> |
Oops, something went wrong.