Skip to content

Commit

Permalink
Refactor #4953 - For Panel
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Feb 2, 2024
1 parent 239b080 commit dcf5781
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions components/lib/panel/Panel.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<template>
<div :class="cx('root')" v-bind="ptm('root')">
<div :class="cx('header')" v-bind="ptm('header')">
<slot :id="ariaId + '_header'" name="header" :class="cx('title')">
<span v-if="header" :id="ariaId + '_header'" :class="cx('title')" v-bind="ptm('title')">{{ header }}</span>
<slot :id="id + '_header'" name="header" :class="cx('title')">
<span v-if="header" :id="id + '_header'" :class="cx('title')" v-bind="ptm('title')">{{ header }}</span>
</slot>
<div :class="cx('icons')" v-bind="ptm('icons')">
<slot name="icons"></slot>
<button
v-if="toggleable"
:id="ariaId + '_header'"
:id="id + '_header'"
v-ripple
type="button"
role="button"
:class="cx('toggler')"
:aria-label="buttonAriaLabel"
:aria-controls="ariaId + '_content'"
:aria-controls="id + '_content'"
:aria-expanded="!d_collapsed"
@click="toggle"
@keydown="onKeyDown"
Expand All @@ -27,7 +27,7 @@
</div>
</div>
<transition name="p-toggleable-content" v-bind="ptm('transition')">
<div v-show="!d_collapsed" :id="ariaId + '_content'" :class="cx('toggleablecontent')" role="region" :aria-labelledby="ariaId + '_header'" v-bind="ptm('toggleablecontent')">
<div v-show="!d_collapsed" :id="id + '_content'" :class="cx('toggleablecontent')" role="region" :aria-labelledby="id + '_header'" v-bind="ptm('toggleablecontent')">
<div :class="cx('content')" v-bind="ptm('content')">
<slot></slot>
</div>
Expand All @@ -52,14 +52,21 @@ export default {
emits: ['update:collapsed', 'toggle'],
data() {
return {
id: this.$attrs.id,
d_collapsed: this.collapsed
};
},
watch: {
'$attrs.id': function (newValue) {
this.id = newValue || UniqueComponentId();
},
collapsed(newValue) {
this.d_collapsed = newValue;
}
},
mounted() {
this.id = this.id || UniqueComponentId();
},
methods: {
toggle(event) {
this.d_collapsed = !this.d_collapsed;
Expand All @@ -77,9 +84,6 @@ export default {
}
},
computed: {
ariaId() {
return UniqueComponentId();
},
buttonAriaLabel() {
return this.toggleButtonProps && this.toggleButtonProps.ariaLabel ? this.toggleButtonProps.ariaLabel : this.header;
}
Expand Down

0 comments on commit dcf5781

Please sign in to comment.