Port sky-scrollable to Dart

This CL ports sky-scrollable to the new sky-element.

R=esprehn@chromium.org

Review URL: https://codereview.chromium.org/950603002
This commit is contained in:
Adam Barth
2015-02-21 09:56:22 -08:00
parent 8b94fd7798
commit 0d038b1a0d
5 changed files with 50 additions and 45 deletions

View File

@@ -1,43 +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="/sky/framework/sky-scrollable.sky" />
<import src="data/cities.sky" as="cities" />
<sky-element name="example-scrollable">
<template>
<style>
sky-scrollable {
margin: 20px;
height: 400px;
border: 2px solid blue;
}
b {
display: inline;
font-weight: bold;
}
</style>
<sky-scrollable>
<template repeat="{{ cities }}">
<template>
<div>{{ name }}</div>
</template>
</template>
</sky-scrollable>
</template>
<script>
module.exports = class extends SkyElement {
created() {
this.cities = cities.slice(0, 300);
}
}.register();
</script>
</sky-element>
<example-scrollable />
</sky>

View File

@@ -0,0 +1,38 @@
<!--
// 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="/sky/framework/sky-element.sky" />
<import src="/sky/framework/sky-scrollable.sky" />
<import src="../data/cities.sky" as="cities" />
<sky-element name="example-scrollable">
<template>
<style>
sky-scrollable {
margin: 20px;
height: 400px;
border: 2px solid blue;
}
</style>
<sky-scrollable />
</template>
<script>
import "dart:sky";
@Tagname('example-scrollable')
class ExampleScrollable extends SkyElement {
void shadowRootReady() {
Element parent = shadowRoot.querySelector('sky-scrollable');
for (Map city in cities.kData.getRange(0, 300)) {
Element div = document.createElement('div');
div.setChild(new Text(city['name']));
parent.appendChild(div);
}
}
}
_init(script) => register(script, ExampleScrollable);
</script>
</sky-element>

View File

@@ -0,0 +1,10 @@
#!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="example-scrollable.sky" />
<example-scrollable />
</sky>

View File

@@ -6,7 +6,7 @@ import "../resources/unit.dart";
import "dart:sky";
class FooElement extends Element {
FooElement() : super("foo");
final String tagName = "foo";
attachedCallback() {
++attachedCallbackCount;

View File

@@ -3,7 +3,7 @@
import "dart:sky";
class FooElement extends Element {
FooElement() : super("foo");
final String tagName = "foo";
attachedCallback() {
print("PASS: FooElement attached.");