index.js (524B)
1 import { h, Component } from 'preact'; 2 import './style.css'; 3 4 const handleAction = (action, e) => { 5 if (e.key === 'Enter' || e.key === ' ') { 6 e.stopPropagation(); 7 action(); 8 return false; 9 } 10 } 11 12 export default props => ( 13 <button 14 tabindex="0" 15 disabled={props.disabled} 16 class={`circle-button circle${props.active ? ' active' : ''}`} 17 onClick={props.action} 18 onKeyDown={handleAction.bind(null, props.action)} 19 > 20 {props.children} 21 </button> 22 )