问题
I'm using polymer and polymer_elements in my angular2-dart project.
I'm able to add polymer elements (such as paper-card), but I'm not able to use css-mixins, I don't know if I missing an import or something.
My .dart
import 'package:angular2/core.dart';
//Polymer imports
import 'package:polymer_elements/paper_card.dart';
import 'package:polymer_elements/paper_button.dart';
import 'package:polymer_elements/paper_icon_button.dart';
import 'package:polymer_elements/iron_icon.dart';
import 'package:polymer_elements/paper_styles/classes/typography.dart';
import 'package:polymer_elements/iron_flex_layout/classes/iron_flex_layout.dart';
@Component(
templateUrl: '../view/book_splash_component.html',
selector: 'book-splash',
styleUrls: const ['../view/css/book_splash_component.css'],
encapsulation: ViewEncapsulation.Native
)
class BookSplashComponent{
//nothing that matters
}
My .html
<paper-card class="rate">
<div class="rate-content">
<div class="card-content">
<div class="rate-header">Rate this album</div>
<div class="rate-name">Mac Miller</div>
<div>Live from space</div>
</div>
<div class="card-actions">
<paper-icon-button class="rate-icon" icon="star"></paper-icon-button>
</div>
</div>
<div class="rate-image"></div>
</paper-card>
My .css with mixins (which doesn't work)
paper-card.rate { @apply(--layout-horizontal); }
.rate-image {
width: 100px;
height: 170px;
background: url('./donuts.png');
background-size: cover;
}
.rate-content {
@apply(--layout-flex);
float: left;
}
.rate-header { @apply(--paper-font-headline); }
.rate-name { color: var(--paper-grey-600); margin: 10px 0; }
paper-icon-button.rate-icon {
--iron-icon-fill-color: white;
--iron-icon-stroke-color: var(--paper-grey-600);
}
But if I replace mixins with the corresponding styles it works! Probably I'm missing something stupid.
I'm trying "Paper-cards can have a horizontal image" example here: https://elements.polymer-project.org/elements/paper-card?active=paper-card&view=demo:demo/index.html
回答1:
Did you try to play with shadow dom, like disable it in your angular component or on polymer to see what happen ?
回答2:
This is Polymer specific and works only in the style tag of a Polymer element or in a <style is="custom-style">
in the head element.
来源:https://stackoverflow.com/questions/37490068/how-to-use-css-mixins-with-angular-2-dart-and-polymer