add TailwindDoc to Overlays

pull/4243/head
ATAKAN TEPE 2023-08-07 12:03:52 +03:00
parent eb8687db09
commit b9e81a283f
13 changed files with 1110 additions and 6 deletions

View File

@ -0,0 +1,155 @@
<template>
<DocSectionText v-bind="$attrs">
<p>
PrimeVue offers a built-in Tailwind theme to get you started quickly. The default values related to the component are displayed below. The component can easily be styled with your own design based on Tailwind utilities, see the
<NuxtLink to="/tailwind">Tailwind Customization</NuxtLink> section for an example.
</p>
<DocSectionCode :code="code1" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
<p>A playground sample with the pre-built Tailwind theme.</p>
<DocSectionCode :code="code2" embedded />
</DocSectionText>
</template>
<script>
export default {
data() {
return {
code1: {
basic: `
export default {
dialog: {
root: ({ state }) => ({
class: [
'rounded-lg shadow-lg border-0',
'max-h-90 transform scale-100',
'm-0 w-[50vw]',
'dark:border dark:border-blue-900/40',
{
'transition-none transform-none !w-screen !h-screen !max-h-full !top-0 !left-0': state.maximized
}
]
}),
header: {
class: ['flex items-center justify-between shrink-0', 'bg-white text-gray-800 border-t-0 rounded-tl-lg rounded-tr-lg p-6', 'dark:bg-gray-900 dark:text-white/80']
},
headerTitle: 'font-bold text-lg',
headerIcons: 'flex items-center',
closeButton: {
class: [
'flex items-center justify-center overflow-hidden relative',
'w-8 h-8 text-gray-500 border-0 bg-transparent rounded-full transition duration-200 ease-in-out mr-2 last:mr-0',
'hover:text-gray-700 hover:border-transparent hover:bg-gray-200',
'focus:outline-none focus:outline-offset-0 focus:shadow-[0_0_0_0.2rem_rgba(191,219,254,1)]', // focus
'dark:hover:text-white/80 dark:hover:border-transparent dark:hover:bg-gray-800/80 dark:focus:shadow-[inset_0_0_0_0.2rem_rgba(147,197,253,0.5)]'
]
},
closeButtonIcon: 'w-4 h-4 inline-block',
content: ({ state }) => ({
class: [
'overflow-y-auto',
'bg-white text-gray-700 px-6 pb-8 pt-0',
'rounded-bl-lg rounded-br-lg',
'dark:bg-gray-900 dark:text-white/80 ',
{
grow: state.maximized
}
]
}),
footer: {
class: ['shrink-0 ', 'border-t-0 bg-white text-gray-700 px-6 pb-6 text-right rounded-b-lg', 'dark:bg-gray-900 dark:text-white/80']
},
mask: ({ props }) => ({
class: ['transition duration-200', { 'bg-black/40': props.modal }]
}),
transition: ({ props }) => {
return props.position === 'top'
? {
enterFromClass: 'opacity-0 scale-75 translate-x-0 -translate-y-full translate-z-0',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75 translate-x-0 -translate-y-full translate-z-0'
}
: props.position === 'bottom'
? {
enterFromClass: 'opacity-0 scale-75 translate-y-full',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75 translate-x-0 translate-y-full translate-z-0'
}
: props.position === 'left' || props.position === 'topleft' || props.position === 'bottomleft'
? {
enterFromClass: 'opacity-0 scale-75 -translate-x-full translate-y-0 translate-z-0',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75 -translate-x-full translate-y-0 translate-z-0'
}
: props.position === 'right' || props.position === 'topright' || props.position === 'bottomright'
? {
enterFromClass: 'opacity-0 scale-75 translate-x-full translate-y-0 translate-z-0',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75 opacity-0 scale-75 translate-x-full translate-y-0 translate-z-0'
}
: {
enterFromClass: 'opacity-0 scale-75',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75'
};
}
}
}
`
},
code2: {
composition: `
<template>
<Toast />
<ConfirmDialog></ConfirmDialog>
<div class="card flex flex-wrap gap-2 justify-center">
<Button @click="confirm1()" icon="pi pi-check" label="Confirm"></Button>
<Button @click="confirm2()" icon="pi pi-times" label="Delete"></Button>
</div>
</template>
<script setup>
import { useConfirm } from "primevue/useconfirm";
import { useToast } from "primevue/usetoast";
const confirm = useConfirm();
const toast = useToast();
const confirm1 = () => {
confirm.require({
message: 'Are you sure you want to proceed?',
header: 'Confirmation',
icon: 'pi pi-exclamation-triangle',
accept: () => {
toast.add({ severity: 'info', summary: 'Confirmed', detail: 'You have accepted', life: 3000 });
},
reject: () => {
toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
}
});
};
const confirm2 = () => {
confirm.require({
message: 'Do you want to delete this record?',
header: 'Delete Confirmation',
icon: 'pi pi-info-circle',
acceptClass: 'p-button-danger',
accept: () => {
toast.add({ severity: 'info', summary: 'Confirmed', detail: 'Record deleted', life: 3000 });
},
reject: () => {
toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
}
});
};
<\/script>`
}
};
}
};
</script>

View File

@ -10,6 +10,7 @@
<script> <script>
import StyledDoc from './StyledDoc.vue'; import StyledDoc from './StyledDoc.vue';
import TailwindDoc from './TailwindDoc.vue';
import UnstyledDoc from './UnstyledDoc.vue'; import UnstyledDoc from './UnstyledDoc.vue';
export default { export default {
@ -24,7 +25,15 @@ export default {
{ {
id: 'unstyled', id: 'unstyled',
label: 'Unstyled', label: 'Unstyled',
component: UnstyledDoc component: UnstyledDoc,
description: 'Theming is implemented with the pass through properties in unstyled mode.',
children: [
{
id: 'tailwind',
label: 'Tailwind',
component: TailwindDoc
}
]
} }
] ]
}; };

View File

@ -0,0 +1,106 @@
<template>
<DocSectionText v-bind="$attrs">
<p>
PrimeVue offers a built-in Tailwind theme to get you started quickly. The default values related to the component are displayed below. The component can easily be styled with your own design based on Tailwind utilities, see the
<NuxtLink to="/tailwind">Tailwind Customization</NuxtLink> section for an example.
</p>
<DocSectionCode :code="code1" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
<p>A playground sample with the pre-built Tailwind theme.</p>
<DocSectionCode :code="code2" embedded />
</DocSectionText>
</template>
<script>
export default {
data() {
return {
code1: {
basic: `
export const TRANSITIONS = {
toggleable: {
enterFromClass: 'max-h-0',
enterActiveClass: 'overflow-hidden transition-all duration-500 ease-in-out',
enterToClass: 'max-h-40 ',
leaveFromClass: 'max-h-40',
leaveActiveClass: 'overflow-hidden transition-all duration-500 ease-in',
leaveToClass: 'max-h-0'
},
overlay: {
enterFromClass: 'opacity-0 scale-75',
enterActiveClass: 'transition-transform transition-opacity duration-150 ease-in',
leaveActiveClass: 'transition-opacity duration-150 ease-linear',
leaveToClass: 'opacity-0'
}
};
export default {
confirmpopup: {
root: {
class: [
'bg-white text-gray-700 border-0 rounded-md shadow-lg',
'z-40 transform origin-center',
'mt-3 absolute left-0 top-0',
'before:absolute before:w-0 before:-top-3 before:h-0 before:border-transparent before:border-solid before:ml-6 before:border-x-[0.75rem] before:border-b-[0.75rem] before:border-t-0 before:border-b-white dark:before:border-b-gray-900',
'dark:border dark:border-blue-900/40 dark:bg-gray-900 dark:text-white/80'
]
},
content: 'p-5 items-center flex',
icon: 'text-2xl',
message: 'ml-4',
footer: 'text-right px-5 py-5 pt-0 ',
transition: TRANSITIONS.overlay
}
}
`
},
code2: {
composition: `
<template>
<Toast />
<ConfirmPopup></ConfirmPopup>
<div class="card flex flex-wrap gap-2 justify-center">
<Button @click="confirm1($event)" icon="pi pi-check" label="Confirm"></Button>
<Button @click="confirm2($event)" icon="pi pi-times" label="Delete" outlined severity="danger"></Button>
</div>
</template>
<script setup>
import { useConfirm } from "primevue/useconfirm";
import { useToast } from "primevue/usetoast";
const confirm = useConfirm();
const toast = useToast();
const confirm1 = (event) => {
confirm.require({
target: event.currentTarget,
message: 'Are you sure you want to proceed?',
icon: 'pi pi-exclamation-triangle',
accept: () => {
toast.add({ severity: 'info', summary: 'Confirmed', detail: 'You have accepted', life: 3000 });
},
reject: () => {
toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
}
});
};
const confirm2 = (event) => {
confirm.require({
target: event.currentTarget,
message: 'Do you want to delete this record?',
icon: 'pi pi-info-circle',
acceptClass: 'p-button-danger',
accept: () => {
toast.add({ severity: 'info', summary: 'Confirmed', detail: 'Record deleted', life: 3000 });
},
reject: () => {
toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
}
});
};
<\/script>`
}
};
}
};
</script>

View File

@ -10,6 +10,7 @@
<script> <script>
import StyledDoc from './StyledDoc.vue'; import StyledDoc from './StyledDoc.vue';
import TailwindDoc from './TailwindDoc.vue';
import UnstyledDoc from './UnstyledDoc.vue'; import UnstyledDoc from './UnstyledDoc.vue';
export default { export default {
@ -24,7 +25,15 @@ export default {
{ {
id: 'unstyled', id: 'unstyled',
label: 'Unstyled', label: 'Unstyled',
component: UnstyledDoc component: UnstyledDoc,
description: 'Theming is implemented with the pass through properties in unstyled mode.',
children: [
{
id: 'tailwind',
label: 'Tailwind',
component: TailwindDoc
}
]
} }
] ]
}; };

View File

@ -0,0 +1,127 @@
<template>
<DocSectionText v-bind="$attrs">
<p>
PrimeVue offers a built-in Tailwind theme to get you started quickly. The default values related to the component are displayed below. The component can easily be styled with your own design based on Tailwind utilities, see the
<NuxtLink to="/tailwind">Tailwind Customization</NuxtLink> section for an example.
</p>
<DocSectionCode :code="code1" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
<p>A playground sample with the pre-built Tailwind theme.</p>
<DocSectionCode :code="code2" embedded />
</DocSectionText>
</template>
<script>
export default {
data() {
return {
code1: {
basic: `
export default {
dialog: {
root: ({ state }) => ({
class: [
'rounded-lg shadow-lg border-0',
'max-h-90 transform scale-100',
'm-0 w-[50vw]',
'dark:border dark:border-blue-900/40',
{
'transition-none transform-none !w-screen !h-screen !max-h-full !top-0 !left-0': state.maximized
}
]
}),
header: {
class: ['flex items-center justify-between shrink-0', 'bg-white text-gray-800 border-t-0 rounded-tl-lg rounded-tr-lg p-6', 'dark:bg-gray-900 dark:text-white/80']
},
headerTitle: 'font-bold text-lg',
headerIcons: 'flex items-center',
closeButton: {
class: [
'flex items-center justify-center overflow-hidden relative',
'w-8 h-8 text-gray-500 border-0 bg-transparent rounded-full transition duration-200 ease-in-out mr-2 last:mr-0',
'hover:text-gray-700 hover:border-transparent hover:bg-gray-200',
'focus:outline-none focus:outline-offset-0 focus:shadow-[0_0_0_0.2rem_rgba(191,219,254,1)]', // focus
'dark:hover:text-white/80 dark:hover:border-transparent dark:hover:bg-gray-800/80 dark:focus:shadow-[inset_0_0_0_0.2rem_rgba(147,197,253,0.5)]'
]
},
closeButtonIcon: 'w-4 h-4 inline-block',
content: ({ state }) => ({
class: [
'overflow-y-auto',
'bg-white text-gray-700 px-6 pb-8 pt-0',
'rounded-bl-lg rounded-br-lg',
'dark:bg-gray-900 dark:text-white/80 ',
{
grow: state.maximized
}
]
}),
footer: {
class: ['shrink-0 ', 'border-t-0 bg-white text-gray-700 px-6 pb-6 text-right rounded-b-lg', 'dark:bg-gray-900 dark:text-white/80']
},
mask: ({ props }) => ({
class: ['transition duration-200', { 'bg-black/40': props.modal }]
}),
transition: ({ props }) => {
return props.position === 'top'
? {
enterFromClass: 'opacity-0 scale-75 translate-x-0 -translate-y-full translate-z-0',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75 translate-x-0 -translate-y-full translate-z-0'
}
: props.position === 'bottom'
? {
enterFromClass: 'opacity-0 scale-75 translate-y-full',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75 translate-x-0 translate-y-full translate-z-0'
}
: props.position === 'left' || props.position === 'topleft' || props.position === 'bottomleft'
? {
enterFromClass: 'opacity-0 scale-75 -translate-x-full translate-y-0 translate-z-0',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75 -translate-x-full translate-y-0 translate-z-0'
}
: props.position === 'right' || props.position === 'topright' || props.position === 'bottomright'
? {
enterFromClass: 'opacity-0 scale-75 translate-x-full translate-y-0 translate-z-0',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75 opacity-0 scale-75 translate-x-full translate-y-0 translate-z-0'
}
: {
enterFromClass: 'opacity-0 scale-75',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75'
};
}
}
}
`
},
code2: {
composition: `
<template>
<div class="card flex justify-center">
<Button label="Show" icon="pi pi-external-link" @click="visible = true" />
<Dialog v-model:visible="visible" modal header="Header" :style="{ width: '50vw' }">
<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>
</Dialog>
</div>
</template>
<script setup>
import { ref } from "vue";
const visible = ref(false);
<\/script>`
}
};
}
};
</script>

View File

@ -10,6 +10,7 @@
<script> <script>
import StyledDoc from './StyledDoc.vue'; import StyledDoc from './StyledDoc.vue';
import TailwindDoc from './TailwindDoc.vue';
import UnstyledDoc from './UnstyledDoc.vue'; import UnstyledDoc from './UnstyledDoc.vue';
export default { export default {
@ -24,7 +25,15 @@ export default {
{ {
id: 'unstyled', id: 'unstyled',
label: 'Unstyled', label: 'Unstyled',
component: UnstyledDoc component: UnstyledDoc,
description: 'Theming is implemented with the pass through properties in unstyled mode.',
children: [
{
id: 'tailwind',
label: 'Tailwind',
component: TailwindDoc
}
]
} }
] ]
}; };

View File

@ -0,0 +1,393 @@
<template>
<DocSectionText v-bind="$attrs">
<p>
PrimeVue offers a built-in Tailwind theme to get you started quickly. The default values related to the component are displayed below. The component can easily be styled with your own design based on Tailwind utilities, see the
<NuxtLink to="/tailwind">Tailwind Customization</NuxtLink> section for an example.
</p>
<DocSectionCode :code="code1" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
<p>A playground sample with the pre-built Tailwind theme.</p>
<DocSectionCode :code="code2" embedded />
</DocSectionText>
</template>
<script>
export default {
data() {
return {
code1: {
basic: `
export default {
dialog: {
root: ({ state }) => ({
class: [
'rounded-lg shadow-lg border-0',
'max-h-90 transform scale-100',
'm-0 w-[50vw]',
'dark:border dark:border-blue-900/40',
{
'transition-none transform-none !w-screen !h-screen !max-h-full !top-0 !left-0': state.maximized
}
]
}),
header: {
class: ['flex items-center justify-between shrink-0', 'bg-white text-gray-800 border-t-0 rounded-tl-lg rounded-tr-lg p-6', 'dark:bg-gray-900 dark:text-white/80']
},
headerTitle: 'font-bold text-lg',
headerIcons: 'flex items-center',
closeButton: {
class: [
'flex items-center justify-center overflow-hidden relative',
'w-8 h-8 text-gray-500 border-0 bg-transparent rounded-full transition duration-200 ease-in-out mr-2 last:mr-0',
'hover:text-gray-700 hover:border-transparent hover:bg-gray-200',
'focus:outline-none focus:outline-offset-0 focus:shadow-[0_0_0_0.2rem_rgba(191,219,254,1)]', // focus
'dark:hover:text-white/80 dark:hover:border-transparent dark:hover:bg-gray-800/80 dark:focus:shadow-[inset_0_0_0_0.2rem_rgba(147,197,253,0.5)]'
]
},
closeButtonIcon: 'w-4 h-4 inline-block',
content: ({ state }) => ({
class: [
'overflow-y-auto',
'bg-white text-gray-700 px-6 pb-8 pt-0',
'rounded-bl-lg rounded-br-lg',
'dark:bg-gray-900 dark:text-white/80 ',
{
grow: state.maximized
}
]
}),
footer: {
class: ['shrink-0 ', 'border-t-0 bg-white text-gray-700 px-6 pb-6 text-right rounded-b-lg', 'dark:bg-gray-900 dark:text-white/80']
},
mask: ({ props }) => ({
class: ['transition duration-200', { 'bg-black/40': props.modal }]
}),
transition: ({ props }) => {
return props.position === 'top'
? {
enterFromClass: 'opacity-0 scale-75 translate-x-0 -translate-y-full translate-z-0',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75 translate-x-0 -translate-y-full translate-z-0'
}
: props.position === 'bottom'
? {
enterFromClass: 'opacity-0 scale-75 translate-y-full',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75 translate-x-0 translate-y-full translate-z-0'
}
: props.position === 'left' || props.position === 'topleft' || props.position === 'bottomleft'
? {
enterFromClass: 'opacity-0 scale-75 -translate-x-full translate-y-0 translate-z-0',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75 -translate-x-full translate-y-0 translate-z-0'
}
: props.position === 'right' || props.position === 'topright' || props.position === 'bottomright'
? {
enterFromClass: 'opacity-0 scale-75 translate-x-full translate-y-0 translate-z-0',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75 opacity-0 scale-75 translate-x-full translate-y-0 translate-z-0'
}
: {
enterFromClass: 'opacity-0 scale-75',
enterActiveClass: 'transition-all duration-200 ease-out',
leaveActiveClass: 'transition-all duration-200 ease-out',
leaveToClass: 'opacity-0 scale-75'
};
}
}
}
`
},
code2: {
composition: `
<template>
<div class="card flex justify-center">
<Button label="Select a Product" icon="pi pi-search" @click="showProducts" />
<Toast />
<DynamicDialog />
</div>
</template>
<script setup>
import { markRaw, defineAsyncComponent } from 'vue';
import { useDialog } from 'primevue/usedialog';
import { useToast } from 'primevue/usetoast';
import Button from 'primevue/button';
const ProductListDemo = defineAsyncComponent(() => import('./components/ProductListDemo.vue'));
const FooterDemo = defineAsyncComponent(() => import('./components/FooterDemo.vue'));
const dialog = useDialog();
const toast = useToast();
const showProducts = () => {
const dialogRef = dialog.open(ProductListDemo, {
props: {
header: 'Product List',
style: {
width: '50vw',
},
breakpoints:{
'960px': '75vw',
'640px': '90vw'
},
modal: true
},
templates: {
footer: markRaw(FooterDemo)
},
onClose: (options) => {
const data = options.data;
if (data) {
const buttonType = data.buttonType;
const summary_and_detail = buttonType ? { summary: 'No Product Selected', detail: \`Pressed '\${buttonType}' button\` } : { summary: 'Product Selected', detail: data.name };
toast.add({ severity:'info', ...summary_and_detail, life: 3000 });
}
}
});
}
<\/script>`,
data: `
/* ProductService */
{
id: '1000',
code: 'f230fh0g3',
name: 'Bamboo Watch',
description: 'Product Description',
image: 'bamboo-watch.jpg',
price: 65,
category: 'Accessories',
quantity: 24,
inventoryStatus: 'INSTOCK',
rating: 5
},
...`
},
extFiles: {
options: {
'src/components/ProductListDemo.vue': {
content: `
<template>
<div>
<div class="flex justify-content-end mt-1 mb-3">
<Button icon="pi pi-external-link" label="Nested Dialog" outlined severity="success" @click="showInfo" />
</div>
<DataTable :value="products">
<Column field="code" header="Code"></Column>
<Column field="name" header="Name"></Column>
<Column header="Image">
<template #body="slotProps">
<img :src="'https://primefaces.org/cdn/primevue/images/product/' + slotProps.data.image" :alt="slotProps.data.name" class="shadow-2 w-4rem" />
</template>
</Column>
<Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column>
<Column style="width:5rem">
<template #body="slotProps">
<Button type="button" icon="pi pi-plus" text rounded @click="selectProduct(slotProps.data)"></Button>
</template>
</Column>
</DataTable>
</div>
</template>
<script>
import { ProductService } from '@/service/ProductService';
import InfoDemo from './InfoDemo.vue';
export default {
inject: ['dialogRef'],
data() {
return {
products: null
}
},
mounted() {
ProductService.getProductsSmall().then(data => this.products = data.slice(0,5));
},
methods: {
selectProduct(data) {
this.dialogRef.close(data);
},
showInfo() {
this.$dialog.open(InfoDemo, {
props: {
header: 'Information',
modal: true,
dismissableMask: true
},
data: {
totalProducts: this.products ? this.products.length : 0
}
});
}
}
}
<\/script>`
},
'src/components/InfoDemo.vue': {
content: `
<template>
<div>
<p>There are <strong>{{totalProducts}}</strong> products in total in this list.</p>
<div class="flex justify-content-end">
<Button type="button" label="Close" @click="closeDialog"></Button>
</div>
</div>
</template>
<script>
export default {
inject: ['dialogRef'],
data() {
return {
totalProducts: 0
}
},
mounted() {
this.totalProducts = this.dialogRef.data.totalProducts;
},
methods: {
closeDialog() {
this.dialogRef.close();
}
}
}
<\/script>
`
},
'src/components/FooterDemo.vue': {
content: `
<template>
<Button type="button" label="No" icon="pi pi-times" @click="closeDialog({ buttonType: 'No' })" text></Button>
<Button type="button" label="Yes" icon="pi pi-check" @click="closeDialog({ buttonType: 'Yes' })" autofocus></Button>
</template>
<script>
export default {
inject: ['dialogRef'],
methods: {
closeDialog(e) {
this.dialogRef.close(e);
}
}
};
<\/script>`
}
},
composition: {
'src/components/ProductListDemo.vue': {
content: `
<template>
<div>
<div class="flex justify-end mt-1 mb-3">
<Button icon="pi pi-external-link" label="Nested Dialog" outlined severity="success" @click="showInfo" />
</div>
<DataTable :value="products">
<Column field="code" header="Code"></Column>
<Column field="name" header="Name"></Column>
<Column header="Image">
<template #body="slotProps">
<img :src="'https://primefaces.org/cdn/primevue/images/product/' + slotProps.data.image" :alt="slotProps.data.name" class="shadow-2 w-4rem" />
</template>
</Column>
<Column field="category" header="Category"></Column>
<Column field="quantity" header="Quantity"></Column>
<Column style="width:5rem">
<template #body="slotProps">
<Button type="button" icon="pi pi-plus" text rounded @click="selectProduct(slotProps.data)"></Button>
</template>
</Column>
</DataTable>
</div>
</template>
<script setup>
import { ref, onMounted, inject } from "vue";
import { useDialog } from "primevue/usedialog";
import { ProductService } from "@/service/ProductService";
import InfoDemo from "./InfoDemo.vue";
const dialogRef = inject("dialogRef");
const dialog = useDialog();
const products = ref(null);
onMounted(() => {
ProductService
.getProductsSmall()
.then((data) => (products.value = data.slice(0, 5)));
});
const selectProduct = (data) => {
dialogRef.value.close(data);
};
const showInfo = () => {
dialog.open(InfoDemo, {
props: {
header: "Information",
modal: true,
dismissableMask: true,
},
data: {
totalProducts: products.value ? products.value.length : 0,
}
});
};
<\/script>`
},
'src/components/InfoDemo.vue': {
content: `
<template>
<div>
<p>There are <strong>{{totalProducts}}</strong> products in total in this list.</p>
<div class="flex justify-end">
<Button type="button" label="Close" @click="closeDialog"></Button>
</div>
</div>
</template>
<script setup>
import { ref, onMounted, inject } from "vue";
const totalProducts = ref(0);
const dialogRef = inject("dialogRef");
onMounted(() => {
totalProducts.value = dialogRef.value.data.totalProducts;
});
const closeDialog = () => {
dialogRef.value.close();
};
<\/script>
`
},
'src/components/FooterDemo.vue': {
content: `
<template>
<Button type="button" label="No" icon="pi pi-times" @click="closeDialog({ buttonType: 'No' })" text></Button>
<Button type="button" label="Yes" icon="pi pi-check" @click="closeDialog({ buttonType: 'Yes' })" autofocus></Button>
</template>
<script setup>
import { inject } from "vue";
const dialogRef = inject("dialogRef");
const closeDialog = (e) => {
dialogRef.value.close(e);
};
<\/script>`
}
}
}
};
}
};
</script>

View File

@ -9,6 +9,7 @@
</template> </template>
<script> <script>
import TailwindDoc from './TailwindDoc.vue';
import UnstyledDoc from './UnstyledDoc.vue'; import UnstyledDoc from './UnstyledDoc.vue';
export default { export default {
@ -18,7 +19,15 @@ export default {
{ {
id: 'unstyled', id: 'unstyled',
label: 'Unstyled', label: 'Unstyled',
component: UnstyledDoc component: UnstyledDoc,
description: 'Theming is implemented with the pass through properties in unstyled mode.',
children: [
{
id: 'tailwind',
label: 'Tailwind',
component: TailwindDoc
}
]
} }
] ]
}; };

View File

@ -0,0 +1,76 @@
<template>
<DocSectionText v-bind="$attrs">
<p>
PrimeVue offers a built-in Tailwind theme to get you started quickly. The default values related to the component are displayed below. The component can easily be styled with your own design based on Tailwind utilities, see the
<NuxtLink to="/tailwind">Tailwind Customization</NuxtLink> section for an example.
</p>
<DocSectionCode :code="code1" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
<p>A playground sample with the pre-built Tailwind theme.</p>
<DocSectionCode :code="code2" embedded />
</DocSectionText>
</template>
<script>
export default {
data() {
return {
code1: {
basic: `
export const TRANSITIONS = {
toggleable: {
enterFromClass: 'max-h-0',
enterActiveClass: 'overflow-hidden transition-all duration-500 ease-in-out',
enterToClass: 'max-h-40 ',
leaveFromClass: 'max-h-40',
leaveActiveClass: 'overflow-hidden transition-all duration-500 ease-in',
leaveToClass: 'max-h-0'
},
overlay: {
enterFromClass: 'opacity-0 scale-75',
enterActiveClass: 'transition-transform transition-opacity duration-150 ease-in',
leaveActiveClass: 'transition-opacity duration-150 ease-linear',
leaveToClass: 'opacity-0'
}
};
export default {
overlaypanel: {
root: {
class: [
'bg-white text-gray-700 border-0 rounded-md shadow-lg',
'z-40 transform origin-center',
'absolute left-0 top-0',
'before:absolute before:w-0 before:-top-3 before:h-0 before:border-transparent before:border-solid before:ml-6 before:border-x-[0.75rem] before:border-b-[0.75rem] before:border-t-0 before:border-b-white dark:before:border-b-gray-900',
'dark:border dark:border-blue-900/40 dark:bg-gray-900 dark:text-white/80'
]
},
content: 'p-5 items-center flex',
transition: TRANSITIONS.overlay
}
}
`
},
code2: {
composition: `
<template>
<div class="card flex justify-center">
<Button type="button" icon="pi pi-image" label="Image" @click="toggle" />
<OverlayPanel ref="op">
<img src="https://primefaces.org/cdn/primevue/images/product/bamboo-watch.jpg" alt="Bamboo Watch" />
</OverlayPanel>
</div>
</template>
<script setup>
import { ref } from "vue";
const op = ref();
const toggle = (event) => {
op.value.toggle(event);
}
<\/script>`
}
};
}
};
</script>

View File

@ -10,6 +10,7 @@
<script> <script>
import StyledDoc from './StyledDoc.vue'; import StyledDoc from './StyledDoc.vue';
import TailwindDoc from './TailwindDoc.vue';
import UnstyledDoc from './UnstyledDoc.vue'; import UnstyledDoc from './UnstyledDoc.vue';
export default { export default {
@ -24,7 +25,15 @@ export default {
{ {
id: 'unstyled', id: 'unstyled',
label: 'Unstyled', label: 'Unstyled',
component: UnstyledDoc component: UnstyledDoc,
description: 'Theming is implemented with the pass through properties in unstyled mode.',
children: [
{
id: 'tailwind',
label: 'Tailwind',
component: TailwindDoc
}
]
} }
] ]
}; };

View File

@ -0,0 +1,129 @@
<template>
<DocSectionText v-bind="$attrs">
<p>
PrimeVue offers a built-in Tailwind theme to get you started quickly. The default values related to the component are displayed below. The component can easily be styled with your own design based on Tailwind utilities, see the
<NuxtLink to="/tailwind">Tailwind Customization</NuxtLink> section for an example.
</p>
<DocSectionCode :code="code1" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
<p>A playground sample with the pre-built Tailwind theme.</p>
<DocSectionCode :code="code2" embedded />
</DocSectionText>
</template>
<script>
export default {
data() {
return {
code1: {
basic: `
export default {
sidebar: {
root: ({ props }) => ({
class: [
'flex flex-col pointer-events-auto relative transform translate-x-0 translate-y-0 translate-z-0 relative transition-transform duration-300',
'bg-white text-gray-700 border-0 shadow-lg',
{
'!transition-none !transform-none !w-screen !h-screen !max-h-full !top-0 !left-0': props.position == 'full',
'h-full w-80': props.position == 'left' || props.position == 'right',
'h-40 w-full': props.position == 'top' || props.position == 'bottom'
},
'dark:border dark:border-blue-900/40 dark:bg-gray-900 dark:text-white/80'
]
}),
header: {
class: ['flex items-center justify-end', 'p-5']
},
closeButton: {
class: [
'flex items-center justify-center overflow-hidden relative',
'w-8 h-8 text-gray-500 border-0 bg-transparent rounded-full transition duration-200 ease-in-out mr-2 last:mr-0',
'hover:text-gray-700 hover:border-transparent hover:bg-gray-200',
'focus:outline-none focus:outline-offset-0 focus:shadow-[0_0_0_0.2rem_rgba(191,219,254,1)]', // focus
'dark:hover:text-white/80 dark:hover:text-white/80 dark:hover:border-transparent dark:hover:bg-gray-800/80 dark:focus:shadow-[inset_0_0_0_0.2rem_rgba(147,197,253,0.5)]'
]
},
closeButtonIcon: 'w-4 h-4 inline-block',
content: {
class: ['p-5 pt-0 h-full w-full', 'grow overflow-y-auto']
},
mask: {
class: ['flex pointer-events-auto', 'bg-black bg-opacity-40 transition duration-200 z-20 transition-colors']
},
transition: ({ props }) => {
return props.position === 'top'
? {
enterFromClass: 'translate-x-0 -translate-y-full translate-z-0',
leaveToClass: 'translate-x-0 -translate-y-full translate-z-0'
}
: props.position === 'bottom'
? {
enterFromClass: 'translate-x-0 translate-y-full translate-z-0',
leaveToClass: 'translate-x-0 translate-y-full translate-z-0'
}
: props.position === 'left'
? {
enterFromClass: '-translate-x-full translate-y-0 translate-z-0',
leaveToClass: '-translate-x-full translate-y-0 translate-z-0'
}
: props.position === 'right'
? {
enterFromClass: 'translate-x-full translate-y-0 translate-z-0',
leaveToClass: 'opacity-0 scale-75 translate-x-full translate-y-0 translate-z-0'
}
: {
enterFromClass: 'opacity-0',
enterActiveClass: 'transition-opacity duration-400 ease-in',
leaveActiveClass: 'transition-opacity duration-400 ease-in',
leaveToClass: 'opacity-0'
};
}
}
}
`
},
code2: {
composition: `
<template>
<div class="card">
<div class="flex gap-2 justify-center">
<Button icon="pi pi-arrow-right" @click="visibleLeft = true" />
<Button icon="pi pi-arrow-left" @click="visibleRight = true" />
<Button icon="pi pi-arrow-down" @click="visibleTop = true" />
<Button icon="pi pi-arrow-up" @click="visibleBottom = true" />
</div>
<Sidebar v-model:visible="visibleLeft">
<h2>Left Sidebar</h2>
<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.</p>
</Sidebar>
<Sidebar v-model:visible="visibleRight" position="right">
<h2>Right Sidebar</h2>
<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.</p>
</Sidebar>
<Sidebar v-model:visible="visibleTop" position="top">
<h2>Top Sidebar</h2>
<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.</p>
</Sidebar>
<Sidebar v-model:visible="visibleBottom" position="bottom">
<h2>Bottom Sidebar</h2>
<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.</p>
</Sidebar>
</div>
</template>
<script setup>
import { ref } from "vue";
const visibleLeft = ref(false);
const visibleRight = ref(false);
const visibleTop = ref(false);
const visibleBottom = ref(false);
<\/script>`
}
};
}
};
</script>

View File

@ -10,6 +10,7 @@
<script> <script>
import StyledDoc from './StyledDoc.vue'; import StyledDoc from './StyledDoc.vue';
import TailwindDoc from './TailwindDoc.vue';
import UnstyledDoc from './UnstyledDoc.vue'; import UnstyledDoc from './UnstyledDoc.vue';
export default { export default {
@ -24,7 +25,15 @@ export default {
{ {
id: 'unstyled', id: 'unstyled',
label: 'Unstyled', label: 'Unstyled',
component: UnstyledDoc component: UnstyledDoc,
description: 'Theming is implemented with the pass through properties in unstyled mode.',
children: [
{
id: 'tailwind',
label: 'Tailwind',
component: TailwindDoc
}
]
} }
] ]
}; };

View File

@ -0,0 +1,64 @@
<template>
<DocSectionText v-bind="$attrs">
<p>
PrimeVue offers a built-in Tailwind theme to get you started quickly. The default values related to the component are displayed below. The component can easily be styled with your own design based on Tailwind utilities, see the
<NuxtLink to="/tailwind">Tailwind Customization</NuxtLink> section for an example.
</p>
<DocSectionCode :code="code1" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
<p>A playground sample with the pre-built Tailwind theme.</p>
<DocSectionCode :code="code2" embedded />
</DocSectionText>
</template>
<script>
export default {
data() {
return {
code1: {
basic: `
export default {
directives: {
tooltip: {
root: ({ context }) => ({
class: [
'absolute shadow-md',
{
'py-0 px-1': context?.right || context?.left || (!context?.right && !context?.left && !context?.top && !context?.bottom),
'py-1 px-0': context?.top || context?.bottom
}
]
}),
arrow: ({ context }) => ({
class: [
'absolute w-0 h-0 border-transparent border-solid',
{
'-m-t-1 border-y-[0.25rem] border-r-[0.25rem] border-l-0 border-r-gray-600': context?.right || (!context?.right && !context?.left && !context?.top && !context?.bottom),
'-m-t-1 border-y-[0.25rem] border-l-[0.25rem] border-r-0 border-l-gray-600': context?.left,
'-m-l-1 border-x-[0.25rem] border-t-[0.25rem] border-b-0 border-t-gray-600': context?.top,
'-m-l-1 border-x-[0.25rem] border-b-[0.25rem] border-t-0 border-b-gray-600': context?.bottom
}
]
}),
text: {
class: 'p-3 bg-gray-600 text-white rounded-md whitespace-pre-line break-words'
}
}
}
}
`
},
code2: {
composition: `
<template>
<div class="card flex flex-wrap justify-center gap-2">
<InputText v-tooltip="'Enter your username'" type="text" placeholder="Right" />
<InputText v-tooltip.top="'Enter your username'" type="text" placeholder="Top" />
<InputText v-tooltip.bottom="'Enter your username'" type="text" placeholder="Bottom" />
<InputText v-tooltip.left="'Enter your username'" type="text" placeholder="Left" />
</div>
</template>`
}
};
}
};
</script>