Files
react-native-devtools-frontend/front_end/component_docs/elements_breadcrumbs/basic.html
T
Jack Franklin 1e53cb87ed Load runtime stylesheets in to the components server
Change-Id: I0f24656ae941f0ade4a3fd40d024a2420142e068
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2354090
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Alex Rudenko <alexrudenko@chromium.org>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
2020-08-20 11:39:24 +00:00

112 lines
3.1 KiB
HTML

<!--
Copyright 2020 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>Basic Breadcrumbs example</title>
<style>
#container {
width: 80%;
border: 1px solid black;
}
.fake-crumb-element {
width: 300px;
height: 20px;
background: red;
margin-bottom: 10px;
padding: 2px;
color: white;
font-size: 20px;
text-align: center;
}
.fake-crumb-element.highlight {
background: blue;
}
</style>
</head>
<body>
<div class="fake-crumb-element" data-fake-crumb-1>body</div>
<div class="fake-crumb-element" data-fake-crumb-2>div#test-id</div>
<div id="container">
</div>
<script type="module">
import * as ComponentHelpers from '../../component_helpers/component_helpers.js';
import {ElementsBreadcrumbs} from '../../elements/ElementsBreadcrumbs.js';
ComponentHelpers.ComponentServerSetup.setup().then(() => renderComponent())
const renderComponent = () => {
let id = 0;
const makeCrumb = (overrides = {}) => {
const attributes = overrides.attributes || {};
const newCrumb = {
nodeType: Node.ELEMENT_NODE,
id: id++,
pseudoType: '',
shadowRootType: '',
nodeName: 'body',
nodeNameNicelyCased: 'body',
legacyDomNode: {},
highlightNode: () => {},
clearHighlight: () => {},
getAttribute: x => attributes[x] || '',
...overrides,
};
return newCrumb;
};
const component = new ElementsBreadcrumbs();
const bodyCrumb = makeCrumb({
nodeType: Node.ELEMENT_NODE,
id: 2,
nodeName: 'body',
nodeNameNicelyCased: 'body',
highlightNode: () => {
document.querySelector("[data-fake-crumb-1]").classList.add('highlight')
},
clearHighlight: () => {
document.querySelector("[data-fake-crumb-1]").classList.remove('highlight')
}
});
const divCrumb = makeCrumb({
nodeType: Node.ELEMENT_NODE,
id: 3,
nodeName: 'div',
nodeNameNicelyCased: 'div',
attributes: {
id: 'test-id',
},
highlightNode: () => {
document.querySelector("[data-fake-crumb-2]").classList.add('highlight')
},
clearHighlight: () => {
document.querySelector("[data-fake-crumb-2]").classList.remove('highlight')
}
});
document.getElementById('container').appendChild(component);
component.data = {
crumbs: [divCrumb, bodyCrumb],
selectedNode: bodyCrumb,
};
component.addEventListener('node-selected', node => {
console.log('node selected', node);
});
}
</script>
</body>
</html>