primevue-mirror/doc/orderlist/theming/TailwindDoc.vue

155 lines
6.8 KiB
Vue

<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
<PrimeVueNuxtLink to="/tailwind">Tailwind Customization</PrimeVueNuxtLink> 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" :service="['ProductService']" embedded />
</DocSectionText>
</template>
<script>
export default {
data() {
return {
code1: {
basic: `
export default {
orderlist: {
root: 'flex',
controls: 'flex flex-col justify-center p-5',
moveupbutton: {
root: ({ context }) => ({
class: [
'relative inline-flex cursor-pointer user-select-none items-center align-bottom text-center overflow-hidden m-0', // button component
'text-white bg-blue-500 border border-blue-500 rounded-md',
'transition duration-200 ease-in-out',
'justify-center px-0 py-3', // icon only
'mb-2', // orderlist button
'dark:bg-sky-300 dark:border-sky-300 dark:text-gray-900', //Dark Mode
{
'cursor-default pointer-events-none opacity-60': context.disabled
}
]
}),
label: 'flex-initial w-0'
},
movetopbutton: {
root: ({ context }) => ({
class: [
'relative inline-flex cursor-pointer user-select-none items-center align-bottom text-center overflow-hidden m-0', // button component
'text-white bg-blue-500 border border-blue-500 rounded-md',
'transition duration-200 ease-in-out',
'justify-center px-0 py-3', // icon only
'mb-2', // orderlist button
'dark:bg-sky-300 dark:border-sky-300 dark:text-gray-900', //Dark Mode
{
'cursor-default pointer-events-none opacity-60': context.disabled
}
]
}),
label: 'flex-initial w-0'
},
movedownbutton: {
root: ({ context }) => ({
class: [
'relative inline-flex cursor-pointer user-select-none items-center align-bottom text-center overflow-hidden m-0', // button component
'text-white bg-blue-500 border border-blue-500 rounded-md',
'transition duration-200 ease-in-out',
'justify-center px-0 py-3', // icon only
'mb-2', // orderlist button
'dark:bg-sky-300 dark:border-sky-300 dark:text-gray-900', //Dark Mode
{
'cursor-default pointer-events-none opacity-60': context.disabled
}
]
}),
label: 'flex-initial w-0'
},
movebottombutton: {
root: ({ context }) => ({
class: [
'relative inline-flex cursor-pointer user-select-none items-center align-bottom text-center overflow-hidden m-0', // button component
'text-white bg-blue-500 border border-blue-500 rounded-md',
'transition duration-200 ease-in-out',
'justify-center px-0 py-3', // icon only
'mb-2', // orderlist button
'dark:bg-sky-300 dark:border-sky-300 dark:text-gray-900', //Dark Mode
{
'cursor-default pointer-events-none opacity-60': context.disabled
}
]
}),
label: 'flex-initial w-0'
},
container: 'flex-auto',
header: {
class: [
'bg-slate-50 text-slate-700 border border-gray-300 p-5 font-bold border-b-0 rounded-t-md',
'dark:bg-gray-900 dark:text-white/80 dark:border-blue-900/40' //Dark Mode
]
},
list: {
class: [
'list-none m-0 p-0 overflow-auto min-h-[12rem] max-h-[24rem]',
'border border-gray-300 bg-white text-gray-600 py-3 px-0 rounded-b-md outline-none',
'dark:border-blue-900/40 dark:bg-gray-900 dark:text-white/80' //Dark Mode
]
},
item: ({ context }) => ({
class: [
'relative cursor-pointer overflow-hidden',
'py-3 px-5 m-0 border-none text-gray-600 dark:text-white/80',
'transition duration-200',
{
'text-blue-700 bg-blue-500/20 dark:bg-blue-300/20': context.active && !context.focused,
'text-blue-700 bg-blue-500/30 dark:bg-blue-300/30': context.active && context.focused,
'text-gray-600 bg-gray-300 dark:bg-blue-900/40': !context.active && context.focused
}
]
})
}
}
`
},
code2: {
composition: `
<template>
<div class="card xl:flex xl:justify-center">
<OrderList v-model="products" listStyle="height:auto" dataKey="id">
<template #header> List of Products </template>
<template #item="slotProps">
<div class="flex flex-wrap p-2 items-center gap-3">
<img class="w-16 shadow-md shrink-0 rounded" :src="'https://primefaces.org/cdn/primevue/images/product/' + slotProps.item.image" :alt="slotProps.item.name" />
<div class="flex-1 flex flex-col gap-2">
<span class="font-bold text-gray-700 dark:text-white/80">{{ slotProps.item.name }}</span>
<div class="flex items-center gap-2">
<i class="pi pi-tag text-sm text-gray-700 dark:text-white/80"></i>
<span class="text-gray-700 dark:text-white/80">{{ slotProps.item.category }}</span>
</div>
</div>
<span class="font-bold text-gray-700 dark:text-white/80">$ {{ slotProps.item.price }}</span>
</div>
</template>
</OrderList>
</div>
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { ProductService } from '@/service/ProductService'
const products = ref(null);
onMounted(() => {
ProductService.getProductsSmall().then((data) => (products.value = data));
});
<\/script>`
}
};
}
};
</script>