Initiated accordion component

pull/3/head
cagataycivici 2018-12-13 23:39:16 +03:00
parent 0fc82c33bd
commit 47c106c413
8 changed files with 212 additions and 2 deletions

View File

@ -43,6 +43,7 @@
</a>
<div :class="{'submenuhide': activeMenuIndex !== 3, 'submenushow': activeMenuIndex === 3}">
<div>
<router-link to="/accordion">&#9679; Accordion</router-link>
<router-link to="/panel">&#9679; Panel</router-link>
<router-link to="/fieldset">&#9679; Fieldset</router-link>
<router-link to="/flexgrid">&#9679; FlexGrid</router-link>

View File

@ -1,4 +1,5 @@
@import '../../components/common/Common.css';
@import '../../components/accordion/Accordion.css';
@import '../../components/inputtext/InputText.css';
@import '../../components/listbox/ListBox.css';
@import '../../components/button/Button.css';

View File

@ -0,0 +1,56 @@
.p-accordion {
width: 100%;
}
.p-accordion .p-accordion-header {
cursor: pointer;
position: relative;
margin-top: 1px;
zoom: 1;
}
.p-accordion .p-accordion-header a {
display: block;
padding: .5em;
}
.p-accordion .p-accordion-toggle-icon,
.p-accordion .p-accordion-header-text {
vertical-align: middle;
}
.p-accordion .p-accordion-header a > span {
display: inline-block;
vertical-align: middle;
}
.p-accordion .p-accordion-content {
padding: 1em;
border-top: 0;
zoom: 1;
}
.p-accordion .p-accordion-header.p-disabled,
.p-accordion .p-accordion-header.p-disabled a {
cursor: default;
}
.p-accordion-content-wrapper-enter,
.p-accordion-content-wrapper-leave-to {
max-height: 0;
}
.p-accordion-content-wrapper-enter-to,
.p-accordion-content-wrapper-leave {
max-height: 1000px;
}
.p-accordion-content-wrapper-leave-active {
overflow: hidden;
transition: max-height 0.45s cubic-bezier(0, 1, 0, 1);
}
.p-accordion-content-wrapper-enter-active {
overflow: hidden;
transition: max-height 1s ease-in-out;
}

View File

@ -0,0 +1,70 @@
<script>
export default {
props: {
multiple: Boolean
},
data() {
return {
tabs: []
};
},
mounted() {
this.tabs = this.$children;
},
methods: {
onTabClick(event, tab) {
if (!tab.disabled) {
if (!this.multiple && !tab.d_active) {
this.tabs.forEach(tab => tab.d_active = false);
}
tab.d_active = !tab.d_active;
let eventName = !tab.active ? 'tabclose' : 'tabopen';
this.$emit(eventName, {
originalEvent: event,
tab: tab
});
}
},
onTabKeydown(event, tab) {
if (event.which === 13) {
this.onTabClick(event, tab);
}
},
isSelected(index) {
return this.props.multiple ? (this.d_activeTabIndex && this.d_activeTabIndex.indexOf(index) >= 0) : this.d_activeTabIndex === index;
}
},
render() {
return (
<div class="p-accordion p-component">
{this.$slots.default}
{
this.tabs.map((tab, i) => {
return (
<div key={tab.header||i} class="p-accordion-tab">
<div class={['p-accordion-header', {'p-highlight': tab.d_active, 'p-disabled': tab.disabled}]}>
<a role="tab" on-click={event => this.onTabClick(event, tab)} on-keydown={event => this.onTabKeydown(event, tab)} tabindex={tab.disabled ? null : '0'}>
<span class="p-accordion-toggle-icon pi pi-fw pi-caret-right"></span>
{tab.header && <span class="p-accordion-header-text">{tab.header}</span>}
{tab.$slots.header}
</a>
</div>
<transition name="p-accordion-content-wrapper">
{
<div class="p-accordion-content-wrapper" v-show={tab.d_active}>
<div class="p-accordion-content">
{tab.$slots.default}
</div>
</div>
}
</transition>
</div>
);
})
}
</div>
)
}
}
</script>

View File

@ -0,0 +1,22 @@
<script>
export default {
props: {
header: null,
active: Boolean,
disabled: Boolean
},
watch: {
active(newValue) {
this.d_active = newValue;
}
},
data() {
return {
d_active: this.active
}
},
render() {
return null;
}
}
</script>

View File

@ -1,6 +1,8 @@
import Vue from 'vue';
import App from './App.vue';
import router from './router';
import Accordion from './components/accordion/Accordion';
import AccordionTab from './components/accordion/AccordionTab';
import Button from './components/button/Button';
import InputText from './components/inputtext/InputText';
import Fieldset from './components/fieldset/Fieldset';
@ -17,11 +19,13 @@ import 'primeicons/primeicons.css';
Vue.config.productionTip = false;
Vue.component('p-inputtext', InputText);
Vue.component('p-accordion', Accordion);
Vue.component('p-accordionTab', AccordionTab);
Vue.component('p-button', Button);
Vue.component('p-inputtext', InputText);
Vue.component('p-listBox', ListBox);
Vue.component('p-panel', Panel);
Vue.component('p-fieldset', Fieldset);
Vue.component('p-panel', Panel);
Vue.component('p-tabView', TabView);
Vue.component('p-tabPanel', TabPanel);
Vue.component('p-textarea', Textarea);

View File

@ -11,6 +11,11 @@ export default new Router({
name: 'home',
component: Home
},
{
path: '/accordion',
name: 'accordion',
component: () => import('./views/accordion/AccordionDemo.vue')
},
{
path: '/button',
name: 'button',

View File

@ -0,0 +1,51 @@
<template>
<div>
<div class="content-section introduction">
<div class="feature-intro">
<h1>AccordionPanel</h1>
<p>AccordionPanel groups a collection of contents in tabs.</p>
</div>
</div>
<div class="content-section implementation">
<h3 class="first">Default</h3>
<p-accordion>
<p-accordionTab header="Godfather I">
The story begins as Don Vito Corleone, the head of a New York Mafia family, overseeshis daughter's wedding. His beloved son ichael has just come home from the war,
but does not intend to become part of his father's business. Through Michael's life the nature of the family business becomes clear. The business of the family is
just like the head of the family, kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
</p-accordionTab>
<p-accordionTab header="Godfather II">
Francis Ford Coppola's legendary continuation and sequel to his landmark 1972 film, TheGodfather parallels the young Vito Corleone's rise with his son Michael's spiritual fall,
deepening The Godfather's depiction of the dark side of the American dream. In the early 1900s, the child Vito flees his Sicilian village for America after the local Mafia kills
his family. Vito struggles to make a living, legally or illegally, for his wife and growing brood in Little Italy.
</p-accordionTab>
<p-accordionTab header="Godfather III">
The Godfather Part III is set in 1979 and 1980. Michael has moved back to New York and taken great strides to remove the family from crime. He turns over his New York criminal
interests to longtime enforcer Joey Zasa. He uses his wealth in an attempt to rehabilitate his reputation through numerous philanthropic acts, administered by a foundation named after his father.
A decade earlier, he gave custody of his two children to Kay, who has since remarried.
</p-accordionTab>
</p-accordion>
<h3>Multiple</h3>
<p-accordion :multiple="true">
<p-accordionTab header="Godfather I">
The story begins as Don Vito Corleone, the head of a New York Mafia family, overseeshis daughter's wedding. His beloved son ichael has just come home from the war,
but does not intend to become part of his father's business. Through Michael's life the nature of the family business becomes clear. The business of the family is
just like the head of the family, kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
</p-accordionTab>
<p-accordionTab header="Godfather II">
Francis Ford Coppola's legendary continuation and sequel to his landmark 1972 film, TheGodfather parallels the young Vito Corleone's rise with his son Michael's spiritual fall,
deepening The Godfather's depiction of the dark side of the American dream. In the early 1900s, the child Vito flees his Sicilian village for America after the local Mafia kills
his family. Vito struggles to make a living, legally or illegally, for his wife and growing brood in Little Italy.
</p-accordionTab>
<p-accordionTab header="Godfather III">
The Godfather Part III is set in 1979 and 1980. Michael has moved back to New York and taken great strides to remove the family from crime. He turns over his New York criminal
interests to longtime enforcer Joey Zasa. He uses his wealth in an attempt to rehabilitate his reputation through numerous philanthropic acts, administered by a foundation named after his father.
A decade earlier, he gave custody of his two children to Kay, who has since remarried.
</p-accordionTab>
</p-accordion>
</div>
</div>
</template>