Skip to content

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

Merged
merged 6 commits into from
Mar 10, 2018

Conversation

amcdnl
Copy link
Contributor

@amcdnl amcdnl commented Feb 18, 2018

This PR adds a dashboard schematic.

Can be viewed here: https://github.com/amcdnl/material-example-schematics/tree/schematic-dashboard

@amcdnl amcdnl self-assigned this Feb 18, 2018
@amcdnl amcdnl requested a review from jelbourn February 18, 2018 17:23
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Feb 18, 2018
margin: 20px;
}

mat-card {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why absolute positioning?

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calc(100% - 15px)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,24 @@
<div class="grid-container">
<h1 class="mat-h1">Dashboard</h1>
<mat-grid-list cols="2" rowHeight="350px">
Copy link
Member

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.

Copy link
Contributor Author

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 :)

Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jelbourn jelbourn requested a review from crisbeto February 18, 2018 20:35
<mat-card-title>
{{card.title}}
<button mat-icon-button [matMenuTriggerFor]="menu">
<mat-icon aria-label="Menu icon">more_vert</mat-icon>
Copy link
Member

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(() => {
Copy link
Member

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.

Copy link
Contributor Author

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(() => {
Copy link
Member

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.

Copy link
Contributor Author

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();
});
});
Copy link
Member

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', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should create -> should compile

Copy link
Contributor Author

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;
Copy link
Member

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>
Copy link
Member

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.

const tree = runner.runSchematic('materialDashboard', { ...options }, createTestApp());
const files = tree.files;

expect(files.indexOf('/src/app/foo/foo.component.css')).toBeGreaterThanOrEqual(0);
Copy link
Member

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.",
Copy link
Member

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.

Copy link
Contributor Author

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 {
Copy link
Member

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">
Copy link
Member

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 {
Copy link
Member

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 = [
Copy link
Member

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}
  ];

@amcdnl
Copy link
Contributor Author

amcdnl commented Mar 8, 2018

@jelbourn - Ready for review.

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker target: major This PR is targeted for the next major release labels Mar 8, 2018
@jelbourn
Copy link
Member

jelbourn commented Mar 8, 2018

@amcdnl just needs rebase

@jelbourn jelbourn merged commit 6273d6a into angular:master Mar 10, 2018
@amcdnl amcdnl deleted the dashboard-schematic branch March 12, 2018 21:56
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants