mirror of
https://github.com/golang/go
synced 2024-11-19 15:24:46 -07:00
337c0124d7
This CL's purpose is to introduce the dependency on the HTML Custom Elements polyfill. Like we've done so far, I'm trying to keep dependencies light by using current or polyfilling future webcomponents standards. Change-Id: I11d14db367b697cdd527fb66b9d7d160ac244b78 Reviewed-on: https://go-review.googlesource.com/25494 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
51 lines
1.3 KiB
TypeScript
51 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 {
|
|
connectedCallback() {
|
|
this.innerHTML = '☰'; // Unicode character for hamburger menu.
|
|
}
|
|
}
|
|
window.customElements.define('heap-hamburger', HamburgerElement);
|
|
|
|
/**
|
|
* A heading for the page with a hamburger menu and a title.
|
|
*/
|
|
export class HeadingElement extends HTMLElement {
|
|
connectedCallback() {
|
|
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>
|
|
`;
|
|
}
|
|
}
|
|
window.customElements.define('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(new HeadingElement());
|
|
}
|