MacViews: Get c/b/ui/views/tabs to build on Mac
[chromium-blink-merge.git] / third_party / polymer / components-chromium / core-style / core-style.html
blobcb893b321185f4ca64479ccdcadae4977c0918e2
1 <!--
2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
3 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
5 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
6 Code distributed by Google as part of the polymer project is also
7 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
8 -->
9 <!--
11 The `core-style` element helps manage styling inside other elements and can
12 be used to make themes. The `core-style` element can be either a producer
13 or consumer of styling. If it has its `id` property set, it's a producer.
14 Elements that are producers should include css styling as their text content.
15 If a `core-style` has its `ref` property set, it's a consumer. A `core-style`
16 typically sets its `ref` property to the value of the `id` property of the
17 `core-style` it wants to use. This allows a single producer to be used in
18 multiple places, for example, in many different elements.
20 It's common to place `core-style` producer elements inside HTMLImports.
21 Remote stylesheets should be included this way, the &#64;import css mechanism is
22 not currently supported.
24 Here's a basic example:
26 <polymer-element name="x-test" noscript>
27 <template>
28 <core-style ref="x-test"></core-style>
29 <content></content>
30 </template>
31 </polymer-element>
33 The `x-test` element above will be styled by any `core-style` elements that have
34 `id` set to `x-test`. These `core-style` producers are separate from the element
35 definition, allowing a user of the element to style it independent of the author's
36 styling. For example:
38 <core-style id="x-test">
39 :host {
40 backgound-color: steelblue;
42 </core-style>
44 The content of the `x-test` `core-style` producer gets included inside the
45 shadowRoot of the `x-test` element. If the content of the `x-test` producer
46 `core-style` changes, all consumers of it are automatically kept in sync. This
47 allows updating styling on the fly.
49 The `core-style` element also supports bindings and it is the producer
50 `core-style` element is the model for its content. Here's an example:
52 <core-style id="x-test">
53 :host {
54 background-color: {{myColor}};
56 </core-style>
57 <script>
58 document._currentScript.ownerDocument.getElementById('x-test').myColor = 'orange';
59 </script>
61 Finally, to facilitate sharing data between `core-style` elements, all
62 `core-style` elements have a `g` property which is set to the global
63 `CoreStyle.g`. Here's an example:
65 <core-style id="x-test">
66 :host {
67 background-color: {{g.myColor}};
69 </core-style>
70 <script>
71 CoreStyle.g.myColor = 'tomato';
72 </script>
74 Finally, one `core-style` can be nested inside another. The `core-style`
75 element has a `list` property which is a map of all the `core-style` producers.
76 A `core-style` producer's content is available via its `cssText` property.
77 Putting this together:
79 <core-style id="common">
80 :host {
81 font-family: sans-serif;
83 </core-style>
85 <core-style id="x-test">
86 {{list.common.cssText}}
88 :host {
89 background-color: {{g.myColor}};
91 </core-style>
94 @group Polymer Core Elements
95 @element core-style
96 @homepage github.io
97 -->
99 <link rel="import" href="../polymer/polymer.html">
101 <polymer-element name="core-style" hidden assetpath="">
103 </polymer-element>
104 <script src="core-style-extracted.js"></script>