OLD | NEW |
| (Empty) |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 import 'dart:html'; | |
6 import 'dart:async'; | |
7 import 'package:observatory/src/elements/helpers/tag.dart'; | |
8 import 'package:observatory/src/elements/helpers/rendering_scheduler.dart'; | |
9 | |
10 class NavBarElement extends HtmlElement implements Renderable { | |
11 static final StyleElement _style = () { | |
12 var style = new StyleElement(); | |
13 style.text = 'nav.nav-bar {' | |
14 'line-height: normal;' | |
15 'position: fixed;' | |
16 'top: 0;' | |
17 'width: 100%;' | |
18 'z-index: 1000;' | |
19 '}' | |
20 'nav.nav-bar > ul {' | |
21 'display: inline-table;' | |
22 'position: relative;' | |
23 'list-style: none;' | |
24 'padding-left: 0;' | |
25 'margin: 0;' | |
26 'width: 100%;' | |
27 'z-index: 1000;' | |
28 'font: 400 16px \'Montserrat\', sans-serif;' | |
29 'color: white;' | |
30 'background-color: #0489c3;' | |
31 '}'; | |
32 return style; | |
33 }(); | |
34 | |
35 static const tag = const Tag<NavBarElement>('nav-bar'); | |
36 | |
37 RenderingScheduler _r; | |
38 | |
39 Stream<RenderedEvent<NavBarElement>> get onRendered => _r.onRendered; | |
40 | |
41 factory NavBarElement({RenderingQueue queue}) { | |
42 NavBarElement e = document.createElement(tag.name); | |
43 e._r = new RenderingScheduler(e, queue: queue); | |
44 return e; | |
45 } | |
46 | |
47 NavBarElement.created() : super.created() { | |
48 // TODO(cbernaschina) remove when no more needed. | |
49 _r = new RenderingScheduler(this); | |
50 createShadowRoot(); | |
51 } | |
52 | |
53 @override | |
54 void attached() { super.attached(); _r.enable(); } | |
55 | |
56 @override | |
57 void detached() { | |
58 super.detached(); _r.disable(notify: true); | |
59 shadowRoot.children = []; | |
60 } | |
61 | |
62 void render() { | |
63 shadowRoot.children = [ | |
64 _style.clone(true), | |
65 document.createElement('nav') | |
66 ..classes = ['nav-bar'] | |
67 ..children = [ | |
68 new UListElement() | |
69 ..children = [ | |
70 new ContentElement() | |
71 ], | |
72 ], | |
73 new DivElement() | |
74 ]; | |
75 } | |
76 } | |
OLD | NEW |