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

Unified Diff: runtime/observatory/lib/src/elements/nav/menu_item.dart

Issue 2160123002: Converted Observatory nav-menu-item element (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Converted from single to triple quotes Created 4 years, 5 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
Index: runtime/observatory/lib/src/elements/nav/menu_item.dart
diff --git a/runtime/observatory/lib/src/elements/nav/menu_item.dart b/runtime/observatory/lib/src/elements/nav/menu_item.dart
new file mode 100644
index 0000000000000000000000000000000000000000..fd89f7e6419a75c3eb0d7a460a3d64879e141b38
--- /dev/null
+++ b/runtime/observatory/lib/src/elements/nav/menu_item.dart
@@ -0,0 +1,114 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:html';
+import 'dart:async';
+import 'package:observatory/src/elements/helpers/tag.dart';
+import 'package:observatory/src/elements/helpers/rendering_scheduler.dart';
+
+class NavMenuItemElement extends HtmlElement implements Renderable {
+ static final StyleElement _style = () {
+ var style = new StyleElement();
+ style.text = '''li.nav-menu-item {
+ float: none;
+ border-top: 1px solid #677;
+ border-bottom: 1px solid #556; position: relative;
+ }
+ li.nav-menu-item:hover {
+ background: #455;
+ }
+ li.nav-menu-item > a {
+ display: block;
+ padding: 12px 12px;
+ color: white;
+ text-decoration: none;
+ }
+ li.nav-menu-item > ul {
+ display: none;
+ position: absolute;
+ top:0;
+ left: 100%;
+ list-style: none;
+ padding: 0;
+ margin-left: 0;
+ width: auto;
+ z-index: 1000;
+ font: 400 16px \'Montserrat\', sans-serif;
+ color: white;
+ background: #567;
+ }
+ li.nav-menu-item > ul:after {
+ content: ""; clear: both; display: block;
+ }
+ li.nav-menu-item:hover > ul {
+ display: block;
+ }''';
+ return style;
+ }();
+
+ static const tag = const Tag<NavMenuItemElement>('nav-menu-item-wrapped');
+
+ RenderingScheduler _r;
+
+ Stream<RenderedEvent<NavMenuItemElement>> get onRendered => _r.onRendered;
+
+ String _label;
+ String _link;
+ String get label => _label;
+ String get link => _link;
+ set label(String value) {
+ if (_label != value) {
+ _label = value;
+ _r.dirty();
+ } else {
+ _r.scheduleNotification();
+ }
+ }
+ set link(String value) {
+ if (_link != value) {
+ _link = value;
+ _r.dirty();
+ } else {
+ _r.scheduleNotification();
+ }
+ }
+
+
+ factory NavMenuItemElement(String label, {String link,
+ RenderingQueue queue}) {
+ assert(label != null);
+ NavMenuItemElement e = document.createElement(tag.name);
+ e._r = new RenderingScheduler(e, queue: queue);
+ e._label = label;
+ e._link = link;
+ return e;
+ }
+
+ NavMenuItemElement.created() : super.created() { createShadowRoot(); }
+
+ @override
+ void attached() { super.attached(); _r.enable(); }
+
+ @override
+ void detached() {
+ super.detached(); _r.disable(notify: true);
+ shadowRoot.children = [];
+ }
+
+ void render() {
+ shadowRoot.children = [
+ _style.clone(true),
+ new LIElement()
+ ..classes = ['nav-menu-item']
+ ..children = [
+ new AnchorElement(href: '#$link')
+ ..text = label,
+ new UListElement()
+ ..children = [
+ new ContentElement()
+ ]
+ ]
+ ];
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698