mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +00:00
Refactor #3965 - For Accordion
This commit is contained in:
parent
78552d81cf
commit
e58fc57621
7 changed files with 175 additions and 112 deletions
95
components/lib/accordion/BaseAccordion.vue
Normal file
95
components/lib/accordion/BaseAccordion.vue
Normal file
|
@ -0,0 +1,95 @@
|
|||
<script>
|
||||
import BaseComponent from 'primevue/basecomponent';
|
||||
import { useStyle } from 'primevue/usestyle';
|
||||
|
||||
const styles = `
|
||||
.p-accordion-header-action {
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
user-select: none;
|
||||
position: relative;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.p-accordion-header-action:focus {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.p-accordion-header-text {
|
||||
line-height: 1;
|
||||
}
|
||||
`;
|
||||
|
||||
const classes = {
|
||||
root: 'p-accordion p-component',
|
||||
tab: {
|
||||
root: ({ instance, index }) => [
|
||||
'p-accordion-tab',
|
||||
{
|
||||
'p-accordion-tab-active': instance.isTabActive(index)
|
||||
}
|
||||
],
|
||||
header: ({ instance, tab, index }) => [
|
||||
'p-accordion-header',
|
||||
{
|
||||
'p-highlight': instance.isTabActive(index),
|
||||
'p-disabled': instance.getTabProp(tab, 'disabled')
|
||||
}
|
||||
],
|
||||
headerAction: 'p-accordion-header-link p-accordion-header-action',
|
||||
headerIcon: 'p-accordion-toggle-icon',
|
||||
headerTitle: 'p-accordion-header-text',
|
||||
toggleableContent: 'p-toggleable-content',
|
||||
content: 'p-accordion-content'
|
||||
}
|
||||
};
|
||||
|
||||
const { load: loadStyle, unload: unloadStyle } = useStyle(styles, { id: 'primevue_accordion_style', manual: true });
|
||||
|
||||
export default {
|
||||
name: 'BaseAccordion',
|
||||
extends: BaseComponent,
|
||||
props: {
|
||||
multiple: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
activeIndex: {
|
||||
type: [Number, Array],
|
||||
default: null
|
||||
},
|
||||
lazy: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
expandIcon: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
collapseIcon: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
tabindex: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
selectOnFocus: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
css: {
|
||||
classes
|
||||
},
|
||||
watch: {
|
||||
isUnstyled: {
|
||||
immediate: true,
|
||||
handler(newValue) {
|
||||
!newValue && loadStyle();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue