Migrate tf_color_scale to use webfiles build rules.

Change: 146858476
This commit is contained in:
Dandelion Mané 2017-02-07 17:39:24 -08:00 committed by TensorFlower Gardener
parent 50e03a2676
commit 8418879238
4 changed files with 184 additions and 0 deletions

View File

@ -0,0 +1,63 @@
package(default_visibility = ["//tensorflow:internal"])
load("@io_bazel_rules_closure//closure:defs.bzl", "webfiles")
load("//tensorflow/tensorboard:defs.bzl", "tensorboard_ts_library")
load("//tensorflow/tensorboard:defs.bzl", "tensorboard_typescript_genrule")
load("//tensorflow/tensorboard:defs.bzl", "tensorboard_webcomponent_library")
licenses(["notice"]) # Apache 2.0
# TODO(dandelion): Add webfiles support for the test code.
webfiles(
name = "tf_color_scale",
srcs = [
"tf-color-scale.html",
":ts",
],
path = "/tf-color-scale",
deps = [
"//tensorflow/tensorboard/components/tf_imports:d3",
"@org_polymer",
],
)
tensorboard_typescript_genrule(
name = "ts",
srcs = [
"colorScale.ts",
"palettes.ts",
],
typings = ["@org_definitelytyped//:d3.d.ts"],
)
filegroup(
name = "all_files",
srcs = glob(["**"]),
tags = ["notsan"],
)
################################################################################
# MARKED FOR DELETION
tensorboard_webcomponent_library(
name = "legacy",
srcs = [
"tf-color-scale.html",
":legacy_ts",
],
destdir = "tf-color-scale",
deps = [
"//tensorflow/tensorboard/components:tf_imports",
"//third_party/javascript/polymer/v1/polymer:lib",
],
)
tensorboard_ts_library(
name = "legacy_ts",
srcs = [
"colorScale.ts",
"palettes.ts",
],
deps = ["//tensorflow/tensorboard/components:common_deps"],
)

View File

@ -0,0 +1,26 @@
package(default_visibility = ["//tensorflow:internal"])
load("@io_bazel_rules_closure//closure:defs.bzl", "webfiles")
licenses(["notice"]) # Apache 2.0
# bazel run //third_party/tensorflow/tensorboard/components/tf_color_scale/demo
webfiles(
name = "demo",
srcs = ["index.html"],
path = "/tf-color-scale/demo",
deps = [
"//tensorflow/tensorboard/components/tf_color_scale",
"//tensorflow/tensorboard/components/tf_imports:d3",
"@org_polymer_iron_demo_helpers",
"@org_polymer_paper_button",
"@org_polymer_paper_styles",
"@org_polymer_webcomponentsjs",
],
)
filegroup(
name = "all_files",
srcs = glob(["**"]),
tags = ["notsan"],
)

View File

@ -0,0 +1,94 @@
<!doctype html>
<!--
@license
Copyright 2016 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>tf-color-scale demo</title>
<script src="../../webcomponentsjs/webcomponents-lite.min.js"></script>
<link rel="import" href="../tf-color-scale.html">
<link rel="import" href="../../iron-demo-helpers/demo-snippet.html">
<link rel="import" href="../../paper-styles/typography.html">
<link rel="import" href="../../paper-button/paper-button.html">
<link rel="import" href="../../tf-imports/d3.html">
<style> body {font-family: "Roboto";}</style>
<demo-snippet>
<template>
<dom-module id="color-scale-demo">
<template>
<paper-button raised id="button" on-tap="change">Change Runs</paper-button>
<tf-color-scale runs="[[runs]]" out-color-scale="{{scale}}"></tf-color-scale>
<div class="container">
<template is="dom-repeat" items="[[runs]]">
<div class="row">
<div class="circle" style$=[[_makeStyle(item)]]></div>
<span>[[item]]</span>
</div>
</template>
</div>
<style>
.circle {
width: 20px;
height: 20px;
border-radius: 10px;
display: inline-block;
}
.row {
height: 35px;
width: 200px;
display: inline-block;
}
.container {
height: 200px;
}
#button {
margin: 20px;
}
</style>
</template>
<script>
let fellowship = ["aragorn", "legolas", "gimli", "frodo",
"gandalf", "boromir", "merry", "pippin", "sam"];
let gems = ["garnet", "amethyst", "pearl", "and steven!"];
let numbers = d3.range(30).map(function(x) {return x.toString();});
let examples = [numbers, fellowship, gems];
Polymer({
is: "color-scale-demo",
properties: {
runs: {
type: Array,
value: examples[0],
},
i: {
type: Number,
value: 0,
},
},
_makeStyle: function(item) {
return "background-color: " + this.scale.scale(item);
},
change: function() {
this.i = (this.i + 1) % 3;
this.runs = examples[this.i];
},
});
</script>
</dom-module>
<color-scale-demo id="demo"></color-scale-demo>
</template>
</demo-snippet>

View File

@ -16,6 +16,7 @@ limitations under the License.
-->
<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../tf-imports/d3.html">
<!--
tf-color-scale is a plumbing component that takes in an array of runs, and produces