Clean up examples directory

1) Merge input example into widgets example
2) Move single-file, non-fn examples into a "raw" directory
3) Rename stocks-fn and widgets-fn to stocks and widgets

R=ojan@chromium.org

Review URL: https://codereview.chromium.org/1005393006
This commit is contained in:
Adam Barth
2015-03-26 14:32:40 -07:00
parent 52552112ff
commit 86a4ceb351
9 changed files with 1 additions and 199 deletions

View File

@@ -50,7 +50,7 @@ the hierarchy returned last frame. Any differences are then applied as mutations
to the physical heiarchy retained by the engine.
For a more featureful example, please see the
[example stocks app](examples/stocks-fn/lib/stocks_app.dart).
[example stocks app](examples/stocks/lib/stocks_app.dart).
Services
--------

View File

@@ -1,9 +1,7 @@
#!mojo mojo:sky_viewer
<div><!-- remove this element once Document can have multiple element children -->
<style>
.h1 { font-size: 2em; margin: 1em; }
.p { margin: 0.5em 1em; color: #bcd8f5; font-weight: 900; }
</style>
<div class="h1">about:blank</div>
<div class="p">Welcome to Sky!</div>
</div>

View File

@@ -1,10 +0,0 @@
#!mojo mojo:sky_viewer
<sky>
<import src="/sky/framework/debug/shake-to-reload.sky" />
<script>
import 'input_app.dart';
main() {
new InputApp();
}
</script>
</sky>

View File

@@ -1,12 +0,0 @@
// 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 'package:sky/framework/fn.dart';
import 'package:sky/framework/components/input.dart';
class InputApp extends App {
Node build() {
return new Input();
}
}

View File

@@ -1,24 +0,0 @@
<sky>
<style>
div {
height: 200px;
background-color: lightblue;
}
</style>
<div id="canvas" />
<script>
import 'dart:math' as math;
import 'dart:sky';
void main() {
var element = document.getElementById('canvas');
element.requestPaint((PaintingContext context) {
Paint paint = new Paint();
paint.setARGB(128, 0, 255, 0);
double radius = math.min(context.width, context.height) / 2.0;
context.drawCircle(context.width / 2.0, context.height / 2.0, radius, paint);
context.commit();
});
}
</script>
</sky>

View File

@@ -1,31 +0,0 @@
#!mojo mojo:sky_viewer
<sky>
<style>
square {
margin: 50px;
height: 100px;
width: 100px;
background-color: green;
}
</style>
<square />
<script>
import "dart:sky";
void main() {
Element square = document.querySelector('square');
double timeBase = null;
void animate(double time) {
if (timeBase == null)
timeBase = time;
double delta = time - timeBase;
int rotation = (delta / 10).floor();
square.style["transform"] = "rotate(${rotation}deg)";
window.requestAnimationFrame(animate);
}
window.requestAnimationFrame(animate);
}
</script>
</sky>

View File

@@ -1,65 +0,0 @@
#!mojo mojo:sky_viewer
<sky>
<import src="/sky/framework/debug/shake-to-reload.sky" />
<style>
dot {
position: absolute;
height: 10px;
width: 10px;
background-color: #00FF00;
border-radius: 5px;
opacity: .75;
}
</style>
<log>Ready!</log>
<script>
import "dart:sky";
// Material design colors. :p
List<String> colors = [
"#009688",
"#FFC107",
"#9C27B0",
"#03A9F4",
"#673AB7",
"#CDDC39",
];
Element whichDot(event) {
return document.querySelector('dot[id="${event.pointer}"]');
}
void moreDots(event) {
Element dot = document.createElement('dot');
dot.setAttribute('id', "${event.pointer}");
dot.style['background-color'] = colors[event.pointer.remainder(colors.length)];
document.querySelector('sky').appendChild(dot);
runToTheCenter(event);
}
void goAway(event) {
whichDot(event).remove();
}
void stopDots(event) {
for (Element e in document.querySelectorAll('dot'))
e.remove();
}
void runToTheCenter(event) {
double radius = (5 + (95 * event.pressure));
Element dot = whichDot(event);
dot.style["transform"] = "translate(${event.x-radius}px,${event.y-radius}px)";
dot.style["width"] = "${2 * radius}px";
dot.style["height"] = "${2 * radius}px";
dot.style["border-radius"] = "${radius}px";
}
void main() {
document.addEventListener("pointerdown", moreDots);
document.addEventListener("pointermove", runToTheCenter);
document.addEventListener("pointerup", goAway);
document.addEventListener("pointercancel", stopDots);
}
</script>
</sky>

View File

@@ -1,15 +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/debug/shake-to-reload.sky" />
<script>
import 'widgets_app.dart';
main() {
new WidgetsApp();
}
</script>
</sky>

View File

@@ -1,39 +0,0 @@
// 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 'package:sky/framework/fn.dart';
import 'package:sky/framework/components/button.dart';
import 'package:sky/framework/components/popup_menu.dart';
class WidgetsApp extends App {
static final Style _menuStyle = new Style('''
position: absolute;
top: 200px;
left: 200px;''');
Node build() {
return new Container(
children: [
new Button(key: 'Go', content: new Text('Go'), level: 1),
new Button(key: 'Back', content: new Text('Back'), level: 3),
new Container(
style: _menuStyle,
children: [
new PopupMenu(
items: [
[new Text('People & options')],
[new Text('New group conversation')],
[new Text('Turn history off')],
[new Text('Archive')],
[new Text('Delete')],
[new Text('Un-merge SMS')],
[new Text('Help & feeback')],
],
level: 4),
]
)
]
);
}
}