Files
react-native-devtools-frontend/front_end/elements/ElementsPanelLink.ts
T
Jack Franklin 8064d3ba7a Lint against non-theme-color variables
This CL turns on the use_theme_colors stylelint rule which enforces that
any colors use variables defined in our codebase.

There are many, many violations, unsurprisingly (about 1500), so for now
I have disabled every single violation. The goal of the dark mode
migration will be in part to remove all violations of this rule.

Additionally, new code going forwards should adhere to the rule and not
add the comment to disable the warning.

Bug: 1152736
Change-Id: I51372724ea51485daef3d4f75b7d3f60a7c8016f
No-Presubmit: true
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2671323
Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
Reviewed-by: Paul Lewis <aerotwist@chromium.org>
2021-02-03 11:02:09 +00:00

62 lines
2.1 KiB
TypeScript

// 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.
import * as LitHtml from '../third_party/lit-html/lit-html.js';
export interface ElementsPanelLinkData {
onElementRevealIconClick: (event?: Event) => void;
onElementRevealIconMouseEnter: (event?: Event) => void;
onElementRevealIconMouseLeave: (event?: Event) => void;
}
export class ElementsPanelLink extends HTMLElement {
private readonly shadow = this.attachShadow({mode: 'open'});
private onElementRevealIconClick: ((event?: Event) => void) = () => {};
private onElementRevealIconMouseEnter: ((event?: Event) => void) = () => {};
private onElementRevealIconMouseLeave: ((event?: Event) => void) = () => {};
set data(data: ElementsPanelLinkData) {
this.onElementRevealIconClick = data.onElementRevealIconClick;
this.onElementRevealIconMouseEnter = data.onElementRevealIconMouseEnter;
this.onElementRevealIconMouseLeave = data.onElementRevealIconMouseLeave;
this.update();
}
private update(): void {
this.render();
}
private render(): void {
// clang-format off
LitHtml.render(LitHtml.html`
<style>
.element-reveal-icon {
display: inline-block;
width: 28px;
height: 24px;
-webkit-mask-position: -140px 96px;
-webkit-mask-image: url(Images/largeIcons.svg);
background-color: rgb(110 110 110); /* stylelint-disable-line plugin/use_theme_colors */
/* See: crbug.com/1152736 for color variable migration. */
}
</style>
<span
class="element-reveal-icon"
@click=${this.onElementRevealIconClick}
@mouseenter=${this.onElementRevealIconMouseEnter}
@mouseleave=${this.onElementRevealIconMouseLeave}></span>
`, this.shadow);
// clang-format on
}
}
customElements.define('devtools-elements-panel-link', ElementsPanelLink);
declare global {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface HTMLElementTagNameMap {
'devtools-elements-panel-link': ElementsPanelLink;
}
}