Files
react-native-devtools-frontend/front_end/elements/NodeText.ts
T
Patrick Brosset 436d8ac8c5 Don't make NodeText a block element to apply ellipsis in Layout panel
In bug 1109177 I cleaned up the display of nodes listed in the Layout
panel by making them not wrap, and have an ellipsis when they were too
long.
This caused a visual regression in the breadcrumbs of the Elements tree.
The nodes there use the same component and they were affected by my
CSS change.
Namely, the focus outline became taller and got cropped.

In this change, I'm just reverting the change of CSS to NodeText.
Instead, I'm moving this to the layoutPane.css, so it now only applies
to nodes in the Layout pane, and not the breadcrumbs anymore.

Before: https://imgur.com/CTGA6SO.jpg
After: https://imgur.com/sFfUQLk.jpg

Bug: 1124250
Change-Id: I9433cf0187be17a0044766472236470bb1be4b79
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2389035
Commit-Queue: Patrick Brosset <patrick.brosset@microsoft.com>
Reviewed-by: Michael Liao <michael.liao@microsoft.com>
2020-09-03 17:25:07 +00:00

67 lines
1.7 KiB
TypeScript

// Copyright (c) 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.
import * as LitHtml from '../third_party/lit-html/lit-html.js';
const {render, html} = LitHtml;
export class NodeText extends HTMLElement {
private readonly shadow = this.attachShadow({mode: 'open'});
private nodeTitle: string = '';
private nodeId?: string = '';
private nodeClasses?: string[] = [];
constructor() {
super();
}
set data(data: {nodeTitle: string, nodeId?: string, nodeClasses?: string[]}) {
this.nodeTitle = data.nodeTitle;
this.nodeId = data.nodeId;
this.nodeClasses = data.nodeClasses;
this.render();
}
private render() {
const parts = [
html`<span class="node-label-name">${this.nodeTitle}</span>`,
];
if (this.nodeId) {
parts.push(html`<span class="node-label-id">#${CSS.escape(this.nodeId)}</span>`);
}
if (this.nodeClasses && this.nodeClasses.length > 0) {
const text = this.nodeClasses.map(c => `.${CSS.escape(c)}`).join('');
parts.push(html`<span class="node-label-class">${text}</span>`);
}
// Disabled until https://crbug.com/1079231 is fixed.
// clang-format off
render(html`
<style>
.node-label-name {
color: var(--dom-tag-name-color);
}
.node-label-class {
color: var(--dom-attribute-name-color);
}
</style>
${parts}
`, this.shadow, {
eventContext: this,
});
// clang-format on
}
}
customElements.define('devtools-node-text', NodeText);
declare global {
interface HTMLElementTagNameMap {
'devtools-node-text': NodeText;
}
}