Skip to content

Commit

Permalink
Add tree visualizer
Browse files Browse the repository at this point in the history
  • Loading branch information
romannurik committed Sep 9, 2015
1 parent 59effb8 commit d3691d2
Show file tree
Hide file tree
Showing 7 changed files with 689 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples.html
Expand Up @@ -17,6 +17,7 @@
-->
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link href="//fonts.googleapis.com/css?family=Roboto|Roboto+Mono" rel="stylesheet">
<script src="layervis.js"></script>
<link href="layervis.css" rel="stylesheet">
<script src="keyboardhelper.js"></script>
Expand Down
3 changes: 2 additions & 1 deletion template.html
Expand Up @@ -2,6 +2,7 @@
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link href="//fonts.googleapis.com/css?family=Roboto|Roboto+Mono" rel="stylesheet">
<script src="layervis.js"></script>
<link href="layervis.css" rel="stylesheet">
</head>
Expand All @@ -11,7 +12,7 @@
<div class="layervis">
<div class="layervis-root framelayout" style="width: 360px; height: 640px; background-color: #e5e5e5">

<div class="nolayer">
<div class="nolayer" style="margin-left: 16px; margin-top: 72px">
Hi there!
</div>

Expand Down
219 changes: 219 additions & 0 deletions treevis/example1.html
@@ -0,0 +1,219 @@
<!doctype html>
<html>
<!--
Copyright 2015 Google Inc.
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.
-->
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link href="//fonts.googleapis.com/css?family=Roboto|Roboto+Mono" rel="stylesheet">
<script src="treevis.js"></script>
<link href="treevis.css" rel="stylesheet">
</head>
<body>

<div class="treevis example-cards">
<div class="treevis-root framelayout">

<div class="cardlist scrollable nolayer linearlayout vertical">
<div class="card card-1" data-elevation="2">
<span class="card-image" style="background-color: #00BCD4"></span>
<span class="card-title">Bacon</span>
<span class="card-desc">Bacon ipsum dolor amet pork belly meatball kevin spare ribs. Frankfurter swine corned beef meatloaf, strip steak.</span>
</div>
<div class="card card-2" style="position: relative;" data-elevation="2">
<span class="card-image" style="background-color: #FFC107"></span>
<span class="card-title">Ribs</span>
<span class="card-desc">Bacon ipsum dolor amet pork belly meatball kevin spare ribs. Frankfurter swine corned beef meatloaf, strip steak.</span>
</div>
<div class="card card-3" style="position: relative;" data-elevation="2">
<span class="card-image" style="background-color: #00BCD4"></span>
<span class="card-title">Ribs</span>
<span class="card-desc">Bacon ipsum dolor amet pork belly meatball kevin spare ribs. Frankfurter swine corned beef meatloaf, strip steak.</span>
</div>
</div>

<div class="appbar" data-elevation="4">
<svg style="left: 16px;" width="24" height="24" viewBox="0 0 24 24"><path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/></svg>
<span class="title">Screen Title</span>
<svg style="right: 16px;" width="8" height="24" viewBox="8 0 8 24"><path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/></svg>
</div>

<div class="fab" data-elevation="4">
<svg width="24" height="24" viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>
</div>

</div>
</div>

<div class="xmltree">
CoordinatorLayout %.treevis-root
AppBarLayout %.appbar
Toolbar app:layout_scrollFlags=scroll|enterAlways layout_height=?actionBarSize %.appbar
RecyclerView app:layout_behavior=@string/appbar_scrolling_view_behavior %.cardlist
CardView %.card-1
CardView %.card-2
...
FloatingActionButton layout_gravity=bottom|right %.fab
</div>

<script>

var lastScrollTop = 0;
$('.cardlist').on('scroll', function() {
var scrollTop = $(this).scrollTop();
var deltaTop = scrollTop - lastScrollTop;
var appbarTop = $('.appbar').position().top;
console.log(appbarTop);
$('.appbar').css({top:Math.min(0,Math.max(appbarTop - deltaTop, -$('.appbar').height() - 8))});
lastScrollTop = scrollTop;
});

</script>

<style>

/* general */

html, body {
margin: 0;
padding: 0;
overflow: hidden;
width: 100%;
height: 100%;
}

body {
display: flex;
flex-direction: row;
}

.treevis {
flex: 1 0 0;
background: #f7f7f7;
font-family: Roboto;
}

.xmltree {
background: #fff;
flex: 1 0 0;
}

.treevis-root {
background-color: #e5e5e5;
width: 360px;
height: 640px;
}

.fab {
right: 16px;
bottom: 16px;
width: 56px;
height: 56px;
border-radius: 50%;
}

.fab svg {
position: absolute;
width: 24px;
height: 24px;
left: 50%;
top: 50%;
margin-left: -12px;
margin-top: -12px;
}

.cardlist {
height: 100%;
box-sizing: border-box;
padding-top: 56px;
padding-bottom: 88px;
overflow: scroll;
}

.card {
background: #fff;
border-radius: 2px;
overflow: hidden;
}

/* cards example */

.example-cards .appbar {
background-color: #3f51b5;
width: 100%;
height: 56px
}

.example-cards .card {
margin: 8px;
}

.example-cards .card + .card {
margin-top: 0;
}

.example-cards .card-image,
.example-cards .card-title,
.example-cards .card-desc {
display: block;
}

.example-cards .card-image {
height: 164px;
background-size: cover;
}

.example-cards .card-title {
margin: 16px;
font-size: 20px;
font-weight: 500;
color: #000;
}

.example-cards .card-desc {
margin: -8px 16px 16px 16px;
font-size: 14px;
color: #888;
line-height: 18px;
}

.example-cards .appbar {
fill: white;
color: #fff;
}

.example-cards .appbar svg {
position: absolute;
height: 24px;
top: 16px;
}

.example-cards .appbar .title {
position: absolute;
left: 72px;
line-height: 56px;
font-size: 20px;
font-weight: 500;
}

.example-cards .fab {
background-color: #ff4081;
fill: white;
}

</style>

</body>
</html>
76 changes: 76 additions & 0 deletions treevis/template.html
@@ -0,0 +1,76 @@
<!doctype html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<link href="//fonts.googleapis.com/css?family=Roboto|Roboto+Mono" rel="stylesheet">
<script src="treevis.js"></script>
<link href="treevis.css" rel="stylesheet">
</head>
<body>

<div class="treevis">
<div class="treevis-root framelayout" style="width: 360px; height: 640px; background-color: #e5e5e5">

<div class="textview" style="box-sizing: border-box; padding-left: 16px; padding-top: 16px; position: absolute; top: 56px; left: 0; right: 0; bottom: 0;">
Hi there!
</div>

<div class="appbar" style="width: 100%; height: 56px; background-color: #3f51b5; fill: white; color: #fff" data-elevation="4">

<svg style="position: absolute; height: 24px; top: 16px; left: 16px;" width="24" height="24" viewBox="0 0 24 24">
<path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z">
</svg>

<span class="title" style="position: absolute; left: 72px; line-height: 56px; font-size: 20px; font-weight: 500;">Screen Title</span>

</div>

<div class="fab" data-elevation="4" style="right: 16px; bottom: 16px; width: 56px; height: 56px; border-radius: 50%; background-color: #ff4081; fill: white;">

<svg style="position: absolute; width: 24px; height: 24px; left: 50%; top: 50%; margin-left: -12px; margin-top: -12px;" width="24" height="24" viewBox="0 0 24 24">
<path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z">
</svg>

</div>

</div>
</div>

<div class="xmltree">
FrameLayout %.treevis-root
LinearLayout orientation=vertical %.treevis-root
Toolbar layout_height=?actionBarSize %.appbar
TextView layout_weight=1 %.textview
FloatingActionButton layout_gravity=bottom|right %.fab
</div>

<style>

html, body {
margin: 0;
padding: 0;
overflow: hidden;
width: 100%;
height: 100%;
}

body {
display: flex;
flex-direction: row;
}

.treevis {
flex: 1 0 0;
background: #f7f7f7;
font-family: Roboto;
}

.xmltree {
background: #fff;
flex: 1 0 0;
}

</style>

</body>
</html>
Binary file added treevis/treevis-example.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d3691d2

Please sign in to comment.