mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +00:00
Update doc components structure
This commit is contained in:
parent
cf5dd67244
commit
036b90fc82
16 changed files with 18 additions and 14 deletions
47
components/doc/DocSectionText.vue
Normal file
47
components/doc/DocSectionText.vue
Normal file
|
@ -0,0 +1,47 @@
|
|||
<template>
|
||||
<component :is="headerTag" class="doc-section-label">
|
||||
{{ $attrs.label }}
|
||||
<NuxtLink :id="$attrs.id" :to="`${checkRouteName}/#${$attrs.id}`" target="_self" @click="onClick"> # </NuxtLink>
|
||||
</component>
|
||||
<div v-if="$attrs" class="doc-section-description">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
inheritAttrs: false,
|
||||
methods: {
|
||||
onClick(event) {
|
||||
const parentElement = event.currentTarget.parentElement;
|
||||
const hash = window.location.hash.substring(1);
|
||||
|
||||
hash === this.$attrs.id && event.preventDefault();
|
||||
|
||||
setTimeout(() => {
|
||||
parentElement.scrollIntoView({ block: 'start' });
|
||||
}, 0);
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
checkRouteName() {
|
||||
const path = this.$router.currentRoute.value.path;
|
||||
|
||||
if (path.lastIndexOf('/') === path.length - 1) {
|
||||
return path.slice(0, -1);
|
||||
}
|
||||
|
||||
return path;
|
||||
},
|
||||
headerTag() {
|
||||
if (this.$attrs.level === 3) {
|
||||
return 'h4';
|
||||
} else if (this.$attrs.level === 2) {
|
||||
return 'h3';
|
||||
}
|
||||
|
||||
return 'h2';
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue