From c8fb79571f844ca9648e52451f5a89cd8b24de8d Mon Sep 17 00:00:00 2001 From: cagataycivici Date: Fri, 28 Dec 2018 15:03:07 +0300 Subject: [PATCH] Implemented Dropdown Component --- src/AppMenu.vue | 1 + src/assets/styles/primevue.css | 1 + src/components/common/Common.css | 15 + src/components/dropdown/Dropdown.css | 123 +++++++++ src/components/dropdown/Dropdown.vue | 397 +++++++++++++++++++++++++++ src/components/utils/DomHandler.js | 1 + src/main.js | 2 + src/router.js | 5 + src/views/dropdown/DropdownDemo.vue | 77 ++++++ src/views/listbox/ListboxDemo.vue | 6 +- 10 files changed, 623 insertions(+), 5 deletions(-) create mode 100644 src/components/dropdown/Dropdown.css create mode 100644 src/components/dropdown/Dropdown.vue create mode 100644 src/views/dropdown/DropdownDemo.vue diff --git a/src/AppMenu.vue b/src/AppMenu.vue index dbe620b0f..6ffdd7f39 100644 --- a/src/AppMenu.vue +++ b/src/AppMenu.vue @@ -10,6 +10,7 @@
● Checkbox ● Chips + ● Dropdown ● Editor ● InputSwitch ● InputText diff --git a/src/assets/styles/primevue.css b/src/assets/styles/primevue.css index a510190a2..4fb9e0efd 100644 --- a/src/assets/styles/primevue.css +++ b/src/assets/styles/primevue.css @@ -4,6 +4,7 @@ @import '../../components/card/Card.css'; @import '../../components/checkbox/Checkbox.css'; @import '../../components/chips/Chips.css'; +@import '../../components/dropdown/Dropdown.css'; @import '../../components/fieldset/Fieldset.css'; @import '../../components/inputtext/InputText.css'; @import '../../components/inputswitch/InputSwitch.css'; diff --git a/src/components/common/Common.css b/src/components/common/Common.css index de44799f9..c436ddbc7 100644 --- a/src/components/common/Common.css +++ b/src/components/common/Common.css @@ -133,4 +133,19 @@ button { transform: translateY(5%); -webkit-transition: transform .3s, opacity .15s; transition: transform .3s, opacity .15s; +} + +/* Overlay Animations */ +.p-input-overlay-enter, +.p-input-overlay-leave-to { + opacity: 0; + -webkit-transform: translateY(5%); + -ms-transform: translateY(5%); + transform: translateY(5%); +} + +.p-input-overlay-enter-active, +.p-input-overlay-leave-active { + -webkit-transition: transform .3s, opacity .15s; + transition: transform .3s, opacity .15s; } \ No newline at end of file diff --git a/src/components/dropdown/Dropdown.css b/src/components/dropdown/Dropdown.css new file mode 100644 index 000000000..97265d7a4 --- /dev/null +++ b/src/components/dropdown/Dropdown.css @@ -0,0 +1,123 @@ +.p-dropdown { + display: inline-block; + position: relative; + cursor: pointer; + vertical-align: middle; +} + +.p-dropdown .p-dropdown-clear-icon { + position: absolute; + right: 2em; + top: 50%; + font-size: 1em; + height: 1em; + margin-top: -.5em; +} + +.p-dropdown .p-dropdown-trigger { + border-right: none; + border-top: none; + border-bottom: none; + cursor: pointer; + width: 1.5em; + height: 100%; + position: absolute; + right: 0; + top: 0; + padding: 0 .25em; +} + +.p-dropdown .p-dropdown-trigger .p-dropdown-trigger-icon { + top: 50%; + left: 50%; + margin-top: -.5em; + margin-left: -.5em; + position: absolute; +} + +.p-dropdown .p-dropdown-label { + display: block; + border: none; + white-space: nowrap; + overflow: hidden; + font-weight: normal; + width: 100%; + padding-right: 1.5em; +} + +.p-dropdown .p-dropdown-item-empty, +.p-dropdown .p-dropdown-label-empty { + overflow: hidden; + visibility: hidden; +} + +.p-dropdown.p-disabled .p-dropdown-trigger, +.p-dropdown.p-disabled .p-dropdown-label { + cursor: default; +} + +.p-dropdown label.p-dropdown-label { + cursor: pointer; +} + +.p-dropdown input.p-dropdown-label { + cursor: default; +} + +.p-dropdown .p-dropdown-panel { + min-width: 100%; + z-index: 1; +} + +.p-dropdown-panel { + position: absolute; + height: auto; +} + +.p-dropdown-panel .p-dropdown-items-wrapper { + overflow: auto; +} + +.p-dropdown-panel .p-dropdown-item { + font-weight: normal; + border: 0 none; + cursor: pointer; + margin: 1px 0; + padding: .125em .25em; + text-align: left; +} + +.p-dropdown-panel .p-dropdown-item-group { + font-weight: bold; +} + +.p-dropdown-panel .p-dropdown-list { + padding: 0.4em; + border: 0 none; + margin: 0; + list-style-type: none; +} + +.p-dropdown-panel .p-dropdown-filter { + width: 100%; + box-sizing: border-box; + padding-right: 1.5em; +} + +.p-dropdown-panel .p-dropdown-filter-container { + position: relative; + margin: 0; + padding: 0.4em; + display: inline-block; +} + +.p-dropdown-panel .p-dropdown-filter-container .p-dropdown-filter-icon { + position: absolute; + top: .8em; + right: 1em; +} + +/** Dropdown **/ +.p-fluid .p-dropdown { + width: 100%; +} \ No newline at end of file diff --git a/src/components/dropdown/Dropdown.vue b/src/components/dropdown/Dropdown.vue new file mode 100644 index 000000000..dd5183029 --- /dev/null +++ b/src/components/dropdown/Dropdown.vue @@ -0,0 +1,397 @@ + + + diff --git a/src/components/utils/DomHandler.js b/src/components/utils/DomHandler.js index 3df8bf588..2fe83b11c 100644 --- a/src/components/utils/DomHandler.js +++ b/src/components/utils/DomHandler.js @@ -207,6 +207,7 @@ export default class DomHandler { element.style.top = top + 'px'; element.style.left = left + 'px'; } + static getHiddenElementOuterHeight(element) { element.style.visibility = 'hidden'; element.style.display = 'block'; diff --git a/src/main.js b/src/main.js index 527f500f0..6c5fdd64d 100644 --- a/src/main.js +++ b/src/main.js @@ -7,6 +7,7 @@ import Button from './components/button/Button'; import Card from './components/card/Card'; import Checkbox from './components/checkbox/Checkbox'; import Chips from './components/chips/Chips'; +import Dropdown from './components/dropdown/Dropdown'; import Editor from './components/editor/Editor'; import InputSwitch from './components/inputswitch/InputSwitch'; import InputText from './components/inputtext/InputText'; @@ -39,6 +40,7 @@ Vue.component('p-button', Button); Vue.component('p-card', Card); Vue.component('p-checkbox', Checkbox); Vue.component('p-chips', Chips); +Vue.component('p-dropdown', Dropdown); Vue.component('p-editor', Editor); Vue.component('p-inputSwitch', InputSwitch); Vue.component('p-inputtext', InputText); diff --git a/src/router.js b/src/router.js index 5c272f7bc..3e6ef2cf5 100644 --- a/src/router.js +++ b/src/router.js @@ -36,6 +36,11 @@ export default new Router({ name: 'chips', component: () => import('./views/chips/ChipsDemo.vue') }, + { + path: '/dropdown', + name: 'dropdown', + component: () => import('./views/dropdown/DropdownDemo.vue') + }, { path: '/editor', name: 'editor', diff --git a/src/views/dropdown/DropdownDemo.vue b/src/views/dropdown/DropdownDemo.vue new file mode 100644 index 000000000..b03b28fdc --- /dev/null +++ b/src/views/dropdown/DropdownDemo.vue @@ -0,0 +1,77 @@ + + + + + diff --git a/src/views/listbox/ListboxDemo.vue b/src/views/listbox/ListboxDemo.vue index ff1d2a8a3..e4e8f62b1 100644 --- a/src/views/listbox/ListboxDemo.vue +++ b/src/views/listbox/ListboxDemo.vue @@ -51,8 +51,4 @@ export default { } } } - - - + \ No newline at end of file