Skip to content

Turn md-card element to mdCard Directive to give other elements 'Card powers' #6739

Closed

Description

@jagomf

Proposal:

To have md-card be a Directive instead of a Component so any element/component can be given Card behavior

What is the expected behavior?

To be able to have <my-component mdCard>.

What is the current behavior?

Currently only a <md-card> component can be visualized as a Card.

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

Be able to apply whatever logic to <my-component> and still keep visualization like a Card with mdCard directive.

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

All

Activity

  1. changed the title [-]md-card as Directive to give other elements 'Card powers'[/-] [+]Turn md-card element to mdCard Directive to give other elements 'Card powers'[/+] on Aug 30, 2017
  2. josephperrott commented on Aug 30, 2017

    @josephperrott
    Member

    Unfortunately its not possible to have md-card as a Directive because it uses a template.

    Furthermore, if the templating were to be removed, styles cannot be applied via Directive selectors as shown in the documentation for the @Directive decorator.

    If you are looking to provide the elevated look of the md-card, you should be able to do this using box-shadow on any components.

  3. willshowell commented on Aug 30, 2017

    @willshowell
    Contributor

    To supplement @josephperrott's answer, material provides a mat-elevation mixin and helper classes for adding elevation to elements:

    <div class="mat-elevation-z12">I am an elevated div</div>
    
    <div class="elevate-me">Me too!</div>
    .elevate-me {
      @include mat-elevation(8);
    }

    See #3917 for in-progress guide

  4. jagomf commented on Sep 6, 2017

    @jagomf
    Author

    Elevation is not the only feature that a card provides... If I only wanted a <div> to look like a card, I could just use class mat-card. That is not the point.

    All the elements (<md-card-header>, <md-card-title>, <md-card-content>, etc) lose all their appearance and behavior if there is no <md-card> element on top.

  5. angular-automatic-lock-bot commented on Sep 7, 2019

    @angular-automatic-lock-bot

    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.

  6. locked and limited conversation to collaborators on Sep 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions