primevue-mirror/src/views/panel/PanelDoc.vue

368 lines
14 KiB
Vue
Raw Normal View History

2019-03-29 07:00:03 +00:00
<template>
<div class="content-section documentation">
<TabView>
<TabPanel header="Documentation">
2020-06-17 19:21:22 +00:00
<h5>Import</h5>
2021-02-03 10:10:30 +00:00
<pre v-code.script><code>
2019-03-29 07:00:03 +00:00
import Panel from 'primevue/panel';
2020-09-24 11:14:55 +00:00
</code></pre>
2019-03-29 07:00:03 +00:00
2020-06-17 19:21:22 +00:00
<h5>Getting Started</h5>
2019-03-29 07:00:03 +00:00
<p>Panel is a container component that accepts content as its children.</p>
2021-02-03 10:10:30 +00:00
<pre v-code><code>
2020-06-17 19:21:22 +00:00
&lt;Panel header="Header"&gt;
2020-06-18 10:00:10 +00:00
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
2020-06-17 19:21:22 +00:00
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
2019-03-29 07:00:03 +00:00
&lt;/Panel&gt;
2020-09-24 11:14:55 +00:00
</code></pre>
2019-05-23 08:53:40 +00:00
2020-06-17 19:21:22 +00:00
<h5>Custom Header</h5>
2019-05-23 08:53:40 +00:00
<p>Header of the panel is either defined with the <i>header</i> property or the header template.</p>
2021-02-03 10:10:30 +00:00
<pre v-code><code>
2019-05-23 08:53:40 +00:00
&lt;Panel&gt;
2019-05-23 11:28:24 +00:00
&lt;template #header&gt;
2019-05-23 08:53:40 +00:00
Header Content
&lt;/template&gt;
Content
&lt;/Panel&gt;
2020-09-24 11:14:55 +00:00
</code></pre>
2019-03-29 07:00:03 +00:00
2020-06-17 19:21:22 +00:00
<h5>Toggleable</h5>
2019-03-29 07:00:03 +00:00
<p>Content of the panel can be expanded and collapsed using <i>toggleable</i> option.</p>
2021-02-03 10:10:30 +00:00
<pre v-code><code>
2020-06-17 19:21:22 +00:00
&lt;Panel header="Header" :toggleable="true"&gt;
2020-06-18 10:00:10 +00:00
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
2020-06-17 19:21:22 +00:00
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
2019-03-29 07:00:03 +00:00
&lt;/Panel&gt;
2020-09-24 11:14:55 +00:00
</code></pre>
2019-05-23 13:11:45 +00:00
<p>To control the initial state of the toggleable panel, use the <i>collapsed</i> property.</p>
2021-02-03 10:10:30 +00:00
<pre v-code><code>
2019-05-23 13:11:45 +00:00
&lt;Panel header="Header Text" :toggleable="true" :collapsed="true"&gt;
Content
&lt;/Panel&gt;
2020-09-24 11:14:55 +00:00
</code></pre>
2019-05-23 13:11:45 +00:00
<p>Use the v-model directive to enable two-way binding.</p>
2019-05-23 13:11:45 +00:00
2021-02-03 10:10:30 +00:00
<pre v-code><code>
2019-05-23 13:11:45 +00:00
&lt;button type="button" @click="isCollapsed = !isCollapsed">Toggle Programmatically&lt;/button&gt;
&lt;Panel header="Header Text" :toggleable="true" v-model:collapsed="isCollapsed"&gt;
2019-05-23 13:11:45 +00:00
Content
&lt;/Panel&gt;
2020-09-24 11:14:55 +00:00
</code></pre>
2020-05-14 08:48:25 +00:00
2020-06-17 19:21:22 +00:00
<h5>Custom Icons</h5>
<p>Additional icons can be placed at the header section of the panel using the special <i>icons</i> slot. For a unified look, it is suggest to add <i>.p-panel-header-icon</i>
2020-05-14 08:48:25 +00:00
class to your icons.</p>
2021-02-03 10:10:30 +00:00
<pre v-code><code>
2020-06-17 19:21:22 +00:00
&lt;h5&gt;Advanced&lt;/h5&gt;
&lt;Panel header="Header"&gt;
2020-05-14 08:48:25 +00:00
&lt;template #icons&gt;
2020-09-21 13:11:25 +00:00
&lt;button class="p-panel-header-icon p-link p-mr-2" @click="toggle"&gt;
2020-05-14 08:48:25 +00:00
&lt;span class="pi pi-cog"&gt;&lt;/span&gt;
2020-06-30 08:25:20 +00:00
&lt;/button&gt;
2020-05-14 08:48:25 +00:00
&lt;Menu id="config_menu" ref="menu" :model="items" :popup="true" /&gt;
&lt;/template&gt;
&lt;/Panel&gt;
2020-09-24 11:14:55 +00:00
</code></pre>
2019-03-29 07:00:03 +00:00
2020-06-17 19:21:22 +00:00
<h5>Properties</h5>
2020-01-13 09:04:50 +00:00
<p>Any property as style and class are passed to the main container element. Following are the additional properties to configure the component.</p>
2019-03-29 07:00:03 +00:00
<div class="doc-tablewrapper">
<table class="doc-table">
<thead>
2019-05-23 08:53:40 +00:00
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
2019-03-29 07:00:03 +00:00
</thead>
<tbody>
2019-05-23 08:53:40 +00:00
<tr>
<td>header</td>
<td>string</td>
<td>null</td>
<td>Header text of the panel.</td>
</tr>
<tr>
<td>toggleable</td>
<td>boolean</td>
<td>null</td>
<td>Defines if content of panel can be expanded and collapsed.</td>
</tr>
<tr>
<td>collapsed</td>
<td>boolean</td>
<td>null</td>
<td>Defines the initial state of panel content.</td>
</tr>
2019-03-29 07:00:03 +00:00
</tbody>
</table>
</div>
2020-06-17 19:21:22 +00:00
<h5>Events</h5>
2019-03-29 07:00:03 +00:00
<div class="doc-tablewrapper">
<table class="doc-table">
<thead>
2019-05-23 08:53:40 +00:00
<tr>
<th>Name</th>
<th>Parameters</th>
<th>Description</th>
</tr>
2019-03-29 07:00:03 +00:00
</thead>
<tbody>
2019-05-23 08:53:40 +00:00
<tr>
<td>toggle</td>
<td>event.originalEvent: browser event <br />
event.value: collapsed state as a boolean
</td>
<td>Callback to invoke when a tab toggle.</td>
</tr>
2019-03-29 07:00:03 +00:00
</tbody>
</table>
</div>
2020-06-17 19:21:22 +00:00
<h5>Styling</h5>
2019-03-29 07:00:03 +00:00
<p>Following is the list of structural style classes, for theming classes visit <router-link to="/theming">theming</router-link> page.</p>
<div class="doc-tablewrapper">
<table class="doc-table">
<thead>
2019-05-23 08:53:40 +00:00
<tr>
<th>Name</th>
<th>Element</th>
</tr>
2019-03-29 07:00:03 +00:00
</thead>
<tbody>
2019-05-23 08:53:40 +00:00
<tr>
<td>p-panel</td>
<td>Container element.</td>
</tr>
<tr>
<td>p-panel-header</td>
2019-05-23 08:53:40 +00:00
<td>Header section.</td>
</tr>
<tr>
<td>p-panel-title</td>
<td>Title text of panel.</td>
</tr>
<tr>
<td>p-panel-header-icon</td>
<td>Action icons inside header.</td>
</tr>
<tr>
<td>p-panel-toggler</td>
2019-05-23 08:53:40 +00:00
<td>Toggle icon.</td>
</tr>
<tr>
<td>p-panel-content</td>
<td>Content of panel.</td>
</tr>
2019-03-29 07:00:03 +00:00
</tbody>
</table>
</div>
2020-06-17 19:21:22 +00:00
<h5>Dependencies</h5>
2019-03-29 07:00:03 +00:00
<p>None.</p>
</TabPanel>
<TabPanel header="Source">
2021-01-22 14:52:32 +00:00
<div class="p-d-flex p-jc-between">
<a href="https://github.com/primefaces/primevue/tree/master/src/views/panel" class="btn-viewsource" target="_blank" rel="noopener noreferrer">
<span>View on GitHub</span>
</a>
<LiveEditor name="PanelDemo" :sources="sources" :toastService="true" :components="['Menu']" />
</div>
2020-05-14 08:48:25 +00:00
2021-02-03 10:10:30 +00:00
<pre v-code><code><template v-pre>
2020-06-17 19:21:22 +00:00
&lt;h5&gt;Regular&lt;/h5&gt;
&lt;Panel header="Header"&gt;
2020-06-18 10:00:10 +00:00
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
2020-06-17 19:21:22 +00:00
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;/p&gt;
2019-08-04 12:19:34 +00:00
&lt;/Panel&gt;
2019-03-29 07:00:03 +00:00
2020-06-17 19:21:22 +00:00
&lt;h5&gt;Advanced&lt;/h5&gt;
&lt;Panel header="Header" :toggleable="true"&gt;
2020-05-14 08:48:25 +00:00
&lt;template #icons&gt;
2020-09-21 13:11:25 +00:00
&lt;button class="p-panel-header-icon p-link p-mr-2" @click="toggle"&gt;
2020-05-14 08:48:25 +00:00
&lt;span class="pi pi-cog"&gt;&lt;/span&gt;
2020-06-30 08:25:20 +00:00
&lt;/button&gt;
2020-05-14 08:48:25 +00:00
&lt;Menu id="config_menu" ref="menu" :model="items" :popup="true" /&gt;
&lt;/template&gt;
2020-06-18 10:00:10 +00:00
&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
2020-06-17 19:21:22 +00:00
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.&lt;/p&gt;
2019-08-04 12:19:34 +00:00
&lt;/Panel&gt;
2019-03-29 07:00:03 +00:00
</template>
2020-09-24 11:14:55 +00:00
</code></pre>
2020-05-14 08:48:25 +00:00
2021-02-03 10:10:30 +00:00
<pre v-code.script><code>
2020-05-14 08:48:25 +00:00
export default {
data() {
return {
items: [
{
label: 'Options',
items: [{
label: 'Update',
icon: 'pi pi-refresh',
command: () => {
this.$toast.add({severity:'success', summary:'Updated', detail:'Data Updated', life: 3000});
}
},
{
label: 'Delete',
icon: 'pi pi-times',
command: () => {
this.$toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000});
}
}
]},
{
label: 'Navigate',
items: [{
label: 'Vue Website',
icon: 'pi pi-external-link',
url: 'https://vuejs.org/'
},
{
label: 'Router',
icon: 'pi pi-upload',
to: '/fileupload'
}
]}
]
}
},
methods: {
toggle(event) {
this.$refs.menu.toggle(event);
},
save() {
this.$toast.add({severity: 'success', summary: 'Success', detail: 'Data Saved', life: 3000});
}
}
}
2020-09-24 11:14:55 +00:00
</code></pre>
2019-03-29 07:00:03 +00:00
</TabPanel>
</TabView>
</div>
2021-01-22 14:52:32 +00:00
</template>
<script>
import LiveEditor from '../liveeditor/LiveEditor';
export default {
data() {
return {
sources: {
'template': {
content: `<template>
<div class="layout-content">
2021-01-26 07:23:55 +00:00
<Toast />
2021-01-22 14:52:32 +00:00
<div class="content-section implementation">
<h5>Regular</h5>
<Panel header="Header">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</Panel>
<h5>Advanced</h5>
<Panel header="Header" :toggleable="true">
<template #icons>
<button class="p-panel-header-icon p-link p-mr-2" @click="toggle">
<span class="pi pi-cog"></span>
</button>
<Menu id="config_menu" ref="menu" :model="items" :popup="true" />
</template>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</Panel>
</div>
</div>
</template>
<script>
export default {
data() {
return {
collapsed: true,
items: [
{
label: 'Options',
items: [{
label: 'Update',
icon: 'pi pi-refresh',
command: () => {
this.$toast.add({severity:'success', summary:'Updated', detail:'Data Updated', life: 3000});
}
},
{
label: 'Delete',
icon: 'pi pi-times',
command: () => {
this.$toast.add({ severity: 'warn', summary: 'Delete', detail: 'Data Deleted', life: 3000});
}
}
]},
{
label: 'Navigate',
items: [{
label: 'Vue Website',
icon: 'pi pi-external-link',
url: 'https://vuejs.org/'
},
{
label: 'Router',
icon: 'pi pi-upload',
command: () => {
window.location.hash = "/fileupload"
}
}
]}
]
}
},
methods: {
toggle(event) {
this.$refs.menu.toggle(event);
},
save() {
this.$toast.add({severity: 'success', summary: 'Success', detail: 'Data Saved', life: 3000});
}
}
}`,
style: `<style lang="scss" scoped>
.p-panel p {
line-height: 1.5;
margin: 0;
}
</style>`
}
}
}
},
components: {
LiveEditor
}
}
</script>