Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: third_party/polymer/components-chromium/core-style/core-style.html

Issue 592593002: Inline scripts were extracted from Polymer elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/echo ""/echo/ Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.g ithub.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/CONTRI BUTORS.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/PATEN TS.txt
8 -->
9 <!--
10
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.
19
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.
23
24 Here's a basic example:
25
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>
32
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:
37
38 <core-style id="x-test">
39 :host {
40 backgound-color: steelblue;
41 }
42 </core-style>
43
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.
48
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:
51
52 <core-style id="x-test">
53 :host {
54 background-color: {{myColor}};
55 }
56 </core-style>
57 <script>
58 document._currentScript.ownerDocument.getElementById('x-test').myColor = ' orange';
59 </script>
60
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:
64
65 <core-style id="x-test">
66 :host {
67 background-color: {{g.myColor}};
68 }
69 </core-style>
70 <script>
71 CoreStyle.g.myColor = 'tomato';
72 </script>
73
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:
78
79 <core-style id="common">
80 :host {
81 font-family: sans-serif;
82 }
83 </core-style>
84
85 <core-style id="x-test">
86 {{list.common.cssText}}
87
88 :host {
89 background-color: {{g.myColor}};
90 }
91 </core-style>
92
93
94 @group Polymer Core Elements
95 @element core-style
96 @homepage github.io
97 -->
98
99 <link rel="import" href="../polymer/polymer.html">
100
101 <polymer-element name="core-style" hidden assetpath="">
102
103 </polymer-element>
104 <script src="core-style-extracted.js"></script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698