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

Unified Diff: sky/examples/fn/lib/style.dart

Issue 971183002: Initial commit of Effen reactive framework experiment for Sky (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/examples/fn/lib/reflect.dart ('k') | sky/examples/fn/widgets/animationgenerator.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/fn/lib/style.dart
diff --git a/sky/examples/fn/lib/style.dart b/sky/examples/fn/lib/style.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c89db5e73dda9228af18f74fe01c5b6ad2c14744
--- /dev/null
+++ b/sky/examples/fn/lib/style.dart
@@ -0,0 +1,36 @@
+part of fn;
+
+class Style {
+ final String _className;
+ static Map<String, Style> _cache = null;
+
+ static int nextStyleId = 1;
+
+ static String nextClassName(String styles) {
+ assert(sky.document != null);
+ var className = "style$nextStyleId";
+ nextStyleId++;
+
+ var styleNode = sky.document.createElement('style');
+ styleNode.setChild(new sky.Text(".$className { $styles }"));
+ sky.document.appendChild(styleNode);
+
+ return className;
+ }
+
+ factory Style(String styles) {
+ if (_cache == null) {
+ _cache = new HashMap<String, Style>();
+ }
+
+ var style = _cache[styles];
+ if (style == null) {
+ style = new Style._internal(nextClassName(styles));
+ _cache[styles] = style;
+ }
+
+ return style;
+ }
+
+ Style._internal(this._className);
+}
« no previous file with comments | « sky/examples/fn/lib/reflect.dart ('k') | sky/examples/fn/widgets/animationgenerator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698