UNPKG

react-awesome-toggle-switch

Version:

React toggle switch with more than 19 different designs

66 lines 3.45 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var React = require("react"); require("../../assets/style.scss"); var TotoroSwitch = /** @class */ (function (_super) { __extends(TotoroSwitch, _super); function TotoroSwitch(props) { var _this = _super.call(this, props) || this; _this.state = { nodeRef: React.createRef(), val: props.value ? props.value : false }; return _this; } TotoroSwitch.prototype.componentDidMount = function () { var nodeRef = this.state.nodeRef; nodeRef.current.checked = this.state.val; this.setState({ nodeRef: nodeRef }); }; TotoroSwitch.prototype.onChange = function (e) { this.props.onValueChange(e.currentTarget.checked); }; TotoroSwitch.prototype.render = function () { var _this = this; return (React.createElement("div", { className: "totoroSwitch" }, React.createElement("div", { className: 'wrap' }, React.createElement("input", { type: 'checkbox', ref: this.state.nodeRef, onChange: function (e) { return _this.onChange(e); } }), React.createElement("div", { className: 'totoro' }, React.createElement("div", { className: 'ears' }, React.createElement("div", { className: 'ear' }), React.createElement("div", { className: 'ear' })), React.createElement("div", { className: 'arm' }), React.createElement("div", { className: 'arm' }), React.createElement("div", { className: 'foot' }), React.createElement("div", { className: 'foot two' }), React.createElement("div", { className: 'body' }, React.createElement("div", { className: 'spots' }, React.createElement("div", { className: "spot" }), React.createElement("div", { className: "spot" }), React.createElement("div", { className: "spot" }), React.createElement("div", { className: "spot" }), React.createElement("div", { className: "spot" }), React.createElement("div", { className: "spot" }), React.createElement("div", { className: "spot" })), React.createElement("div", { className: 'inner' }, React.createElement("div", { className: 'mouth' }), React.createElement("div", { className: "eye" }), React.createElement("div", { className: "eye" }))))))); }; return TotoroSwitch; }(React.Component)); exports.default = TotoroSwitch; //# sourceMappingURL=index.js.map