From c555ea659c2f4688cd105437abf03c39e08975f5 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Sat, 23 Nov 2019 12:50:47 -0330 Subject: [PATCH] Convert NetworkDropdownIcon component to JSX (#7511) Co-Authored-By: Mark Stacey --- .../components/network-dropdown-icon.js | 75 ++++++++++--------- .../tests/network-dropdown-icon.test.js | 14 ++-- 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/ui/app/components/app/dropdowns/components/network-dropdown-icon.js b/ui/app/components/app/dropdowns/components/network-dropdown-icon.js index d4a2c2ff7..de3e8496d 100644 --- a/ui/app/components/app/dropdowns/components/network-dropdown-icon.js +++ b/ui/app/components/app/dropdowns/components/network-dropdown-icon.js @@ -1,47 +1,54 @@ -const inherits = require('util').inherits -const Component = require('react').Component -const h = require('react-hyperscript') +import PropTypes from 'prop-types' +import React from 'react' - -inherits(NetworkDropdownIcon, Component) -module.exports = NetworkDropdownIcon - -function NetworkDropdownIcon () { - Component.call(this) -} - -NetworkDropdownIcon.prototype.render = function () { +function NetworkDropdownIcon (props) { const { backgroundColor, isSelected, - innerBorder = 'none', - diameter = '12', + innerBorder, + diameter, loading, - } = this.props + } = props return loading - ? h('span.pointer.network-indicator', { - style: { - display: 'flex', - alignItems: 'center', - flexDirection: 'row', - }, - }, [ - h('img', { - style: { - width: '27px', - }, - src: 'images/loading.svg', - }), - ]) - : h(`.menu-icon-circle${isSelected ? '--active' : ''}`, {}, - h('div', { - style: { + ? ( + + + + ) + : ( +
+
+
) } + +NetworkDropdownIcon.defaultProps = { + backgroundColor: undefined, + loading: false, + innerBorder: 'none', + diameter: '12', + isSelected: false, +} + +NetworkDropdownIcon.propTypes = { + backgroundColor: PropTypes.string, + loading: PropTypes.boolean, + innerBorder: PropTypes.string, + diameter: PropTypes.string, + isSelected: PropTypes.bool, +} + +module.exports = NetworkDropdownIcon diff --git a/ui/app/components/app/dropdowns/tests/network-dropdown-icon.test.js b/ui/app/components/app/dropdowns/tests/network-dropdown-icon.test.js index ed7b7e253..ce3853a63 100644 --- a/ui/app/components/app/dropdowns/tests/network-dropdown-icon.test.js +++ b/ui/app/components/app/dropdowns/tests/network-dropdown-icon.test.js @@ -7,12 +7,14 @@ describe('Network Dropdown Icon', () => { let wrapper beforeEach(() => { - wrapper = shallow() + wrapper = shallow(( + + )) }) it('adds style props based on props', () => {