From efb01cb824b88a893bc5f737e41f253622f82ce4 Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Mon, 17 Dec 2018 00:04:39 +0300 Subject: [PATCH] Imlemented InputSwitch Component --- src/AppMenu.vue | 1 + src/assets/styles/primevue.css | 1 + src/components/inputswitch/InputSwitch.css | 36 +++++++++++++++ src/components/inputswitch/InputSwitch.vue | 54 ++++++++++++++++++++++ src/main.js | 2 + src/router.js | 5 ++ src/views/inputswitch/InputSwitchDemo.vue | 31 +++++++++++++ 7 files changed, 130 insertions(+) create mode 100644 src/components/inputswitch/InputSwitch.css create mode 100644 src/components/inputswitch/InputSwitch.vue create mode 100644 src/views/inputswitch/InputSwitchDemo.vue diff --git a/src/AppMenu.vue b/src/AppMenu.vue index c110cac76..59f1e2c94 100644 --- a/src/AppMenu.vue +++ b/src/AppMenu.vue @@ -9,6 +9,7 @@
● Checkbox + ● InputSwitch ● InputText ● Listbox ● RadioButton diff --git a/src/assets/styles/primevue.css b/src/assets/styles/primevue.css index 4e2913686..c43e2a0e6 100644 --- a/src/assets/styles/primevue.css +++ b/src/assets/styles/primevue.css @@ -5,6 +5,7 @@ @import '../../components/checkbox/Checkbox.css'; @import '../../components/fieldset/Fieldset.css'; @import '../../components/inputtext/InputText.css'; +@import '../../components/inputswitch/InputSwitch.css'; @import '../../components/listbox/Listbox.css'; @import '../../components/panel/Panel.css'; @import '../../components/radiobutton/RadioButton.css'; diff --git a/src/components/inputswitch/InputSwitch.css b/src/components/inputswitch/InputSwitch.css new file mode 100644 index 000000000..0854112ca --- /dev/null +++ b/src/components/inputswitch/InputSwitch.css @@ -0,0 +1,36 @@ +.p-inputswitch { + position: relative; + display: inline-block; + width: 3em; + height: 1.75em; +} + +.p-inputswitch-slider { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + -webkit-transition: .3s; + transition: .3s; + border-radius: 30px; +} + +.p-inputswitch-slider:before { + position: absolute; + content: ""; + height: 1.250em; + width: 1.250em; + left: .25em; + bottom: .25em; + border-radius: 50%; + -webkit-transition: .3s; + transition: .3s; +} + +.p-inputswitch-checked .p-inputswitch-slider:before { + -webkit-transform: translateX(1.250em); + -ms-transform: translateX(1.250em); + transform: translateX(1.250em); +} \ No newline at end of file diff --git a/src/components/inputswitch/InputSwitch.vue b/src/components/inputswitch/InputSwitch.vue new file mode 100644 index 000000000..e8db100b1 --- /dev/null +++ b/src/components/inputswitch/InputSwitch.vue @@ -0,0 +1,54 @@ + + + \ No newline at end of file diff --git a/src/main.js b/src/main.js index 9766deeb6..d8a8e7c00 100644 --- a/src/main.js +++ b/src/main.js @@ -6,6 +6,7 @@ import AccordionTab from './components/accordion/AccordionTab'; import Button from './components/button/Button'; import Card from './components/card/Card'; import Checkbox from './components/checkbox/Checkbox'; +import InputSwitch from './components/inputswitch/InputSwitch'; import InputText from './components/inputtext/InputText'; import Fieldset from './components/fieldset/Fieldset'; import Listbox from './components/listbox/Listbox'; @@ -30,6 +31,7 @@ Vue.component('p-accordionTab', AccordionTab); Vue.component('p-button', Button); Vue.component('p-card', Card); Vue.component('p-checkbox', Checkbox); +Vue.component('p-inputSwitch', InputSwitch); Vue.component('p-inputtext', InputText); Vue.component('p-listbox', Listbox); Vue.component('p-fieldset', Fieldset); diff --git a/src/router.js b/src/router.js index c1a65ef43..d90d7ced3 100644 --- a/src/router.js +++ b/src/router.js @@ -41,6 +41,11 @@ export default new Router({ name: 'flexgrid', component: () => import('./views/flexgrid/FlexGridDemo.vue') }, + { + path: '/inputswitch', + name: 'inputswitch', + component: () => import('./views/inputswitch/InputSwitchDemo.vue') + }, { path: '/inputtext', name: 'inputtext', diff --git a/src/views/inputswitch/InputSwitchDemo.vue b/src/views/inputswitch/InputSwitchDemo.vue new file mode 100644 index 000000000..462124953 --- /dev/null +++ b/src/views/inputswitch/InputSwitchDemo.vue @@ -0,0 +1,31 @@ + + +