This repository has been archived on 2024-04-04. You can view files and clone it, but cannot push or open issues or pull requests.
tailwindui/vue/components/application-ui/page-examples/detail-screens/stacked.vue

424 lines
22 KiB
Vue
Raw Normal View History

2024-01-24 19:02:44 +08:00
<!--
This example requires some changes to your config:
```
// tailwind.config.js
module.exports = {
// ...
plugins: [
// ...
require('@tailwindcss/forms'),
],
}
```
-->
<template>
<header class="absolute inset-x-0 top-0 z-50 flex h-16 border-b border-gray-900/10">
<div class="mx-auto flex w-full max-w-7xl items-center justify-between px-4 sm:px-6 lg:px-8">
<div class="flex flex-1 items-center gap-x-6">
<button type="button" class="-m-3 p-3 md:hidden" @click="mobileMenuOpen = true">
<span class="sr-only">Open main menu</span>
<Bars3Icon class="h-5 w-5 text-gray-900" aria-hidden="true" />
</button>
<img class="h-8 w-auto" src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600" alt="Your Company" />
</div>
<nav class="hidden md:flex md:gap-x-11 md:text-sm md:font-semibold md:leading-6 md:text-gray-700">
<a v-for="(item, itemIdx) in navigation" :key="itemIdx" :href="item.href">{{ item.name }}</a>
</nav>
<div class="flex flex-1 items-center justify-end gap-x-8">
<button type="button" class="-m-2.5 p-2.5 text-gray-400 hover:text-gray-500">
<span class="sr-only">View notifications</span>
<BellIcon class="h-6 w-6" aria-hidden="true" />
</button>
<a href="#" class="-m-1.5 p-1.5">
<span class="sr-only">Your profile</span>
<img class="h-8 w-8 rounded-full bg-gray-800" src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" alt="" />
</a>
</div>
</div>
<Dialog as="div" class="lg:hidden" @close="mobileMenuOpen = false" :open="mobileMenuOpen">
<div class="fixed inset-0 z-50" />
<DialogPanel class="fixed inset-y-0 left-0 z-50 w-full overflow-y-auto bg-white px-4 pb-6 sm:max-w-sm sm:px-6 sm:ring-1 sm:ring-gray-900/10">
<div class="-ml-0.5 flex h-16 items-center gap-x-6">
<button type="button" class="-m-2.5 p-2.5 text-gray-700" @click="mobileMenuOpen = false">
<span class="sr-only">Close menu</span>
<XMarkIconOutline class="h-6 w-6" aria-hidden="true" />
</button>
<div class="-ml-0.5">
<a href="#" class="-m-1.5 block p-1.5">
<span class="sr-only">Your Company</span>
<img class="h-8 w-auto" src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600" alt="" />
</a>
</div>
</div>
<div class="mt-2 space-y-2">
<a v-for="item in navigation" :key="item.name" :href="item.href" class="-mx-3 block rounded-lg px-3 py-2 text-base font-semibold leading-7 text-gray-900 hover:bg-gray-50">{{ item.name }}</a>
</div>
</DialogPanel>
</Dialog>
</header>
<main>
<header class="relative isolate pt-16">
<div class="absolute inset-0 -z-10 overflow-hidden" aria-hidden="true">
<div class="absolute left-16 top-full -mt-16 transform-gpu opacity-50 blur-3xl xl:left-1/2 xl:-ml-80">
<div class="aspect-[1154/678] w-[72.125rem] bg-gradient-to-br from-[#FF80B5] to-[#9089FC]" style="clip-path: polygon(100% 38.5%, 82.6% 100%, 60.2% 37.7%, 52.4% 32.1%, 47.5% 41.8%, 45.2% 65.6%, 27.5% 23.4%, 0.1% 35.3%, 17.9% 0%, 27.7% 23.4%, 76.2% 2.5%, 74.2% 56%, 100% 38.5%)" />
</div>
<div class="absolute inset-x-0 bottom-0 h-px bg-gray-900/5" />
</div>
<div class="mx-auto max-w-7xl px-4 py-10 sm:px-6 lg:px-8">
<div class="mx-auto flex max-w-2xl items-center justify-between gap-x-8 lg:mx-0 lg:max-w-none">
<div class="flex items-center gap-x-6">
<img src="https://tailwindui.com/img/logos/48x48/tuple.svg" alt="" class="h-16 w-16 flex-none rounded-full ring-1 ring-gray-900/10" />
<h1>
<div class="text-sm leading-6 text-gray-500">Invoice <span class="text-gray-700">#00011</span></div>
<div class="mt-1 text-base font-semibold leading-6 text-gray-900">Tuple, Inc</div>
</h1>
</div>
<div class="flex items-center gap-x-4 sm:gap-x-6">
<button type="button" class="hidden text-sm font-semibold leading-6 text-gray-900 sm:block">Copy URL</button>
<a href="#" class="hidden text-sm font-semibold leading-6 text-gray-900 sm:block">Edit</a>
<a href="#" class="rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Send</a>
<Menu as="div" class="relative sm:hidden">
<MenuButton class="-m-3 block p-3">
<span class="sr-only">More</span>
<EllipsisVerticalIcon class="h-5 w-5 text-gray-500" aria-hidden="true" />
</MenuButton>
<transition enter-active-class="transition ease-out duration-100" enter-from-class="transform opacity-0 scale-95" enter-to-class="transform opacity-100 scale-100" leave-active-class="transition ease-in duration-75" leave-from-class="transform opacity-100 scale-100" leave-to-class="transform opacity-0 scale-95">
<MenuItems class="absolute right-0 z-10 mt-0.5 w-32 origin-top-right rounded-md bg-white py-2 shadow-lg ring-1 ring-gray-900/5 focus:outline-none">
<MenuItem v-slot="{ active }">
<button type="button" :class="[active ? 'bg-gray-50' : '', 'block w-full px-3 py-1 text-left text-sm leading-6 text-gray-900']">Copy URL</button>
</MenuItem>
<MenuItem v-slot="{ active }">
<a href="#" :class="[active ? 'bg-gray-50' : '', 'block px-3 py-1 text-sm leading-6 text-gray-900']">Edit</a>
</MenuItem>
</MenuItems>
</transition>
</Menu>
</div>
</div>
</div>
</header>
<div class="mx-auto max-w-7xl px-4 py-16 sm:px-6 lg:px-8">
<div class="mx-auto grid max-w-2xl grid-cols-1 grid-rows-1 items-start gap-x-8 gap-y-8 lg:mx-0 lg:max-w-none lg:grid-cols-3">
<!-- Invoice summary -->
<div class="lg:col-start-3 lg:row-end-1">
<h2 class="sr-only">Summary</h2>
<div class="rounded-lg bg-gray-50 shadow-sm ring-1 ring-gray-900/5">
<dl class="flex flex-wrap">
<div class="flex-auto pl-6 pt-6">
<dt class="text-sm font-semibold leading-6 text-gray-900">Amount</dt>
<dd class="mt-1 text-base font-semibold leading-6 text-gray-900">$10,560.00</dd>
</div>
<div class="flex-none self-end px-6 pt-4">
<dt class="sr-only">Status</dt>
<dd class="rounded-md bg-green-50 px-2 py-1 text-xs font-medium text-green-600 ring-1 ring-inset ring-green-600/20">Paid</dd>
</div>
<div class="mt-6 flex w-full flex-none gap-x-4 border-t border-gray-900/5 px-6 pt-6">
<dt class="flex-none">
<span class="sr-only">Client</span>
<UserCircleIcon class="h-6 w-5 text-gray-400" aria-hidden="true" />
</dt>
<dd class="text-sm font-medium leading-6 text-gray-900">Alex Curren</dd>
</div>
<div class="mt-4 flex w-full flex-none gap-x-4 px-6">
<dt class="flex-none">
<span class="sr-only">Due date</span>
<CalendarDaysIcon class="h-6 w-5 text-gray-400" aria-hidden="true" />
</dt>
<dd class="text-sm leading-6 text-gray-500">
<time datetime="2023-01-31">January 31, 2023</time>
</dd>
</div>
<div class="mt-4 flex w-full flex-none gap-x-4 px-6">
<dt class="flex-none">
<span class="sr-only">Status</span>
<CreditCardIcon class="h-6 w-5 text-gray-400" aria-hidden="true" />
</dt>
<dd class="text-sm leading-6 text-gray-500">Paid with MasterCard</dd>
</div>
</dl>
<div class="mt-6 border-t border-gray-900/5 px-6 py-6">
<a href="#" class="text-sm font-semibold leading-6 text-gray-900">Download receipt <span aria-hidden="true">&rarr;</span></a>
</div>
</div>
</div>
<!-- Invoice -->
<div class="-mx-4 px-4 py-8 shadow-sm ring-1 ring-gray-900/5 sm:mx-0 sm:rounded-lg sm:px-8 sm:pb-14 lg:col-span-2 lg:row-span-2 lg:row-end-2 xl:px-16 xl:pb-20 xl:pt-16">
<h2 class="text-base font-semibold leading-6 text-gray-900">Invoice</h2>
<dl class="mt-6 grid grid-cols-1 text-sm leading-6 sm:grid-cols-2">
<div class="sm:pr-4">
<dt class="inline text-gray-500">Issued on</dt>
{{ ' ' }}
<dd class="inline text-gray-700"><time datetime="2023-23-01">January 23, 2023</time></dd>
</div>
<div class="mt-2 sm:mt-0 sm:pl-4">
<dt class="inline text-gray-500">Due on</dt>
{{ ' ' }}
<dd class="inline text-gray-700"><time datetime="2023-31-01">January 31, 2023</time></dd>
</div>
<div class="mt-6 border-t border-gray-900/5 pt-6 sm:pr-4">
<dt class="font-semibold text-gray-900">From</dt>
<dd class="mt-2 text-gray-500"><span class="font-medium text-gray-900">Acme, Inc.</span><br />7363 Cynthia Pass<br />Toronto, ON N3Y 4H8</dd>
</div>
<div class="mt-8 sm:mt-6 sm:border-t sm:border-gray-900/5 sm:pl-4 sm:pt-6">
<dt class="font-semibold text-gray-900">To</dt>
<dd class="mt-2 text-gray-500"><span class="font-medium text-gray-900">Tuple, Inc</span><br />886 Walter Street<br />New York, NY 12345</dd>
</div>
</dl>
<table class="mt-16 w-full whitespace-nowrap text-left text-sm leading-6">
<colgroup>
<col class="w-full" />
<col />
<col />
<col />
</colgroup>
<thead class="border-b border-gray-200 text-gray-900">
<tr>
<th scope="col" class="px-0 py-3 font-semibold">Projects</th>
<th scope="col" class="hidden py-3 pl-8 pr-0 text-right font-semibold sm:table-cell">Hours</th>
<th scope="col" class="hidden py-3 pl-8 pr-0 text-right font-semibold sm:table-cell">Rate</th>
<th scope="col" class="py-3 pl-8 pr-0 text-right font-semibold">Price</th>
</tr>
</thead>
<tbody>
<tr v-for="item in invoice.items" :key="item.id" class="border-b border-gray-100">
<td class="max-w-0 px-0 py-5 align-top">
<div class="truncate font-medium text-gray-900">{{ item.title }}</div>
<div class="truncate text-gray-500">{{ item.description }}</div>
</td>
<td class="hidden py-5 pl-8 pr-0 text-right align-top tabular-nums text-gray-700 sm:table-cell">{{ item.hours }}</td>
<td class="hidden py-5 pl-8 pr-0 text-right align-top tabular-nums text-gray-700 sm:table-cell">{{ item.rate }}</td>
<td class="py-5 pl-8 pr-0 text-right align-top tabular-nums text-gray-700">{{ item.price }}</td>
</tr>
</tbody>
<tfoot>
<tr>
<th scope="row" class="px-0 pb-0 pt-6 font-normal text-gray-700 sm:hidden">Subtotal</th>
<th scope="row" colspan="3" class="hidden px-0 pb-0 pt-6 text-right font-normal text-gray-700 sm:table-cell">Subtotal</th>
<td class="pb-0 pl-8 pr-0 pt-6 text-right tabular-nums text-gray-900">{{ invoice.subTotal }}</td>
</tr>
<tr>
<th scope="row" class="pt-4 font-normal text-gray-700 sm:hidden">Tax</th>
<th scope="row" colspan="3" class="hidden pt-4 text-right font-normal text-gray-700 sm:table-cell">Tax</th>
<td class="pb-0 pl-8 pr-0 pt-4 text-right tabular-nums text-gray-900">{{ invoice.tax }}</td>
</tr>
<tr>
<th scope="row" class="pt-4 font-semibold text-gray-900 sm:hidden">Total</th>
<th scope="row" colspan="3" class="hidden pt-4 text-right font-semibold text-gray-900 sm:table-cell">Total</th>
<td class="pb-0 pl-8 pr-0 pt-4 text-right font-semibold tabular-nums text-gray-900">{{ invoice.total }}</td>
</tr>
</tfoot>
</table>
</div>
<div class="lg:col-start-3">
<!-- Activity feed -->
<h2 class="text-sm font-semibold leading-6 text-gray-900">Activity</h2>
<ul role="list" class="mt-6 space-y-6">
<li v-for="(activityItem, activityItemIdx) in activity" :key="activityItem.id" class="relative flex gap-x-4">
<div :class="[activityItemIdx === activity.length - 1 ? 'h-6' : '-bottom-6', 'absolute left-0 top-0 flex w-6 justify-center']">
<div class="w-px bg-gray-200" />
</div>
<template v-if="activityItem.type === 'commented'">
<img :src="activityItem.person.imageUrl" alt="" class="relative mt-3 h-6 w-6 flex-none rounded-full bg-gray-50" />
<div class="flex-auto rounded-md p-3 ring-1 ring-inset ring-gray-200">
<div class="flex justify-between gap-x-4">
<div class="py-0.5 text-xs leading-5 text-gray-500">
<span class="font-medium text-gray-900">{{ activityItem.person.name }}</span> commented
</div>
<time :datetime="activityItem.dateTime" class="flex-none py-0.5 text-xs leading-5 text-gray-500">{{ activityItem.date }}</time>
</div>
<p class="text-sm leading-6 text-gray-500">{{ activityItem.comment }}</p>
</div>
</template>
<template v-else>
<div class="relative flex h-6 w-6 flex-none items-center justify-center bg-white">
<CheckCircleIcon v-if="activityItem.type === 'paid'" class="h-6 w-6 text-indigo-600" aria-hidden="true" />
<div v-else class="h-1.5 w-1.5 rounded-full bg-gray-100 ring-1 ring-gray-300" />
</div>
<p class="flex-auto py-0.5 text-xs leading-5 text-gray-500">
<span class="font-medium text-gray-900">{{ activityItem.person.name }}</span> {{ activityItem.type }} the invoice.
</p>
<time :datetime="activityItem.dateTime" class="flex-none py-0.5 text-xs leading-5 text-gray-500">{{ activityItem.date }}</time>
</template>
</li>
</ul>
<!-- New comment form -->
<div class="mt-6 flex gap-x-3">
<img src="https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80" alt="" class="h-6 w-6 flex-none rounded-full bg-gray-50" />
<form action="#" class="relative flex-auto">
<div class="overflow-hidden rounded-lg pb-12 shadow-sm ring-1 ring-inset ring-gray-300 focus-within:ring-2 focus-within:ring-indigo-600">
<label for="comment" class="sr-only">Add your comment</label>
<textarea rows="2" name="comment" id="comment" class="block w-full resize-none border-0 bg-transparent py-1.5 text-gray-900 placeholder:text-gray-400 focus:ring-0 sm:text-sm sm:leading-6" placeholder="Add your comment..." />
</div>
<div class="absolute inset-x-0 bottom-0 flex justify-between py-2 pl-3 pr-2">
<div class="flex items-center space-x-5">
<div class="flex items-center">
<button type="button" class="-m-2.5 flex h-10 w-10 items-center justify-center rounded-full text-gray-400 hover:text-gray-500">
<PaperClipIcon class="h-5 w-5" aria-hidden="true" />
<span class="sr-only">Attach a file</span>
</button>
</div>
<div class="flex items-center">
<Listbox as="div" v-model="selected">
<ListboxLabel class="sr-only">Your mood</ListboxLabel>
<div class="relative">
<ListboxButton class="relative -m-2.5 flex h-10 w-10 items-center justify-center rounded-full text-gray-400 hover:text-gray-500">
<span class="flex items-center justify-center">
<span v-if="selected.value === null">
<FaceSmileIcon class="h-5 w-5 flex-shrink-0" aria-hidden="true" />
<span class="sr-only">Add your mood</span>
</span>
<span v-if="!(selected.value === null)">
<span :class="[selected.bgColor, 'flex h-8 w-8 items-center justify-center rounded-full']">
<component :is="selected.icon" class="h-5 w-5 flex-shrink-0 text-white" aria-hidden="true" />
</span>
<span class="sr-only">{{ selected.name }}</span>
</span>
</span>
</ListboxButton>
<transition leave-active-class="transition ease-in duration-100" leave-from-class="opacity-100" leave-to-class="opacity-0">
<ListboxOptions class="absolute z-10 -ml-6 mt-1 w-60 rounded-lg bg-white py-3 text-base shadow ring-1 ring-black ring-opacity-5 focus:outline-none sm:ml-auto sm:w-64 sm:text-sm">
<ListboxOption as="template" v-for="mood in moods" :key="mood.value" :value="mood" v-slot="{ active }">
<li :class="[active ? 'bg-gray-100' : 'bg-white', 'relative cursor-default select-none px-3 py-2']">
<div class="flex items-center">
<div :class="[mood.bgColor, 'flex h-8 w-8 items-center justify-center rounded-full']">
<component :is="mood.icon" :class="[mood.iconColor, 'h-5 w-5 flex-shrink-0']" aria-hidden="true" />
</div>
<span class="ml-3 block truncate font-medium">{{ mood.name }}</span>
</div>
</li>
</ListboxOption>
</ListboxOptions>
</transition>
</div>
</Listbox>
</div>
</div>
<button type="submit" class="rounded-md bg-white px-2.5 py-1.5 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50">Comment</button>
</div>
</form>
</div>
</div>
</div>
</div>
</main>
</template>
<script setup>
import { ref } from 'vue'
import {
Dialog,
DialogPanel,
Listbox,
ListboxButton,
ListboxLabel,
ListboxOption,
ListboxOptions,
Menu,
MenuButton,
MenuItem,
MenuItems,
} from '@headlessui/vue'
import {
Bars3Icon,
CalendarDaysIcon,
CreditCardIcon,
EllipsisVerticalIcon,
FaceFrownIcon,
FaceSmileIcon,
FireIcon,
HandThumbUpIcon,
HeartIcon,
PaperClipIcon,
UserCircleIcon,
XMarkIcon as XMarkIconMini,
} from '@heroicons/vue/20/solid'
import { BellIcon, XMarkIcon as XMarkIconOutline } from '@heroicons/vue/24/outline'
import { CheckCircleIcon } from '@heroicons/vue/24/solid'
const navigation = [
{ name: 'Home', href: '#' },
{ name: 'Invoices', href: '#' },
{ name: 'Clients', href: '#' },
{ name: 'Expenses', href: '#' },
]
const invoice = {
subTotal: '$8,800.00',
tax: '$1,760.00',
total: '$10,560.00',
items: [
{
id: 1,
title: 'Logo redesign',
description: 'New logo and digital asset playbook.',
hours: '20.0',
rate: '$100.00',
price: '$2,000.00',
},
{
id: 2,
title: 'Website redesign',
description: 'Design and program new company website.',
hours: '52.0',
rate: '$100.00',
price: '$5,200.00',
},
{
id: 3,
title: 'Business cards',
description: 'Design and production of 3.5" x 2.0" business cards.',
hours: '12.0',
rate: '$100.00',
price: '$1,200.00',
},
{
id: 4,
title: 'T-shirt design',
description: 'Three t-shirt design concepts.',
hours: '4.0',
rate: '$100.00',
price: '$400.00',
},
],
}
const activity = [
{ id: 1, type: 'created', person: { name: 'Chelsea Hagon' }, date: '7d ago', dateTime: '2023-01-23T10:32' },
{ id: 2, type: 'edited', person: { name: 'Chelsea Hagon' }, date: '6d ago', dateTime: '2023-01-23T11:03' },
{ id: 3, type: 'sent', person: { name: 'Chelsea Hagon' }, date: '6d ago', dateTime: '2023-01-23T11:24' },
{
id: 4,
type: 'commented',
person: {
name: 'Chelsea Hagon',
imageUrl:
'https://images.unsplash.com/photo-1550525811-e5869dd03032?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80',
},
comment: 'Called client, they reassured me the invoice would be paid by the 25th.',
date: '3d ago',
dateTime: '2023-01-23T15:56',
},
{ id: 5, type: 'viewed', person: { name: 'Alex Curren' }, date: '2d ago', dateTime: '2023-01-24T09:12' },
{ id: 6, type: 'paid', person: { name: 'Alex Curren' }, date: '1d ago', dateTime: '2023-01-24T09:20' },
]
const moods = [
{ name: 'Excited', value: 'excited', icon: FireIcon, iconColor: 'text-white', bgColor: 'bg-red-500' },
{ name: 'Loved', value: 'loved', icon: HeartIcon, iconColor: 'text-white', bgColor: 'bg-pink-400' },
{ name: 'Happy', value: 'happy', icon: FaceSmileIcon, iconColor: 'text-white', bgColor: 'bg-green-400' },
{ name: 'Sad', value: 'sad', icon: FaceFrownIcon, iconColor: 'text-white', bgColor: 'bg-yellow-400' },
{ name: 'Thumbsy', value: 'thumbsy', icon: HandThumbUpIcon, iconColor: 'text-white', bgColor: 'bg-blue-500' },
{ name: 'I feel nothing', value: null, icon: XMarkIconMini, iconColor: 'text-gray-400', bgColor: 'bg-transparent' },
]
const mobileMenuOpen = ref(false)
const selected = ref(moods[5])
</script>