Skip to content

Commit

Permalink
feat(schematics): add material scaffolding schematic (#9883)
Browse files Browse the repository at this point in the history
  • Loading branch information
amcdnl authored and jelbourn committed Feb 18, 2018
1 parent 17255e1 commit 45399c6
Show file tree
Hide file tree
Showing 13 changed files with 503 additions and 15 deletions.
5 changes: 5 additions & 0 deletions schematics/README.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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": {
"description": "Create a Material shell",
"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
Original file line number Diff line number Diff line change
@@ -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`
37 changes: 37 additions & 0 deletions schematics/shell/custom-theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {AppConfig} from '../utils/devkit-utils/config';

/**
* Create custom theme for the given application configuration.
*/
export function createCustomTheme(app: AppConfig) {
const name = app.name || 'app';
return `
// Custom Theming for Angular Material
// For more information: https://material.angular.io/guide/theming
@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
$${name}-primary: mat-palette($mat-indigo);
$${name}-accent: mat-palette($mat-pink, A200, A100, A400);
// The warn palette is optional (defaults to red).
$${name}-warn: mat-palette($mat-red);
// Create the theme object (a Sass map containing all of the palettes).
$${name}-theme: mat-light-theme($${name}-primary, $${name}-accent, $${name}-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($${name}-theme);
`;
}
Loading

0 comments on commit 45399c6

Please sign in to comment.