Оплата
Выбор тарифа карточками и история оплат с выбором строк и сортировкой по счёту.
Состав: Avatar, AvatarGroup, AvatarLabelGroup, Badge, Button, Card, Checkbox, DropdownMenu, FeaturedIcon, Field, IconButton, InputGroup, Kbd, PageHeader, QueryContainer, RadioGroup, SectionHeader, Select, Sidebar, Slideout, Table.
vue
<script setup lang="ts">
import {
PageHeader,
PageHeaderContent,
PageHeaderDescription,
PageHeaderHeading,
PageHeaderTitle,
} from '@prosper/ui'
import BillingCard from './BillingCard.vue'
import BillingHistory from './BillingHistory.vue'
import BillingPanel from './BillingPanel.vue'
import BillingPlans from './BillingPlans.vue'
import BillingSections from './BillingSections.vue'
import ShellLayout from './ShellLayout.vue'
</script>
<template>
<ShellLayout current="Настройки">
<template #card><BillingCard /></template>
<template #panel><BillingPanel /></template>
<PageHeader>
<PageHeaderContent>
<PageHeaderHeading>
<PageHeaderTitle>Оплата</PageHeaderTitle>
<PageHeaderDescription>
Управляйте тарифом и платёжными данными.
</PageHeaderDescription>
</PageHeaderHeading>
</PageHeaderContent>
</PageHeader>
<BillingSections />
<BillingPlans />
<BillingHistory />
</ShellLayout>
</template>vue
<script setup lang="ts">
import {
Avatar,
AvatarFallback,
AvatarGroup,
AvatarGroupAdd,
Badge,
BadgeDot,
Button,
SidebarCard,
SidebarCardActions,
SidebarCardClose,
SidebarCardDescription,
SidebarCardHeading,
SidebarCardTitle,
} from '@prosper/ui'
const hosts = [
{ name: 'Алия Ахметова', initials: 'АА' },
{ name: 'Дамир Сейтказин', initials: 'ДС' },
{ name: 'Ирина Шевчук', initials: 'ИШ' },
{ name: 'Тимур Цой', initials: 'ТЦ' },
] as const
</script>
<template>
<SidebarCard variant="outline">
<AvatarGroup size="xs" aria-label="Участники мастер-класса">
<Avatar v-for="host in hosts" :key="host.initials">
<AvatarFallback :label="host.name">{{ host.initials }}</AvatarFallback>
</Avatar>
<Avatar>
<AvatarFallback label="Ещё 5 участников">+5</AvatarFallback>
</Avatar>
<AvatarGroupAdd label="Пригласить участника" />
</AvatarGroup>
<SidebarCardHeading>
<div class="title">
<SidebarCardTitle>Мастер-класс</SidebarCardTitle>
<Badge size="sm" variant="modern" color="success">
<BadgeDot />
В эфире
</Badge>
</div>
<SidebarCardDescription>
Как собрать отчёт по оплатам команды за пять минут.
</SidebarCardDescription>
</SidebarCardHeading>
<SidebarCardActions>
<Button variant="link-gray" size="sm">Скрыть</Button>
<Button variant="link-color" size="sm">Присоединиться</Button>
</SidebarCardActions>
<SidebarCardClose />
</SidebarCard>
</template>
<style scoped>
.title {
display: flex;
align-items: center;
gap: var(--prosper-spacing-sm);
}
</style>vue
<script setup lang="ts">
import {
Button,
ButtonIcon,
SectionHeader,
SectionHeaderActions,
SectionHeaderContent,
SectionHeaderHeading,
SectionHeaderTitle,
} from '@prosper/ui'
import { DownloadCloud02 } from '@prosper/ui/icons'
import BillingTable from './BillingTable.vue'
</script>
<template>
<section class="history" aria-labelledby="billing-history-title">
<SectionHeader>
<SectionHeaderContent>
<SectionHeaderHeading>
<SectionHeaderTitle id="billing-history-title" as="h2">
История оплат
</SectionHeaderTitle>
</SectionHeaderHeading>
<SectionHeaderActions>
<Button variant="secondary" size="sm">
<ButtonIcon><DownloadCloud02 /></ButtonIcon>
Скачать все
</Button>
</SectionHeaderActions>
</SectionHeaderContent>
</SectionHeader>
<BillingTable />
</section>
</template>
<style scoped>
.history {
display: flex;
flex-direction: column;
gap: var(--prosper-spacing-3xl);
}
</style>vue
<script setup lang="ts">
import {
Badge,
Sidebar,
SidebarContent,
SidebarItem,
SidebarSection,
} from '@prosper/ui'
import {
CreditCard02,
Flag05,
LineChartUp03,
NotificationBox,
Star01,
Toggle03Right,
UserSquare,
} from '@prosper/ui/icons'
import type { Component } from 'vue'
import { currentSection, settingsSections } from '../data/billing'
const icons: Record<string, Component> = {
'Мои данные': Flag05,
Уведомления: NotificationBox,
Аналитика: LineChartUp03,
'Сохранённые отчёты': Star01,
Оплата: CreditCard02,
'Отчёты пользователей': UserSquare,
'Настройки уведомлений': Toggle03Right,
}
</script>
<template>
<Sidebar variant="secondary" aria-label="Разделы настроек">
<SidebarContent>
<SidebarSection>
<SidebarItem
v-for="section in settingsSections"
:key="section.label"
href="#"
:current="section.label === currentSection"
>
<template #leading><component :is="icons[section.label]" /></template>
{{ section.label }}
<template v-if="section.count" #trailing>
<Badge size="sm">{{ section.count }}</Badge>
</template>
</SidebarItem>
</SidebarSection>
</SidebarContent>
</Sidebar>
</template>vue
<script setup lang="ts">
import {
Badge,
BadgeDot,
FeaturedIcon,
RadioGroup,
RadioGroupItem,
} from '@prosper/ui'
import { LayersThree01, LayersTwo01, Zap } from '@prosper/ui/icons'
import { ref } from 'vue'
import { plans, type PlanValue } from '../data/billing'
const plan = ref<PlanValue>('basic')
const planIcons = {
basic: LayersTwo01,
business: LayersThree01,
enterprise: Zap,
}
</script>
<template>
<RadioGroup v-model="plan" aria-label="Тариф">
<RadioGroupItem
v-for="item in plans"
:key="item.value"
:value="item.value"
indicator="checkbox"
indicator-position="end"
>
<template #leading>
<FeaturedIcon variant="modern" color="gray" size="sm">
<component :is="planIcons[item.value]" />
</FeaturedIcon>
</template>
{{ item.title }}
<template #price>
{{ item.price }}
<small>в месяц</small>
</template>
<template v-if="item.offer" #badge>
<Badge size="sm" variant="modern" color="success">
<BadgeDot />
{{ item.offer }}
</Badge>
</template>
<template #supporting>{{ item.description }}</template>
</RadioGroupItem>
</RadioGroup>
</template>vue
<script setup lang="ts">
import {
Badge,
BadgeIcon,
Checkbox,
IconButton,
TableCell,
TableRow,
} from '@prosper/ui'
import { Check, DownloadCloud02 } from '@prosper/ui/icons'
import type { Invoice } from '../data/billing'
defineProps<{ invoice: Invoice }>()
const selected = defineModel<boolean>('selected', { required: true })
</script>
<template>
<TableRow :selected="selected">
<TableCell>
<template #leading>
<Checkbox
v-model:checked="selected"
:aria-label="`Выбрать: ${invoice.title}`"
/>
</template>
<span class="invoice nowrap">{{ invoice.title }}</span>
</TableCell>
<TableCell>
<span class="nowrap">{{ invoice.amount }}</span>
</TableCell>
<TableCell>
<span class="nowrap">{{ invoice.date }}</span>
</TableCell>
<TableCell>
<Badge size="sm" variant="badge" color="success">
<BadgeIcon><Check /></BadgeIcon>
Оплачен
</Badge>
</TableCell>
<TableCell>
<IconButton
variant="tertiary"
size="xs"
:aria-label="`Скачать: ${invoice.title}`"
>
<DownloadCloud02 />
</IconButton>
</TableCell>
</TableRow>
</template>
<style scoped>
.invoice {
color: var(--prosper-color-text-primary);
font-weight: var(--prosper-font-weight-medium);
}
.nowrap {
white-space: nowrap;
}
</style>vue
<script setup lang="ts">
import { Field, FieldLabel, Select, SelectItem } from '@prosper/ui'
import type { SelectOptionValue } from '@prosper/ui'
import { ref } from 'vue'
import { currentSection, settingsSections } from '../data/billing'
const section = ref<SelectOptionValue>(currentSection)
</script>
<template>
<nav class="sections" aria-label="Выбор раздела настроек">
<Field>
<FieldLabel>Раздел настроек</FieldLabel>
<Select v-model="section">
<SelectItem
v-for="item in settingsSections"
:key="item.label"
:value="item.label"
>
{{ item.label }}
</SelectItem>
</Select>
</Field>
</nav>
</template>
<style scoped>
@media (width >= 64rem) {
.sections {
display: none;
}
}
</style>vue
<script setup lang="ts">
import {
Card,
Checkbox,
Table,
TableBody,
TableHead,
TableHeader,
TableRow,
type TableSort,
} from '@prosper/ui'
import { computed, ref } from 'vue'
import { invoices, type InvoiceSort } from '../data/billing'
import BillingRow from './BillingRow.vue'
const sort = ref<InvoiceSort>('descending')
const selected = ref<string[]>([])
const shown = computed(() => {
const sign = sort.value === 'ascending' ? 1 : -1
return [...invoices].sort(
(first, second) => sign * (first.issued - second.issued),
)
})
const all = computed(() =>
invoices.every(({ id }) => selected.value.includes(id)),
)
const some = computed(() => selected.value.length > 0)
const setAll = (checked: boolean): void => {
selected.value = checked ? invoices.map(({ id }) => id) : []
}
const setOne = (id: string, checked: boolean): void => {
selected.value = checked
? [...selected.value, id]
: selected.value.filter((value) => value !== id)
}
const flip = (next: TableSort): void => {
sort.value = next === 'descending' ? 'descending' : 'ascending'
}
</script>
<template>
<Card class="table-card">
<Table aria-label="Счета">
<TableHeader>
<TableRow>
<TableHead :sort="sort" @update:sort="flip">
<template #leading>
<Checkbox
aria-label="Выбрать все счета"
:checked="all"
:indeterminate="some && !all"
@update:checked="setAll"
/>
</template>
Счёт
</TableHead>
<TableHead>Сумма</TableHead>
<TableHead>Дата</TableHead>
<TableHead>Статус</TableHead>
<TableHead>Действия</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<BillingRow
v-for="invoice in shown"
:key="invoice.id"
:invoice="invoice"
:selected="selected.includes(invoice.id)"
@update:selected="setOne(invoice.id, $event)"
/>
</TableBody>
</Table>
</Card>
</template>
<style scoped>
@container prosper (width < 40rem) {
@media (width < 64rem) {
.table-card {
margin-inline: calc(var(--prosper-spacing-xl) * -1);
}
}
}
</style>ts
import type { TableSort } from '@prosper/ui'
export type PlanValue = 'basic' | 'business' | 'enterprise'
export interface Plan {
value: PlanValue
title: string
price: string
description: string
offer?: string
}
export interface Invoice {
id: string
title: string
amount: string
date: string
issued: number
}
export type InvoiceSort = Exclude<TableSort, 'none'>
export const plans: readonly Plan[] = [
{
value: 'basic',
title: 'Базовый тариф',
price: '10 $',
description:
'До 10 пользователей, 20 ГБ личных данных и доступ ко всем функциям.',
offer: 'Ограниченное предложение',
},
{
value: 'business',
title: 'Бизнес-тариф',
price: '20 $',
description:
'До 20 пользователей, 40 ГБ личных данных и доступ ко всем функциям.',
},
{
value: 'enterprise',
title: 'Корпоративный тариф',
price: '40 $',
description:
'Без ограничений по пользователям и личным данным, доступ ко всем функциям.',
},
]
export const invoices: readonly Invoice[] = [
{
id: '2027-12',
title: 'Базовый тариф, декабрь 2027',
amount: '10,00 $',
date: '1 дек. 2027',
issued: 11,
},
{
id: '2027-11',
title: 'Базовый тариф, ноябрь 2027',
amount: '10,00 $',
date: '1 нояб. 2027',
issued: 10,
},
{
id: '2027-10',
title: 'Базовый тариф, октябрь 2027',
amount: '10,00 $',
date: '1 окт. 2027',
issued: 9,
},
{
id: '2027-09',
title: 'Базовый тариф, сентябрь 2027',
amount: '10,00 $',
date: '1 сент. 2027',
issued: 8,
},
{
id: '2027-08',
title: 'Базовый тариф, август 2027',
amount: '10,00 $',
date: '1 авг. 2027',
issued: 7,
},
{
id: '2027-07',
title: 'Базовый тариф, июль 2027',
amount: '10,00 $',
date: '1 июл. 2027',
issued: 6,
},
{
id: '2027-06',
title: 'Базовый тариф, июнь 2027',
amount: '10,00 $',
date: '1 июн. 2027',
issued: 5,
},
]
export interface SettingsSection {
label: string
count?: number
}
export const settingsSections: readonly SettingsSection[] = [
{ label: 'Мои данные' },
{ label: 'Уведомления', count: 10 },
{ label: 'Аналитика' },
{ label: 'Сохранённые отчёты' },
{ label: 'Оплата' },
{ label: 'Отчёты пользователей' },
{ label: 'Настройки уведомлений' },
]
export const currentSection = 'Оплата'