Toggleable Panel

pull/3/head
cagataycivici 2018-12-09 23:25:26 +03:00
parent 344154e8fe
commit f8edaffc7f
3 changed files with 43 additions and 16 deletions

View File

@ -13,11 +13,15 @@
width: 1.25em;
line-height: 1.25em;
text-align: center;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
user-select: none;
}
.p-panel .p-panel-titlebar-icon span {
line-height: inherit;
margin-top: -1px;
}
.p-panel .p-panel-content {
@ -32,17 +36,22 @@
text-align:left;
}
.p-panel-content-wrapper-collapsed {
overflow: hidden;
.p-panel-content-wrapper-enter,
.p-panel-content-wrapper-leave-to {
max-height: 0;
}
.p-panel-content-wrapper-enter-to,
.p-panel-content-wrapper-leave {
max-height: 1000px;
}
.p-panel-content-wrapper-leave-active {
overflow: hidden;
transition: max-height 0.5s cubic-bezier(0, 1, 0, 1);
}
.p-panel-content-wrapper-expanded {
max-height: 1000px;
.p-panel-content-wrapper-enter-active {
overflow: hidden;
transition: max-height 1s ease-in-out;
}
.p-panel-content-wrapper-expanding {
overflow: hidden;
}

View File

@ -4,12 +4,17 @@
<slot name="header">
<span class="p-panel-title" v-if="header">{{header}}</span>
</slot>
<a v-if="toggleable" tabindex="0" class="p-panel-titlebar-icon p-panel-titlebar-toggler" @click="toggle">
<span :class="{'pi pi-minus': !d_collapsed, 'pi pi-plus': d_collapsed}"></span>
</a>
</div>
<div class="p-panel-content-wrapper">
<transition name="p-panel-content-wrapper">
<div class="p-panel-content-wrapper" v-show="!d_collapsed">
<div class="p-panel-content">
<slot></slot>
</div>
</div>
</transition>
</div>
</template>
@ -17,7 +22,18 @@
export default {
props: {
header: String,
toggleable: Boolean
toggleable: Boolean,
collapsed: Boolean
},
data() {
return {
d_collapsed: this.collapsed
}
},
methods: {
toggle() {
this.d_collapsed = !this.d_collapsed;
}
}
}
</script>

View File

@ -8,6 +8,7 @@
</div>
<div class="content-section implementation">
<h3 class="first">Regular</h3>
<p-panel header="Godfather I">
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
@ -15,7 +16,8 @@
kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
</p-panel>
<p-panel header="Godfather I" style="margin-top:2em" :toggleable="true">
<h3>Toggleable</h3>
<p-panel header="Godfather I" :toggleable="true">
The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
His beloved son Michael 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,