FontPreview.js (1066B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const { 8 PureComponent, 9 } = require("resource://devtools/client/shared/vendor/react.mjs"); 10 const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js"); 11 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs"); 12 13 const Types = require("resource://devtools/client/inspector/fonts/types.js"); 14 15 class FontPreview extends PureComponent { 16 static get propTypes() { 17 return { 18 onPreviewClick: PropTypes.func, 19 previewUrl: Types.font.previewUrl.isRequired, 20 }; 21 } 22 23 static get defaultProps() { 24 return { 25 onPreviewClick: () => {}, 26 }; 27 } 28 29 render() { 30 const { onPreviewClick, previewUrl } = this.props; 31 32 return dom.img({ 33 className: "font-preview", 34 onClick: onPreviewClick, 35 src: previewUrl, 36 }); 37 } 38 } 39 40 module.exports = FontPreview;