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

mat-card-flat SCSS class not working #11014

Closed
odahcam opened this issue Apr 25, 2018 · 4 comments · Fixed by #11028
Closed

mat-card-flat SCSS class not working #11014

odahcam opened this issue Apr 25, 2018 · 4 comments · Fixed by #11028
Assignees
Labels
P4 A relatively minor issue that is not relevant to core functions

Comments

@odahcam
Copy link
Contributor

odahcam commented Apr 25, 2018

Bug, feature request, or proposal:

bug

What is the expected behavior?

.mat-card-flat class to make a card look flatten.

What is the current behavior?

So many shadows.

What are the steps to reproduce?

https://stackblitz.com/edit/angular-material2-issue-ercan7?file=app/app.component.html

What is the use-case or motivation for changing an existing behavior?

The class is there and it's not working.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Material >= 5 <= 6

Is there anything else we should know?

image

The class .mat-elevation-z works, that's because a rule in;
https://github.com/angular/material2/blob/21d004a4322df944539458281e1983965cfb6edd/src/lib/core/style/_elevation.scss#L151
...I think.

@EdricChan03
Copy link
Contributor

That's because the styles for the card seem to be overriding the .mat-card-flat class. If you check the DevTools, the .mat-card:not([class*="mat-elevation-z"]) seems to override .mat-card-flat.

@odahcam
Copy link
Contributor Author

odahcam commented Apr 26, 2018

Exactly, I just don't have any idea on how to fix it.

@crisbeto crisbeto self-assigned this Apr 26, 2018
@crisbeto crisbeto added has pr P4 A relatively minor issue that is not relevant to core functions labels Apr 26, 2018
crisbeto added a commit to crisbeto/material2 that referenced this issue Apr 26, 2018
Fixes the `.mat-flat-card` selector not working due to its specificity being too low.

Fixes angular#11014.
crisbeto added a commit to crisbeto/material2 that referenced this issue Apr 26, 2018
Fixes the `.mat-flat-card` selector not working due to its specificity being too low.

Fixes angular#11014.
@odahcam
Copy link
Contributor Author

odahcam commented Apr 26, 2018

I'd like to suggest a matCardFlat directive that would automatically handle the flat effect, removing the user's need of knowing how to style the component, something like this:

import { Directive, ElementRef } from '@angular/core';

@Directive({
  selector: 'mat-card[matCardFlat]',
  exportAs: 'matCardFlat'
})
export class MatCardFlatDirective {

    constructor(elRef: ElementRef) {
        const el: HTMLElement = elRef.nativeElement;
        el.classList.add('mat-card-flat', 'mat-elevation-z0');
    }

}

Where .mat-card-flat could also make squared border cards, etc.

andrewseguin pushed a commit that referenced this issue Apr 26, 2018
Fixes the `.mat-flat-card` selector not working due to its specificity being too low.

Fixes #11014.
@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
P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants