Skip to content

Commit 9954ca8

Browse files
authored
docs: update getting started for alpha.9 (#1338)
1 parent fc9e55e commit 9954ca8

File tree

3 files changed

+30
-44
lines changed

3 files changed

+30
-44
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ Angular Material has changed from `@angular2-material/...` packages to a single
99
contains all of the components. Build tools such as [`rollup.js`](http://rollupjs.org/) can perform
1010
tree-shaking to eliminate the code for components that you aren't using.
1111

12+
The addition of theming as also changed the directory structure for bringing the core css into your
13+
application. See the new [theming guide](docs/theming.md) for more information.
14+
1215

1316
### Features
1417

GETTING_STARTED.md

+16-29
Original file line numberDiff line numberDiff line change
@@ -14,54 +14,37 @@ Get started with Angular Material 2 using the Angular CLI.
1414

1515
The new command creates a project with a build system for your Angular app.
1616

17-
## Install Angular Material 2 components
18-
19-
Angular Material 2 components are set up in separate modules. This allows you to only pull into your app what you need, reducing the size of your app. Components are installed individually. You can see our [list of published packages here](https://www.npmjs.com/~angular2-material).
20-
21-
Note that only packages published under the `@latest` npm tag are officially released.
17+
## Install Angular Material components
2218

2319
```bash
24-
npm install --save @angular2-material/core @angular2-material/button @angular2-material/card
20+
npm install --save @angular/material
2521
```
2622

27-
> The core module is required as a peer dependency of other components
28-
29-
## Add components to your app module
30-
Now you should be able to import the components normally wherever you'd like to use them. Import the components in your application module:
23+
## Import the Angular Material NgModule
3124

3225
**src/app/app.module.ts**
3326
```ts
34-
import { MdButtonModule } from '@angular2-material/button';
35-
import { MdCardModule } from '@angular2-material/card';
27+
import { MaterialModule } from '@angular/material';
3628
// other imports
3729
@NgModule({
38-
imports: [MdButtonModule.forRoot(), MdCardModule.forRoot()],
30+
imports: [MaterialModule.forRoot()],
3931
...
4032
})
33+
export class PizzaPartyAppModule { }
4134
```
4235

43-
### Sample Angular Material 2 project
44-
- [Material 2 Sample App](https://github.com/jelbourn/material2-app)
45-
36+
### Including core and theme styles:
37+
See the [theming guide](docs/theming.md) for more information.
4638

47-
### Additional setup for `md-menu` and `md-tooltip`:
48-
For alpha.7, you need to include the overlay styles in your app via a `link` element. This will
49-
look something like
50-
```html
51-
<link href="vendor/@angular2-material/core/overlay/overlay.css" rel="stylesheet">
52-
```
53-
54-
In future releases, all of the core styles will be combined into a single distributed css file.
5539

5640
### Additional setup for `md-slide-toggle` and `md-slider`:
5741
The slide-toggle and slider components have a dependency on [HammerJS](http://hammerjs.github.io/).
58-
1) Add HammerJS to your application via [npm](https://www.npmjs.com/package/hammerjs), a CDN
59-
(such as the [Google CDN](https://developers.google.com/speed/libraries/#hammerjs)),
60-
or served directly from your app.
61-
2) Include the typings for HammerJS in your typescript build ([more info on @types](https://blogs.msdn.microsoft.com/typescript/2016/06/15/the-future-of-declaration-files))
6242

43+
Add HammerJS to your application via [npm](https://www.npmjs.com/package/hammerjs), a CDN
44+
(such as the [Google CDN](https://developers.google.com/speed/libraries/#hammerjs)), or served
45+
directly from your app.
6346

64-
### Additional setup for `md-icon`:
47+
### [Optional] Using Material Design icons with `md-icon`:
6548

6649
- If you want to use Material Design icons, load the Material Design font in your `index.html`.
6750
`md-icon` supports any font icons or svg icons, so this is only one potential option.
@@ -70,3 +53,7 @@ The slide-toggle and slider components have a dependency on [HammerJS](http://ha
7053
```html
7154
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
7255
```
56+
57+
### Sample Angular Material 2 projects
58+
- [Material 2 Sample App](https://github.com/jelbourn/material2-app)
59+
- [Angular Connect 2016 Demo](https://github.com/kara/leashed-in)

docs/theming.md

+11-15
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@ include all of the styles for core (styles common to all components), so you onl
2424
single css file for Angular Material in your app.
2525

2626
You can include a theme file directly into your application from
27-
`@angular2-material/core/theming/prebuilt`
27+
`@angular/material/core/theming/prebuilt`
2828

2929
If you're using Angular CLI, this is as simple as including one line
3030
in your `style.css` file:
3131
```css
32-
@import '~@angular2-material/core/theming/prebuilt/deeppurple-amber.css';
32+
@import '~@angular/material/core/theming/prebuilt/deeppurple-amber.css';
3333
```
3434

3535
Alternatively, you can just reference the file directly. This would look something like
3636
```html
37-
<link href="node_modules/@angular2-material/core/theming/prebuilt/indigo-pink.css" rel="stylesheet">
37+
<link href="node_modules/@angular/material/core/theming/prebuilt/indigo-pink.css" rel="stylesheet">
3838
```
3939
The actual path will depend on your server setup.
4040

@@ -46,10 +46,7 @@ When you want more customization than a pre-built theme offers, you can create y
4646
A theme file is a simple Sass file that defines your palettes and passes them to mixins that output
4747
the corresponding styles. A typical theme file will look something like this:
4848
```scss
49-
@import '~@angular2-material/core/theming/theming';
50-
@import '~@angular2-material/core/theming/palette';
51-
@import '~@angular2-material/core/core';
52-
@import '~@angular2-material/button/button-theme';
49+
@import '~@angular/material/core/theming/all-theme';
5350
// Plus imports for other components in your app.
5451

5552
// Include the base styles for Angular Material core. We include this here so that you only
@@ -61,15 +58,17 @@ the corresponding styles. A typical theme file will look something like this:
6158
// hue.
6259
$primary: md-palette($md-indigo);
6360
$accent: md-palette($md-pink, A200, A100, A400);
61+
62+
// The warn palette is optional (defaults to red).
6463
$warn: md-palette($md-red);
6564

6665
// Create the theme object (a Sass map containing all of the palettes).
6766
$theme: md-light-theme($primary, $accent, $warn);
6867

6968
// Include theme styles for core and each component used in your app.
70-
@include md-core-theme($theme);
71-
@include md-button-theme($theme);
72-
// Plus includes for other components in your app.
69+
// Alternatively, you can import and @include the theme mixins for each component
70+
// that you are using.
71+
@include angular-material-theme($theme);
7372
```
7473

7574
You only need this single Sass file; you do not need to use Sass to style the rest of your app.
@@ -99,8 +98,7 @@ secondary dark theme:
9998

10099
$dark-theme: md-dark-theme($dark-primary, $dark-accent, $dark-warn);
101100

102-
@include md-core-theme($dark-theme);
103-
@include md-button-theme($dark-theme);
101+
@include angular-material-theme($dark-theme);
104102
}
105103
```
106104

@@ -111,7 +109,7 @@ dark theme.
111109
In order to style your own components with our tooling, the component's styles must be defined
112110
with Sass.
113111

114-
You can consume the theming functions and variables from the `@angular2-material/core/theming`.
112+
You can consume the theming functions and variables from the `@angular/material/core/theming`.
115113
You can use the `md-color` function to extract a specific color from a palette. For example:
116114
```scss
117115
.unicorn-carousel {
@@ -121,7 +119,5 @@ You can use the `md-color` function to extract a specific color from a palette.
121119
```
122120

123121
### Future work
124-
* When the "all" package is released, there will be a mixin that captures all of the component's
125-
theme styles so that you don't have to include them all individually.
126122
* Once CSS variables (custom properties) are available in all the browsers we support,
127123
we will explore how to take advantage of them to make theming even simpler.

0 commit comments

Comments
 (0)