a-simple-switch
Advanced tools
Comparing version
{ | ||
"name": "a-simple-switch", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Vanilla JS/CSS Switch UI element", | ||
@@ -5,0 +5,0 @@ "main": "src/javascript/index.js", |
# Simple Switch | ||
[](https://badge.fury.io/js/a-simple-switch) | ||
Simple, accessible, performant implementation of the Switch UI element. | ||
 | ||
**Features:** | ||
@@ -13,2 +17,3 @@ | ||
- [Statistics](#statistics) | ||
- [Installation](#installation) | ||
@@ -22,2 +27,12 @@ - [Installing the Javascript](#installing-the-javascript) | ||
## Statistics | ||
Below are the gzipped sizes of the source files. All measured using an Apache | ||
server and Google Chrome. | ||
| File | Size (after gzip) | | ||
| ---- | ----------------- | | ||
| `SimpleSwitch.css` | 785 bytes | | ||
| `SimpleSwitch.min.js` | 1.4 kilobytes | | ||
## Installation | ||
@@ -24,0 +39,0 @@ |
@@ -24,4 +24,16 @@ export class Switch { | ||
this.element.insertAdjacentElement('afterend', this.track); | ||
this.updateSize(); | ||
} | ||
/** | ||
* Updates the size of the Switch to match the inherited font size. | ||
*/ | ||
updateSize() { | ||
const _style = window.getComputedStyle(this.track); | ||
const inheritedFontSize = _style['font-size']; | ||
this.track.style.setProperty('--simple-switch_size', inheritedFontSize); | ||
} | ||
bind() { | ||
@@ -28,0 +40,0 @@ this.track.addEventListener("click", function(e) { |
Sorry, the diff of this file is not supported yet
13664
15.23%148
6.47%137
12.3%