Screenshot

API
NOTE: this component is not fully implemented yet - only info and share are available atm.
The following attributes are available and can be modified at runtime:
- icon - one of: [close, lineChart, barChart, dotPlot, star, share, info, download]. no default, is mandatory.
- background - on which kind of background the button is used. one of: [light, dark]. default is light.
- state - tristate, one of [true,false,disabled]. default is true.
- size - the width and height. default is 40.
Note that the temporary state when mouse is being clicked but not yet released, is not considered.
Events:
- action - keyborad-Enter and mouse-click are captured, prevented and instead one event "action" is dispatched.
Details
There are 96 possibilities (8 * 2 * 3 * 2), 24 for each icon to consider. In order to reduce this complexity, the implementation of this component makes a few assumptions while staying open to overruling assumptions for any specific combination.
The assumptions are:
- focus: border; white on light bg or black on dark bg
- depends only on background, nothing else
- mouse hover: swap colors on dark bg (square), lighter color on light bg
- exception for close icon on light bg: white X, blue circle, not square
- state: TODO. this also includes the behaviour - i.e. within a button-group, only buttons w/ state false/off can be focussed.
Usage with WebPack
package.json
"dependencies": {
"@ewc-lib/ewc-icon-button": "latest"
},
webpack.config.js
index.html
<body>
<script src="bundle.js"></script>
<div style="display:flex; gap:3px; margin-bottom: 5px;">
<ewc-icon-button icon="info"></ewc-icon-button>
<ewc-icon-button icon="share"></ewc-icon-button>
</div>
<div style="display:flex; gap:3px; padding:2px; align-items: center; background-color: var(--c-p-140);">
<ewc-icon-button background="dark" icon="info"></ewc-icon-button>
<ewc-icon-button background="dark" icon="share"></ewc-icon-button>
</div>
</body>
main.js
import "@ewc-lib/ewc-icon-button"