fune/devtools/client/inspector/fonts/components/FontsApp.js
Gabriel Luong c50ffac88e Bug 1411160 - Adds an initial react/redux template for loading a Changes View in the inspector sidebar. r=pbro
--HG--
rename : devtools/client/inspector/fonts/components/App.js => devtools/client/inspector/fonts/components/FontsApp.js
rename : devtools/client/inspector/layout/components/App.js => devtools/client/inspector/layout/components/LayoutApp.js
2017-10-26 11:32:46 -04:00

77 lines
1.9 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 {
createFactory,
DOM: dom,
PropTypes,
PureComponent,
} = require("devtools/client/shared/vendor/react");
const { connect } = require("devtools/client/shared/vendor/react-redux");
const SearchBox = createFactory(require("devtools/client/shared/components/SearchBox"));
const FontList = createFactory(require("./FontList"));
const { getStr } = require("../utils/l10n");
const Types = require("../types");
const PREVIEW_UPDATE_DELAY = 150;
class FontsApp extends PureComponent {
static get propTypes() {
return {
fonts: PropTypes.arrayOf(PropTypes.shape(Types.font)).isRequired,
onPreviewFonts: PropTypes.func.isRequired,
onShowAllFont: PropTypes.func.isRequired,
};
}
render() {
let {
fonts,
onPreviewFonts,
onShowAllFont,
} = this.props;
return dom.div(
{
className: "theme-sidebar inspector-tabpanel",
id: "sidebar-panel-fontinspector"
},
dom.div(
{
className: "devtools-toolbar"
},
SearchBox({
delay: PREVIEW_UPDATE_DELAY,
placeholder: getStr("fontinspector.previewText"),
type: "text",
onChange: onPreviewFonts,
}),
dom.label(
{
id: "font-showall",
className: "theme-link",
title: getStr("fontinspector.seeAll.tooltip"),
onClick: onShowAllFont,
},
getStr("fontinspector.seeAll")
)
),
fonts.length ?
FontList({ fonts })
:
dom.div(
{
className: "devtools-sidepanel-no-result"
},
getStr("fontinspector.noFontsOnSelectedElement")
)
);
}
}
module.exports = connect(state => state)(FontsApp);