primevue-mirror/doc/passthrough/UsePassThroughDoc.vue

119 lines
3.1 KiB
Vue
Raw Normal View History

2023-08-30 08:49:23 +00:00
<template>
<DocSectionText v-bind="$attrs">
2024-01-12 07:59:36 +00:00
<p>An existing pass through configuration is customized with the <i>usePassThrough</i> utility. The first parameter is the object to customize, the second parameter is the customizations and the final parameter is the merge strategy.</p>
2024-01-30 08:16:35 +00:00
<DocSectionCode :code="code1" hideToggleCode importCode hideStackBlitz />
2023-08-30 08:49:23 +00:00
<p>
The <i>mergeSections</i> defines whether the sections from the main configuration gets added and the <i>mergeProps</i> controls whether to override or merge the defined props. Defaults are <i>true</i> for <i>mergeSections</i> and
<i>false</i> for <i>mergeProps</i>.
</p>
2024-01-30 08:16:35 +00:00
<DocSectionCode :code="code2" hideToggleCode importCode hideStackBlitz />
<DocSectionCode :code="code3" hideToggleCode importCode hideStackBlitz />
<DocSectionCode :code="code4" hideToggleCode importCode hideStackBlitz />
<DocSectionCode :code="code5" hideToggleCode importCode hideStackBlitz />
2023-08-30 08:49:23 +00:00
</DocSectionText>
</template>
<script>
export default {
data() {
return {
code1: {
2023-09-22 12:54:14 +00:00
basic: `
import { createApp } from "vue";
2023-08-30 08:49:23 +00:00
import PrimeVue from "primevue/config";
import { usePassThrough } from "primevue/passthrough";
import BasePreset from "./basepreset";
2023-08-30 08:49:23 +00:00
const app = createApp(App);
const CustomPreset = usePassThrough(
BasePreset,
2023-08-30 08:49:23 +00:00
{
panel: {
title: {
class: ['leading-none font-light text-2xl']
}
}
},
{
mergeSections: true,
2023-09-01 09:27:29 +00:00
mergeProps: false
2023-08-30 08:49:23 +00:00
}
);
app.use(PrimeVue, { unstyled: true, pt: CustomPreset });
2023-09-22 12:54:14 +00:00
`
2023-08-30 08:49:23 +00:00
},
code2: {
2023-09-22 12:54:14 +00:00
basic: `
const CustomPreset = usePassThrough(
BasePreset,
2023-08-30 08:49:23 +00:00
{
panel: {
header: 'my_panel_header'
}
},
{ mergeSections: true, mergeProps: false }
);
2024-01-30 08:16:35 +00:00
// Output:
2023-08-30 08:49:23 +00:00
// panel.header.class => 'my_panel_header'
2023-09-22 12:54:14 +00:00
// panel.title.class => Tailwind.panel.title.class
`
2023-08-30 08:49:23 +00:00
},
code3: {
2023-09-22 12:54:14 +00:00
basic: `
const CustomPreset = usePassThrough(
BasePreset,
2023-08-30 08:49:23 +00:00
{
panel: {
header: 'my_panel_header'
}
},
{ mergeSections: true, mergeProps: true }
);
2024-01-30 08:16:35 +00:00
// Output:
2023-08-30 08:49:23 +00:00
// panel.header.class => [Tailwind.panel.header.class, 'my_panel_header']
2023-09-22 12:54:14 +00:00
// panel.title.class => Tailwind.panel.title.class
`
2023-08-30 08:49:23 +00:00
},
code4: {
2023-09-22 12:54:14 +00:00
basic: `
const CustomPreset = usePassThrough(
BasePreset,
2023-08-30 08:49:23 +00:00
{
panel: {
header: 'my_panel_header'
}
},
{ mergeSections: false, mergeProps: true }
);
2024-01-30 08:16:35 +00:00
// Output:
2023-08-30 08:49:23 +00:00
// panel.header.class => [Tailwind.panel.header.class, 'my_panel_header']
2023-09-22 12:54:14 +00:00
// panel.title.class => undefined
`
2023-08-30 08:49:23 +00:00
},
code5: {
basic: `
const CustomPreset = usePassThrough(
BasePreset,
2023-08-30 08:49:23 +00:00
{
panel: {
header: 'my_panel_header'
}
},
{ mergeSections: false, mergeProps: false }
);
2024-01-30 08:16:35 +00:00
// Output:
2023-08-30 08:49:23 +00:00
// panel.header.class => 'my_panel_header'
2023-09-22 12:54:14 +00:00
// panel.title.class => undefined
`
2023-08-30 08:49:23 +00:00
}
};
}
};
</script>