-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(tree): Add material styled tree #8458
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
Merged
Changes from all commits
Commits
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
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
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
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
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
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
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
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
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
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
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
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
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,27 @@ | ||
@import '../core/theming/palette'; | ||
@import '../core/theming/theming'; | ||
@import '../core/typography/typography-utils'; | ||
|
||
@mixin mat-tree-theme($theme) { | ||
$background: map-get($theme, background); | ||
$foreground: map-get($theme, foreground); | ||
|
||
.mat-tree { | ||
background: mat-color($background, 'card'); | ||
} | ||
|
||
.mat-tree-node { | ||
color: mat-color($foreground, text); | ||
} | ||
} | ||
|
||
@mixin mat-tree-typography($config) { | ||
.mat-tree { | ||
font-family: mat-font-family($config); | ||
} | ||
|
||
.mat-tree-node { | ||
font-weight: mat-font-weight($config, body-1); | ||
font-size: mat-font-size($config, body-1); | ||
} | ||
} |
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,9 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
export * from './public-api'; |
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,73 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { | ||
ContentChildren, | ||
Directive, | ||
Input, | ||
QueryList | ||
} from '@angular/core'; | ||
import { | ||
CdkNestedTreeNode, | ||
CdkTreeNodeDef, | ||
CdkTreeNode, | ||
} from '@angular/cdk/tree'; | ||
import {MatTreeNodeOutlet} from './outlet'; | ||
|
||
/** | ||
* Wrapper for the CdkTree node with Material design styles. | ||
*/ | ||
// TODO(tinayuangao): use mixinTabIndex | ||
@Directive({ | ||
selector: 'mat-tree-node', | ||
exportAs: 'matTreeNode', | ||
host: { | ||
'[attr.role]': 'role', | ||
'class': 'mat-tree-node', | ||
'tabindex': '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. Add |
||
}, | ||
providers: [{provide: CdkTreeNode, useExisting: MatTreeNode}] | ||
}) | ||
export class MatTreeNode<T> extends CdkTreeNode<T> { | ||
@Input() role: 'treeitem' | 'group' = 'treeitem'; | ||
} | ||
|
||
/** | ||
* Wrapper for the CdkTree node definition with Material design styles. | ||
*/ | ||
@Directive({ | ||
selector: '[matTreeNodeDef]', | ||
inputs: [ | ||
'when: matTreeNodeDefWhen' | ||
], | ||
providers: [{provide: CdkTreeNodeDef, useExisting: MatTreeNodeDef}] | ||
}) | ||
export class MatTreeNodeDef<T> extends CdkTreeNodeDef<T> { | ||
@Input('matTreeNode') data: T; | ||
} | ||
|
||
/** | ||
* Wrapper for the CdkTree nested node with Material design styles. | ||
*/ | ||
@Directive({ | ||
selector: 'mat-nested-tree-node', | ||
exportAs: 'matNestedTreeNode', | ||
host: { | ||
'[attr.role]': 'role', | ||
'class': 'mat-nested-tree-node', | ||
}, | ||
providers: [ | ||
{provide: CdkNestedTreeNode, useExisting: MatNestedTreeNode}, | ||
{provide: CdkTreeNode, useExisting: MatNestedTreeNode} | ||
] | ||
}) | ||
export class MatNestedTreeNode<T> extends CdkNestedTreeNode<T> { | ||
@Input('matNestedTreeNode') node: T; | ||
|
||
@ContentChildren(MatTreeNodeOutlet) nodeOutlet: QueryList<MatTreeNodeOutlet>; | ||
} |
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,23 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
import {CdkTreeNodeOutlet} from '@angular/cdk/tree'; | ||
import { | ||
Directive, | ||
ViewContainerRef, | ||
} from '@angular/core'; | ||
|
||
/** | ||
* Outlet for nested CdkNode. Put `[matTreeNodeOutlet]` on a tag to place children dataNodes | ||
* inside the outlet. | ||
*/ | ||
@Directive({ | ||
selector: '[matTreeNodeOutlet]' | ||
}) | ||
export class MatTreeNodeOutlet implements CdkTreeNodeOutlet { | ||
constructor(public viewContainer: ViewContainerRef) {} | ||
} |
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.
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.
Under what circumstances would this be undefined?
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.
We have to initialize
mostRecentTreeNode
because of the error/usr/local/google/home/tinagao/WebstormProjects/material2/src/cdk/tree/node.ts:79:10: Metadata collected contains an error that will be reported at runtime: Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler.
So I initialize the static variable to be null, and we have to check whether it's null here.
But the value shouldn't be
null
orundefined
when we call it fromtree.ts