Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Yvonne Yip committed Sep 21, 2013
1 parent bd707c9 commit 6783c7b
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 0 deletions.
70 changes: 70 additions & 0 deletions yvonne/getting-started/components/gs-app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<link href="../../../../polymer-elements/polymer-selector/polymer-selector.html" rel="import">
<link href="../../../../polymer-ui-elements/polymer-ui-pages/polymer-ui-pages.html" rel="import">
<link href="gs-import-selector.html" rel="import">
<polymer-element name="gs-app" attributes="page imports selectedImportsIndex projectName projectPath">
<template>
<style>
polymer-ui-pages {
display: block;
}
polymer-selector .polymer-selected {
color: white;
background: black;
}
</style>
<polymer-ui-pages selected="{{page}}">
<section>
<h1>Getting Started with Polymer</h1>
<h2>What's the name of your project?</h2>
<input value="{{projectName}}">
<h2>Create at:</h2>
<input value="{{projectPath}}">/{{projectName}}
<button on-click="nextAction">Next!</button>
</section>
<section>
<gs-import-selector imports="{{imports}}"></gs-import-selector>
<button on-click="nextAction">Next!</button>
</section>
<section>
<p>
Project: {{projectName}} at {{projectPath}}/{{projectName}}
</p>
<p>
Imports:<br>
<template repeat="{{projectImports}}">
{{}}<br>
</template>
</p>
<button on-click="generateAction">Generate!</button>
</section>
</polymer-ui-pages>
</template>
<script>
Polymer('gs-app', {
page: 0,
imports: [
'polymer-ui-elements/polymer-ui-accordion/polymer-ui-accordion.html',
'polymer-ui-elements/polymer-ui-arrow/polymer-ui-arrow.html',
'polymer-ui-elements/polymer-ui-breadcrumbs/polymer-ui-breadcrumbs.html',
'polymer-ui-elements/polymer-ui-card/polymer-ui-card.html',
'polymer-ui-elements/polymer-ui-collapsible/polymer-ui-collapsible.html',
],
selectedImportsIndex: [],
projectName: '',
projectPath: '',
projectImports: [],
nextAction: function() {
this.page += 1;
if (this.selectedImportsIndex) {
this.projectImports = [];
for (var i = 0; i < this.selectedImportsIndex.length; i++) {
var idx = this.selectedImportsIndex[i];
this.projectImports.push(this.imports[idx]);
}
}
},
generateAction: function() {
}
});
</script>
</polymer-element>
47 changes: 47 additions & 0 deletions yvonne/getting-started/components/gs-import-selector.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<link href="../../../../polymer-elements/polymer-selector/polymer-selector.html" rel="import">
<polymer-element name="gs-import-selector" attributes="imports selectedIndex results">
<template>
<style>
polymer-selector .polymer-selected {
color: white;
background: black;
}
</style>
<polymer-selector selected="{{selectedIndex}}" multi on-polymer-activate="activateAction">
<template repeat="{{imports}}">
<div>{{}}</div>
</template>
</polymer-selector>
</template>
<script>
Polymer('gs-import-selector', {
imports: [],
selectedIndex: [],
results: [],
created: function() {
this.selectedIndexChanged();
},
importsChanged: function() {
this.selectedIndex = [];
this.results = [];
},
selectedIndexChanged: function(old) {
if (old) {
this.observer && this.observer.close();
}
if (this.selectedIndex) {
this.observer = new ArrayObserver(this.selectedIndex, this.selectedIndexMutated.bind(this));
}
},
selectedIndexMutated: function(records) {
var record = records[0];
if (record.addedCount) {
this.results.push(this.imports[this.selectedIndex[record.index]]);
}
for (var i = 0; i < record.removed.length; i++) {
this.results.splice(this.results.indexOf(record.removed[i]));
}
}
});
</script>
</polymer-element>
10 changes: 10 additions & 0 deletions yvonne/getting-started/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html>
<head>
<link href="components/gs-app.html" rel="import">
<script src="polymer/polymer/polymer.js"></script>
</head>
<body>
<gs-app></gs-app>
</body>
</html>
3 changes: 3 additions & 0 deletions yvonne/getting-started/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

var server = require('./lib/server');
31 changes: 31 additions & 0 deletions yvonne/getting-started/lib/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var port = 8888;
var project_dir = __dirname + '/../';
var root_dir = __dirname + '/../../../../';

var express = require('express');

var app = express();
app.use(express.bodyParser());

app.get('/', function(req, res) {
res.sendfile('index.html', {root: project_dir});
});

app.get('/components/*', function(req, res) {
res.sendfile(req.params[0], {root: project_dir + 'components/'});
});

app.get('/polymer/*', function(req, res) {
res.sendfile(req.params[0], {root: root_dir});
});

app.get('/polymer-elements/*', function(req, res) {
res.sendfile(req.params[0], {root: root_dir + 'polymer-elements/'});
});

app.get('/polymer-ui-elements/*', function(req, res) {
res.sendfile(req.params[0], {root: root_dir + 'polymer-ui-elements/'});
});

app.listen(port);
console.log('Listening on port ' + port);
8 changes: 8 additions & 0 deletions yvonne/getting-started/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "getting-started",
"description": "Polymer bootstrap app",
"version": "0.0.1",
"dependencies": {
"express": "3.x"
}
}

0 comments on commit 6783c7b

Please sign in to comment.