Skip to content
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

feat(schematics): add shell schematic #9883

Merged
merged 4 commits into from Feb 18, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions schematics/README.md
@@ -0,0 +1,5 @@
# Angular Material Schematics
A collection of Schematics for Angular Material.

## Collection
- [Shell](shell/README.md)
10 changes: 9 additions & 1 deletion schematics/collection.json
@@ -1,5 +1,13 @@
// This is the root config file where the schematics are defined.
{
"$schema": "./node_modules/@angular-devkit/schematics/collection-schema.json",
"schematics": {}
"schematics": {
// Adds Angular Material to an application without changing any templates
"materialShell": {
Copy link
Member

Choose a reason for hiding this comment

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

FYI we're probably going to change this name at some point but it's still TBD

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be ng-add.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding an alias for it gives this error: Error: Schematics/alias "ng-add" collides with another alias or schematic name.

"description": "Create a Material shell",
Copy link
Member

Choose a reason for hiding this comment

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

Could you expand the description to something like "Adds Angular Material to an application without changing any templates"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the record, comments are technically not supported in JSON. ;P

Copy link
Contributor

Choose a reason for hiding this comment

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

The collection.json are read as JSON5; http://json5.org/

"factory": "./shell",
"schema": "./shell/schema.json",
"aliases": ["material-shell"]
}
}
}
219 changes: 219 additions & 0 deletions schematics/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions schematics/shell/README.md
@@ -0,0 +1,10 @@
# Material Shell
Adds Angular Material and its depedencies and pre-configures the application.

- Adds Material and CDK to `package.json`
- Adds Material Icons Stylesheet to `index.html`
- Adds Roboto Font to `index.html`
- Ensure `BrowserAnimationsModule` is installed and included in root module
- Adds pre-configured theme to `.angular-cli.json` file OR adds custom theme scaffolding to `styles.scss`

Command: `ng generate material-shell --collection=material-schematics`
28 changes: 28 additions & 0 deletions schematics/shell/custom-theme.ts
@@ -0,0 +1,28 @@
export const CUSTOM_THEME =
`
@import '~@angular/material/theming';
// Plus imports for other components in your app.

// Include the common styles for Angular Material. We include this here so that you only
// have to load a single css file for Angular Material in your app.
// Be sure that you only ever include this mixin once!
@include mat-core();

// Define the palettes for your theme using the Material Design palettes available in palette.scss
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
// hue. Available color palettes: https://www.google.com/design/spec/style/color.html
Copy link
Member

Choose a reason for hiding this comment

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

We should add a link to the theming guide here in comments

$candy-app-primary: mat-palette($mat-indigo);
Copy link
Member

Choose a reason for hiding this comment

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

Can we get the real name of the app in here instead of candy-app?

$candy-app-accent: mat-palette($mat-pink, A200, A100, A400);

// The warn palette is optional (defaults to red).
$candy-app-warn: mat-palette($mat-red);

// Create the theme object (a Sass map containing all of the palettes).
$candy-app-theme: mat-light-theme($candy-app-primary, $candy-app-accent, $candy-app-warn);

// Include theme styles for core and each component used in your app.
// Alternatively, you can import and @include the theme mixins for each component
// that you are using.
@include angular-material-theme($candy-app-theme);

`;