a-simple-switch
Advanced tools
Comparing version 0.2.0 to 0.3.0
{ | ||
"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 | ||
[![npm version](https://badge.fury.io/js/a-simple-switch.svg)](https://badge.fury.io/js/a-simple-switch) | ||
Simple, accessible, performant implementation of the Switch UI element. | ||
![image](https://user-images.githubusercontent.com/6314286/27006387-34f51ae4-4df0-11e7-903d-f5a05e783d6e.png) | ||
**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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13664
148
137