Unfortunately, I'm finding the current documentation/examples for the usage of paper-styles a bit lacking. I'm not an experienced CSS guy (relative newbie actually), so I could really use examples of how to implement Polymer 1.0 application-wide styling in order to be used by all of it's custom elements (i.e. by applying classes to any tags in those custom element's local DOMs). I did this kind of thing relatively easily in Polymer 0.5 using core-styles, but it has changed enough in 1.0 to confuse me, particularly without full docs/examples to work from. It also seems there may be a few ways to accomplish this. I'm also wondering if paper-styles is still considered experimental in 1.0? There are no docs or examples for it's use in polymer 1.0 online element catalog (https://elements.polymer-project.org/elements/paper-styles), although I did come across 'some' on it's gitHub repository.
相关问题
- How can I dynamically add items into paper-dropdow
- How can I dynamically add items into paper-dropdow
- 2 way data-binding between a polymer component and
- Shadow DOM CSS Styling from outside is not working
- How to get Polymer 2.0 ES5 elements working with v
相关文章
- Access shadow DOM properties (polymer) with javasc
- document.querySelector() returns null
- Updating Polymer component via Websocket?
- polymer duplicate element content
- Where is it best to handle the business logic in m
- How do you bind Polymer elements to a Model in ASP
- Polymer 2.0: Notify and reflect to attribute
- Polymer paper-dialog position
One thing you can do when documentation is lacking is search through other projects that are using the code you would like to use.
paper-tabs
, for example, usespaper-styles
. You can see an example import ofpaper-styles/color.html
inpaper-tabs.html
. The value--paper-yellow-a100
is being used inpaper-tabs.html
. Below is an example of using various CSS variables (var
) and mixins (@apply
) defined inpaper-styles
to apply style to the main document.Click here to learn more about styling in Polymer 1.0.
Concerning your question about paper-styles being experimental, on the Polymer home page in the catalog section it states:
However, in various locations on the site, including styling, there are mentions of experimental features.
At this time using
@apply
would be considered experimental.There is a page on the Polymer website titled Experimental features & elements you can look at for more information.
The general misunderstanding seems to be, that just by importing the
paper-styles
element, the document gets styled according to the material design specs. That's not the case.You just get all the variables and mixins.
Then you need to apply them to each and every element inside your custom-element the way you see it fit.
Here is an example element:
Luckily the styles are nicely structured inside just four files with each just a couple of hundred lines max.