diff --git a/src/renderer/components/ft-toggle-switch/ft-toggle-switch.css b/src/renderer/components/ft-toggle-switch/ft-toggle-switch.css new file mode 100644 index 00000000..1d57aaf0 --- /dev/null +++ b/src/renderer/components/ft-toggle-switch/ft-toggle-switch.css @@ -0,0 +1,74 @@ +/* Thanks to Guus Lieben for the Material Design Switch */ + +.switch-input { + display: none; +} + +.switch-label { + position: relative; + display: inline-block; + min-width: 112px; + cursor: pointer; + font-weight: 500; + text-align: left; + margin: 16px; + padding: 16px 0 16px 44px; +} + +.switch-label:before, +.switch-label:after { + content: ""; + position: absolute; + margin: 0; + outline: 0; + top: 50%; + -ms-transform: translate(0, -50%); + -webkit-transform: translate(0, -50%); + transform: translate(0, -50%); + -webkit-transition: all 0.3s ease; + transition: all 0.3s ease; +} + +.switch-label:before { + left: 1px; + width: 34px; + height: 14px; + background-color: #9E9E9E; + border-radius: 8px; +} + +.switch-label:after { + left: 0; + width: 20px; + height: 20px; + background-color: #FAFAFA; + border-radius: 50%; + box-shadow: 0 3px 1px -2px rgba(0, 0, 0, 0.14), 0 2px 2px 0 rgba(0, 0, 0, 0.098), 0 1px 5px 0 rgba(0, 0, 0, 0.084); +} + +.switch-label .toggle--on { + display: none; +} + +.switch-label .toggle--off { + display: inline-block; +} + +.switch-input:checked+.switch-label:before { + background-color: #90CAF9; +} + +.switch-input:checked+.switch-label:after { + background-color: #2196F3; + -ms-transform: translate(80%, -50%); + -webkit-transform: translate(80%, -50%); + transform: translate(80%, -50%); +} + +.switch-input:checked+.switch-label .toggle--on { + display: inline-block; +} + +.switch-input:checked+.switch-label .toggle--off { + display: none; +} diff --git a/src/renderer/components/ft-toggle-switch/ft-toggle-switch.js b/src/renderer/components/ft-toggle-switch/ft-toggle-switch.js new file mode 100644 index 00000000..5439c5d9 --- /dev/null +++ b/src/renderer/components/ft-toggle-switch/ft-toggle-switch.js @@ -0,0 +1,25 @@ +import Vue from 'vue' + +export default Vue.extend({ + name: 'FtToggleSwitch', + props: { + label: { + type: String, + required: true + }, + defaultValue: { + type: Boolean, + default: false + } + }, + data: function () { + return { + id: '', + currentValue: false + } + }, + mounted: function () { + this.id = this._uid + this.currentValue = this.defaultValue + } +}) diff --git a/src/renderer/components/ft-toggle-switch/ft-toggle-switch.vue b/src/renderer/components/ft-toggle-switch/ft-toggle-switch.vue new file mode 100644 index 00000000..b9545c47 --- /dev/null +++ b/src/renderer/components/ft-toggle-switch/ft-toggle-switch.vue @@ -0,0 +1,22 @@ + + +