Skip to content

Instantly share code, notes, and snippets.

@jsmanifest
Created April 2, 2020 03:17
Show Gist options
  • Save jsmanifest/e357448730a9c0ee622a1cb0b1f696c8 to your computer and use it in GitHub Desktop.
Save jsmanifest/e357448730a9c0ee622a1cb0b1f696c8 to your computer and use it in GitHub Desktop.
const DeactivatorInput = ({
component: Component = 'input',
style,
opened,
open: openModal,
close: closeModal,
...rest
}) => (
<div>
<Component
type="email"
onKeyPress={(e) => {
const pressedEnter = e.charCode === 13
if (pressedEnter) {
openModal()
}
}}
style={{
minWidth: 200,
border: '1px solid rgba(0, 0, 0, 0.5)',
borderRadius: 4,
padding: '6px 12px',
...style,
}}
placeholder="Search a user to deactivate"
{...rest}
/>
<Modal isOpen={opened}>
<h1>Modal is opened</h1>
<hr />
<button type="button" onClick={closeModal}>
Close
</button>
</Modal>
</div>
)
function App() {
return (
<ControlPanel>
<DeactivatorInput />
</ControlPanel>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment