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

Docs (Guides): Mat elevation guide #3917

Closed
wants to merge 11 commits into from

Conversation

M-a-c
Copy link
Contributor

@M-a-c M-a-c commented Apr 5, 2017

Added a basic guide on how to use Mat Elevation.
Includes Example

  • Link to Material designs spec for Elevation
  • How to use the CSS class
  • How to use the mixin
  • Deprecated naming

Fixes #2800

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Apr 5, 2017

## Mixins
In order to use the mixin for Elevation you must
`@import '~@angular/material/core/style/_elevation.scss';`
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be ~@angular/material/theming now that they're using a flat release structure (#3776)

Copy link
Contributor Author

@M-a-c M-a-c Apr 5, 2017

Choose a reason for hiding this comment

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

Ok yeah I'll have to fix this then

Copy link
Contributor Author

@M-a-c M-a-c Apr 5, 2017

Choose a reason for hiding this comment

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

@willshowell Do you know if i will need to specify elevation.scss from that path?
@import '~@angular/material/theming/style/_elevation.scss';?

Copy link
Contributor

Choose a reason for hiding this comment

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

@M-a-c no that should error. Using the master builds, check out your node_modules. At /node_modules/@angular/material/_theming.scss you can see that all the mixins/functions/definitions are concatenated together, including mat-elevation().

And due to Sass importing of partials, you don't need the leading underscore or file extension in your import statement.

How to use the mixin
```scss
.myClass {
@include $mat-elevation(2);

Choose a reason for hiding this comment

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

shouldn't this be without the $? -> @include mat-elevation(2);

@include $mat-elevation(2);

&:active {
@include $mat-elevation(8);

Choose a reason for hiding this comment

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

same here

}

.dynamimc {
@include $mat-elevation(2);

Choose a reason for hiding this comment

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

Also without $ ? At least in my Project it won't compile with a $

@M-a-c
Copy link
Contributor Author

M-a-c commented Apr 10, 2017

@Sabartius thanks for the feedback

.dynamimc {
@include mat-elevation(2);

&:active {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be &:hover?

@@ -0,0 +1,5 @@
<div class="dynamimc">Hover over me!</div>
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean dynamic?

}


.dynamimc {
Copy link
Member

Choose a reason for hiding this comment

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

Ditto

```

## Deprecated
The use of `mdElevation($zValue)` is deprecated.
Copy link
Member

Choose a reason for hiding this comment

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

Should we use the words attribute / directive in this text to be more clear?

@@ -0,0 +1,5 @@
<div class="dynamimc">Hover over me!</div>

<div class"no-elevation">No Elevation</div>
Copy link
Member

Choose a reason for hiding this comment

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

Does adding the no-elevation class here create confusion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good point, I removed it in the next commit

Copy link
Member

@Splaktar Splaktar left a comment

Choose a reason for hiding this comment

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

LGTM

@Splaktar
Copy link
Member

@ladyleet any additional comments/suggestions for this PR?

&:hover {
@include mat-elevation(8);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

newline

@@ -0,0 +1,33 @@
# mat-elevation
Copy link
Contributor

Choose a reason for hiding this comment

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

how do you feel about this?

# Elevation
Angular Material's elevation classes and mixins allow you to add separation between elements along the z-axis.
All material design elements have resting elevations. In addition, some elements may change their elevation in response to user interaction. The [Material Design spec](https://material.io/guidelines/material-design/elevation-shadows.html) explains how best to use elevation.

Angular Material provides two ways to control the elevation of elements: predefined CSS classes and mixins.

## Predefined CSS classes
The easiest way to add elevation to an element is to simply add one of the predefined CSS classes `mat-elevation-z#` where `#` is the elevation number you want, 0-24. Dynamic elevation can be acheived by switching elevation classes:

```html
<div [class.mat-elevation-z2]="!isActive" [class.mat-elevation-z8]="isActive"></div>
```

<!-- example(elevation-overview) -->

## Mixins
Elevations can also be added in CSS via the `mat-elevation` mixin, which takes a number 0-24 indicating the elevation level of the element. In order to use the mixin you must import `~@angular/material/theming`.

```scss
@import ~@angular/material/theming;

.myClass {
  @include mat-elevation(2);

  &:active {
    @include mat-elevation(8);
  }
}
```

@mmalerba
Copy link
Contributor

Closing due to inactivity

@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 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add elevation guide
6 participants