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 'position: fixed;' |
| 15 'top: -56px;' |
| 16 'width: 100%;' |
| 17 'z-index: 1000;' |
| 18 '}' |
| 19 'nav.nav-bar > ul {' |
| 20 'display: inline-table;' |
| 21 'position: relative;' |
| 22 'list-style: none;' |
| 23 'padding-left: 0;' |
| 24 'margin-left: 0;' |
| 25 'width: 100%;' |
| 26 'z-index: 1000;' |
| 27 'font: 400 16px \'Montserrat\', sans-serif;' |
| 28 'color: white;' |
| 29 'background-color: #0489c3;' |
| 30 '}' |
| 31 'nav.nav-bar:after {' |
| 32 'content: ""; clear: both; display: block;' |
| 33 '}' |
| 34 'nav.nav-bar:before {' |
| 35 'height: 40px;' |
| 36 'background-color: #0489c3;' |
| 37 'content: ""; display: block;' |
| 38 '}'; |
| 39 return style; |
| 40 }(); |
| 41 |
| 42 static const tag = const Tag<NavBarElement>('nav-bar'); |
| 43 |
| 44 RenderingScheduler _r; |
| 45 |
| 46 Stream<RenderedEvent<NavBarElement>> get onRendered => _r.onRendered; |
| 47 |
| 48 factory NavBarElement({RenderingQueue queue}) { |
| 49 NavBarElement e = document.createElement(tag.name); |
| 50 e._r = new RenderingScheduler(e, queue: queue); |
| 51 return e; |
| 52 } |
| 53 |
| 54 NavBarElement.created() : super.created() { |
| 55 // TODO(cbernaschina) remove when no more needed. |
| 56 _r = new RenderingScheduler(this); |
| 57 createShadowRoot(); |
| 58 } |
| 59 |
| 60 @override |
| 61 void attached() { super.attached(); _r.enable(); } |
| 62 |
| 63 @override |
| 64 void detached() { |
| 65 super.detached(); _r.disable(notify: true); |
| 66 shadowRoot.children = []; |
| 67 } |
| 68 |
| 69 void render() { |
| 70 shadowRoot.children = [ |
| 71 _style.clone(true), |
| 72 document.createElement('nav') |
| 73 ..classes = ['nav-bar'] |
| 74 ..children = [ |
| 75 new UListElement() |
| 76 ..children = [ |
| 77 new ContentElement() |
| 78 ], |
| 79 ], |
| 80 new DivElement() |
| 81 ]; |
| 82 } |
| 83 } |
OLD | NEW |