FontStyle.js (1715B)
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 { 14 getStr, 15 } = require("resource://devtools/client/inspector/fonts/utils/l10n.js"); 16 17 class FontStyle extends PureComponent { 18 static get propTypes() { 19 return { 20 disabled: PropTypes.bool.isRequired, 21 onChange: PropTypes.func.isRequired, 22 value: PropTypes.string.isRequired, 23 }; 24 } 25 26 constructor(props) { 27 super(props); 28 this.name = "font-style"; 29 this.onToggle = this.onToggle.bind(this); 30 } 31 32 onToggle(e) { 33 this.props.onChange( 34 this.name, 35 e.target.checked ? "italic" : "normal", 36 null 37 ); 38 } 39 40 render() { 41 return dom.label( 42 { 43 className: "font-control", 44 }, 45 dom.span( 46 { 47 className: "font-control-label", 48 }, 49 getStr("fontinspector.fontItalicLabel") 50 ), 51 dom.div( 52 { 53 className: "font-control-input", 54 }, 55 dom.input({ 56 checked: 57 this.props.value === "italic" || this.props.value === "oblique", 58 className: "devtools-checkbox-toggle", 59 disabled: this.props.disabled, 60 name: this.name, 61 onChange: this.onToggle, 62 type: "checkbox", 63 }) 64 ) 65 ); 66 } 67 } 68 69 module.exports = FontStyle;