SidebarFixedItem.js (1534B)
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 createFactory, 10 } = require("resource://devtools/client/shared/vendor/react.mjs"); 11 const dom = require("resource://devtools/client/shared/vendor/react-dom-factories.js"); 12 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs"); 13 14 const SidebarItem = createFactory( 15 require("resource://devtools/client/aboutdebugging/src/components/sidebar/SidebarItem.js") 16 ); 17 18 /** 19 * This component displays a fixed item in the Sidebar component. 20 */ 21 class SidebarFixedItem extends PureComponent { 22 static get propTypes() { 23 return { 24 icon: PropTypes.string.isRequired, 25 isSelected: PropTypes.bool.isRequired, 26 name: PropTypes.string.isRequired, 27 to: PropTypes.string, 28 }; 29 } 30 31 render() { 32 const { icon, isSelected, name, to } = this.props; 33 34 return SidebarItem( 35 { 36 className: "sidebar-item--tall", 37 isSelected, 38 to, 39 }, 40 dom.div( 41 { 42 className: "sidebar-fixed-item__container", 43 }, 44 dom.img({ 45 className: "sidebar-fixed-item__icon", 46 src: icon, 47 }), 48 dom.span( 49 { 50 className: "ellipsis-text", 51 title: name, 52 }, 53 name 54 ) 55 ) 56 ); 57 } 58 } 59 60 module.exports = SidebarFixedItem;