go/cmd/heapview/client/main.ts
Michael Matloob 72064bd647 cmd/heapview: dowgrade to customelements v0
I've had too many issues with customelements v1. The interface for v0
isn't as nice, and v0 will eventually be deprecated. But v1's polyfill
library is better supported, and it will be easy to upgrade later.

Change-Id: I87b376376b750167a0464c6c249930edecbd59db
Reviewed-on: https://go-review.googlesource.com/25545
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2016-08-05 20:49:36 +00:00

50 lines
1.3 KiB
TypeScript

// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/**
* A hamburger menu element.
*/
class HamburgerElement extends HTMLElement {
attachedCallback() {
this.innerHTML = '&#9776'; // Unicode character for hamburger menu.
}
}
document.registerElement('heap-hamburger', HamburgerElement);
/**
* A heading for the page with a hamburger menu and a title.
*/
export class HeadingElement extends HTMLElement {
attachedCallback() {
this.style.display = 'block';
this.style.backgroundColor = '#2196F3';
this.style.webkitUserSelect = 'none';
this.style.cursor = 'default';
this.style.color = '#FFFFFF';
this.style.padding = '10px';
this.innerHTML = `
<div style="margin:0px; font-size:2em"><heap-hamburger></heap-hamburger> Go Heap Viewer</div>
`;
}
}
document.registerElement('heap-heading', HeadingElement);
/**
* Reset body's margin and padding, and set font.
*/
function clearStyle() {
document.head.innerHTML += `
<style>
* {font-family: Roboto,Helvetica}
body {margin: 0px; padding:0px}
</style>
`;
}
export function main() {
document.title = 'Go Heap Viewer';
clearStyle();
document.body.appendChild(document.createElement("heap-heading"));
}