-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(schematics): dashboard schematic #10011
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
Conversation
margin: 20px; | ||
} | ||
|
||
mat-card { |
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.
Why absolute positioning?
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.
I couldn't come up with a good way to make the card 100% height/width with 15px margin. Open to ideas if you have any.
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.
calc(100% - 15px)
?
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.
Results in this - https://www.screencast.com/t/Q2MpKLRi :(
@@ -0,0 +1,24 @@ | |||
<div class="grid-container"> | |||
<h1 class="mat-h1">Dashboard</h1> | |||
<mat-grid-list cols="2" rowHeight="350px"> |
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.
Grid-list is only useful when you want items with heterogenous rowspans. We could either mix that in, or just use cards laid out with flex styles.
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.
I'll update it to have spans :)
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.
Are the rowspans meaningful here? A screenshot would be helpful
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.
<mat-card-title> | ||
{{card.title}} | ||
<button mat-icon-button [matMenuTriggerFor]="menu"> | ||
<mat-icon aria-label="Menu icon">more_vert</mat-icon> |
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.
It might be more appropriate to have the aria-label
be on the button
. See the examples in menu-a11y.html
.
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { |
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.
The two beforeEach
calls can be combined.
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.
This code was copied from the base component schematic.
let component: <%= classify(name) %>Component; | ||
let fixture: ComponentFixture<<%= classify(name) %>Component>; | ||
|
||
beforeEach(async(() => { |
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.
Use fakeAsync
instead of async
.
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.
This code was copied from the base component schematic.
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
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.
Missing a newline at the end of the file.
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { |
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.
should create -> should compile
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.
This code was copied from the base component schematic.
@@ -0,0 +1,74 @@ | |||
import { Component, <% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%><% if(changeDetection !== 'Default') { %>, ChangeDetectionStrategy<% }%> } from '@angular/core'; | |||
|
|||
declare var google: any; |
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.
It doesn't look like this is being used anywhere.
<mat-card-title> | ||
{{card.title}} | ||
<button mat-icon-button [matMenuTriggerFor]="menu"> | ||
<mat-icon aria-label="Menu icon">more_vert</mat-icon> |
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.
Same note as the other template. The aria-label
should be on the button and be more descriptive.
schematics/dashboard/index_spec.ts
Outdated
const tree = runner.runSchematic('materialDashboard', { ...options }, createTestApp()); | ||
const files = tree.files; | ||
|
||
expect(files.indexOf('/src/app/foo/foo.component.css')).toBeGreaterThanOrEqual(0); |
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.
These assertions can be rewritten using toContain
, e.g.
expect(files).toContain('/src/app/foo/foo.component.css');
}, | ||
"flat": { | ||
"type": "boolean", | ||
"description": "Flag to indicate if a dir is created.", |
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.
Unclear what dir
is referring to.
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.
This code was copied from the base component schematic.
margin: 20px; | ||
} | ||
|
||
mat-card { |
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.
calc(100% - 15px)
?
@@ -0,0 +1,24 @@ | |||
<div class="grid-container"> | |||
<h1 class="mat-h1">Dashboard</h1> | |||
<mat-grid-list cols="2" rowHeight="350px"> |
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.
Are the rowspans meaningful here? A screenshot would be helpful
margin: 20px; | ||
} | ||
|
||
mat-card { |
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.
Kind of nit-picky, but since this could set the pattern for a project I'll get into it:
I think each of these styles that currently target a mat
element or attribute should be a css class instead. While those selectors are fine in this skeleton, I don't want to give people the impression that this is the way they should always style custom components. Introducing a separate css class signals the intent that you want to style a specific instance of a component rather than all instances of that component.
changeDetection: ChangeDetectionStrategy.<%= changeDetection %><% } %> | ||
}) | ||
export class <%= classify(name) %>Component { | ||
cards = [ |
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.
Condense this?
cards = [
{title: 'Card 1', cols: 2, rows: 1},
{title: 'Card 2', cols: 1, rows: 1},
{title: 'Card 3', cols: 1, rows: 2},
{title: 'Card 4', cols: 1, rows: 1}
];
@jelbourn - Ready for review. |
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.
LGTM
@amcdnl just needs rebase |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This PR adds a dashboard schematic.
Can be viewed here: https://github.com/amcdnl/material-example-schematics/tree/schematic-dashboard