Files
firefox/devtools/client/framework/components/toolbox-tab.js
T
Julian Descottes d3239a75b1 Bug 1399886 - remove unnecessary invertable CSS classes on devtools icons;r=gl
Using fill instead of filter we don't need to define each icon as
invertable or not. If the icon is a SVG and supports fill="context-fill"
then it will be inverted/highlighted etc... as expected.

If not then it won't be impacted by DevTools themes.

MozReview-Commit-ID: CLFprKMuCt9
2017-10-04 21:13:48 +02:00

65 lines
1.6 KiB
JavaScript

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const {DOM, createClass} = require("devtools/client/shared/vendor/react");
const {img, button, span} = DOM;
module.exports = createClass({
displayName: "ToolboxTab",
renderIcon(definition, isHighlighted) {
const {icon} = definition;
if (!icon) {
return [];
}
return [
img({
src: icon
}),
];
},
render() {
const {panelDefinition, currentToolId, highlightedTool, selectTool,
focusedButton, focusButton} = this.props;
const {id, tooltip, label, iconOnly} = panelDefinition;
const isHighlighted = id === currentToolId;
const className = [
"devtools-tab",
currentToolId === id ? "selected" : "",
highlightedTool === id ? "highlighted" : "",
iconOnly ? "devtools-tab-icon-only" : ""
].join(" ");
return button(
{
className,
id: `toolbox-tab-${id}`,
"data-id": id,
title: tooltip,
type: "button",
tabIndex: focusedButton === id ? "0" : "-1",
onFocus: () => focusButton(id),
onMouseDown: () => selectTool(id),
},
span(
{
className: "devtools-tab-line"
}
),
...this.renderIcon(panelDefinition, isHighlighted),
iconOnly ?
null :
span(
{
className: "devtools-tab-label"
},
label
)
);
}
});