Port sky-drawer to Dart

Also, port the "appish" example to exercise the drawer.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/942413002
This commit is contained in:
Adam Barth 2015-02-23 08:30:58 -08:00
parent eb117c7326
commit 973cf80fb9
3 changed files with 29 additions and 38 deletions

View File

@ -1,26 +0,0 @@
#!mojo mojo:sky_viewer
<!--
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-->
<sky>
<import src="/sky/framework/sky-element/sky-element.sky" as="SkyElement" />
<import src="example-scaffold.sky" />
<sky-element name="example-app">
<template>
<example-scaffold>
<div class="title">Awesome app</div>
<div class="menu">This is a menu</div>
<div class="body">This is an awesome app.</div>
</example-scrollable>
</template>
<script>
module.exports = class extends SkyElement {
}.register();
</script>
</sky-element>
<example-app />
</sky>

View File

@ -4,10 +4,10 @@
// found in the LICENSE file. // found in the LICENSE file.
--> -->
<import src="/sky/framework/sky-drawer.sky" /> <import src="/sky/framework/sky-drawer.sky" />
<import src="/sky/framework/sky-element/sky-element.sky" as="SkyElement" /> <import src="/sky/framework/sky-element.sky" />
<import src="/sky/framework/sky-scrollable.sky" /> <import src="/sky/framework/sky-scrollable.sky" />
<sky-element name="example-scaffold"> <sky-element>
<template> <template>
<style> <style>
:host { :host {
@ -54,7 +54,7 @@
<content select=".menu"/> <content select=".menu"/>
</sky-drawer> </sky-drawer>
<sky-toolbar> <sky-toolbar>
<div id="menu" on-click="handleMenuClick"/> <div id="menu" />
<content id="title" select=".title"/> <content id="title" select=".title"/>
</sky-toolbar> </sky-toolbar>
<sky-scrollable> <sky-scrollable>
@ -62,18 +62,23 @@
</sky-scrollable> </sky-scrollable>
</template> </template>
<script> <script>
module.exports = class extends SkyElement { import "dart:sky";
created() {
this.toolbar_ = null; @Tagname('example-scaffold')
class ExampleScaffold extends SkyElement {
Element _drawer;
void shadowRootReady() {
_drawer = shadowRoot.getElementById('drawer');
Element menu = shadowRoot.getElementById('menu');
menu.addEventListener('click', _handleMenuClick);
} }
shadowRootReady() { void _handleMenuClick(_) {
this.toolbar_ = this.shadowRoot.getElementById('drawer'); _drawer.toggle();
} }
}
handleMenuClick() { _init(script) => register(script, ExampleScaffold);
this.toolbar_.toggle();
}
}.register();
</script> </script>
</sky-element> </sky-element>

12
examples/appish/index.sky Normal file
View File

@ -0,0 +1,12 @@
#!mojo mojo:sky_viewer
<!--
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-->
<import src="example-scaffold.sky" />
<example-scaffold>
<div class="title">Awesome app</div>
<div class="menu">This is a menu</div>
<div class="body">This is an awesome app.</div>
</example-scrollable>