Design Updates: Breadcrumbs, Empty State, new Charts and new colors

Design Updates: Breadcrumbs, Empty State, new Charts and new colors

* Add Breadcrumb component to UI package

* Add AppBreadcrumbs for improved navigation: Replaced static text descriptions with the new AppBreadcrumbs component across multiple pages to enhance navigation. Addressed an issue with Supabase client warnings by temporarily suppressing getSession warnings. Also made minor UI adjustments, including adjustments to heading styles and layout features.

* Enhance UI styling and configuration settings: Updated various UI components and global styles to improve styling consistency and responsiveness.

* Update global styles and adjust padding: Updated several CSS variables for improved color accuracy and appearance. Added padding to admin account page body for better layout consistency.

* Refactor UI components and adjust styling: Replaced Heading tags in Plan Picker with span for consistency. Added active and hover states to buttons in the sidebar. Refined background, layout styling, and color schemes across various components. Removed sidebar case in Page component switch statement.

* Add Chart Components and Integrate into Dashboard: Introduced `recharts` library and created `Chart` components. Updated dashboard to use the new components and enhanced UI/UX with descriptions and restructured cards.
* Enhance dashboard demo UI layout: Refactor the layout by adjusting flex properties and spacing classes to improve component alignment. Update dummy data generation and Figure font size for better visual consistency.

* Update localization keys for navigation labels: Changed localization keys for tab labels to use 'routes' prefix for consistency. Adjusted corresponding component references and added missing keys for routes. This ensures better organization and uniformity in the code.

* Add EmptyState component and enhance account handling: Introduced a new EmptyState component for UI consistency and updated JSON locales with 'account' route. Modified HomeAddAccountButton to accept className prop and refactored HomeAccountsListEmptyState to use the new EmptyState component. Updated navigation config to align labels in locales.

* Add locale support and enhance currency formatting: This commit introduces locale-based currency formatting across billing components by utilizing the `useTranslation` hook to fetch the current language. It also refactors the `formatCurrency` function to accept an object parameter for better readability and reusability.

* Fix typo in devDependencies section of template generator: Corrected a syntax error in `package.json.hbs` template affecting the `@kit/tsconfig` entry. The change ensures that the dependency is properly defined and prevents potential issues during package management.

* Update heading levels and add tracking-tight class in auth shell: Changed Heading components from level 4 to level 5 and added the 'tracking-tight' class in multiple auth-related pages. This improves visual consistency and better aligns the typography across the application.
This commit is contained in:
Giancarlo Buomprisco
2024-08-04 23:25:28 +08:00
committed by GitHub
parent 23154c366d
commit e696f1aed0
53 changed files with 1795 additions and 515 deletions

View File

@@ -1,4 +1,7 @@
'use client';
import { PlusSquare } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import { z } from 'zod';
import type { LineItemSchema } from '@kit/billing';
@@ -16,6 +19,9 @@ export function LineItemDetails(
selectedInterval?: string | undefined;
}>,
) {
const locale = useTranslation().i18n.language;
const currencyCode = props?.currency.toLowerCase();
return (
<div className={'flex flex-col space-y-1'}>
{props.lineItems.map((item, index) => {
@@ -48,10 +54,11 @@ export function LineItemDetails(
<Trans
i18nKey={'billing:setupFee'}
values={{
setupFee: formatCurrency(
props?.currency.toLowerCase(),
item.setupFee as number,
),
setupFee: formatCurrency({
currencyCode,
value: item.setupFee as number,
locale,
}),
}}
/>
</span>
@@ -89,7 +96,11 @@ export function LineItemDetails(
<span>-</span>
<span className={'text-xs font-semibold'}>
{formatCurrency(props?.currency.toLowerCase(), item.cost)}
{formatCurrency({
currencyCode,
value: item.cost,
locale,
})}
</span>
</div>
@@ -129,7 +140,11 @@ export function LineItemDetails(
<If condition={!item.tiers?.length}>
<span className={'font-semibold'}>
{formatCurrency(props.currency.toLowerCase(), item.cost)}
{formatCurrency({
currencyCode,
value: item.cost,
locale,
})}
</span>
</If>
</div>
@@ -165,7 +180,11 @@ export function LineItemDetails(
{/* If there are no tiers, there is a flat cost for usage */}
<If condition={!item.tiers?.length}>
<span className={'font-semibold'}>
{formatCurrency(props?.currency.toLowerCase(), item.cost)}
{formatCurrency({
currencyCode,
value: item.cost,
locale,
})}
</span>
</If>
</div>
@@ -203,6 +222,7 @@ function Tiers({
item: z.infer<typeof LineItemSchema>;
}) {
const unit = item.unit;
const locale = useTranslation().i18n.language;
const tiers = item.tiers?.map((tier, index) => {
const tiersLength = item.tiers?.length ?? 0;
@@ -228,7 +248,11 @@ function Tiers({
<If condition={isLastTier}>
<span className={'font-bold'}>
{formatCurrency(currency.toLowerCase(), tier.cost)}
{formatCurrency({
currencyCode: currency.toLowerCase(),
value: tier.cost,
locale,
})}
</span>
<If condition={tiersLength > 1}>
@@ -264,7 +288,11 @@ function Tiers({
<If condition={!isIncluded}>
<span className={'font-bold'}>
{formatCurrency(currency.toLowerCase(), tier.cost)}
{formatCurrency({
currencyCode: currency.toLowerCase(),
value: tier.cost,
locale,
})}
</span>
<span>

View File

@@ -26,7 +26,6 @@ import {
FormLabel,
FormMessage,
} from '@kit/ui/form';
import { Heading } from '@kit/ui/heading';
import { If } from '@kit/ui/if';
import { Label } from '@kit/ui/label';
import {
@@ -106,6 +105,8 @@ export function PlanPicker(
const isRecurringPlan =
selectedPlan?.paymentType === 'recurring' || !selectedPlan;
const locale = useTranslation().i18n.language;
return (
<Form {...form}>
<div
@@ -316,10 +317,12 @@ export function PlanPicker(
<div>
<Price key={plan.id}>
<span>
{formatCurrency(
product.currency.toLowerCase(),
primaryLineItem.cost,
)}
{formatCurrency({
currencyCode:
product.currency.toLowerCase(),
value: primaryLineItem.cost,
locale,
})}
</span>
</Price>
@@ -424,7 +427,7 @@ function PlanDetails({
}
>
<div className={'flex flex-col space-y-0.5'}>
<Heading level={5}>
<span className={'text-sm font-medium'}>
<b>
<Trans
i18nKey={`billing:plans.${selectedProduct.id}.name`}
@@ -434,10 +437,10 @@ function PlanDetails({
<If condition={isRecurring}>
/ <Trans i18nKey={`billing:billingInterval.${selectedInterval}`} />
</If>
</Heading>
</span>
<p>
<span className={'text-muted-foreground'}>
<span className={'text-muted-foreground text-sm'}>
<Trans
i18nKey={`billing:plans.${selectedProduct.id}.description`}
defaults={selectedProduct.description}
@@ -489,7 +492,7 @@ function Price(props: React.PropsWithChildren) {
return (
<span
className={
'animate-in slide-in-from-left-4 fade-in text-xl font-bold duration-500'
'animate-in slide-in-from-left-4 fade-in text-xl font-semibold tracking-tight duration-500'
}
>
{props.children}

View File

@@ -29,6 +29,8 @@ interface Paths {
return: string;
}
type Interval = 'month' | 'year';
export function PricingTable({
config,
paths,
@@ -48,7 +50,7 @@ export function PricingTable({
highlighted?: boolean;
}>;
}) {
const intervals = getPlanIntervals(config).filter(Boolean) as string[];
const intervals = getPlanIntervals(config).filter(Boolean) as Interval[];
const [interval, setInterval] = useState(intervals[0]!);
return (
@@ -123,7 +125,7 @@ function PricingItem(
plan: {
id: string;
lineItems: z.infer<typeof LineItemSchema>[];
interval?: string;
interval?: Interval;
name?: string;
href?: string;
label?: string;
@@ -156,6 +158,8 @@ function PricingItem(
return item.type !== 'flat';
});
const interval = props.plan.interval as Interval;
return (
<div
data-cy={'subscription-plan'}
@@ -209,15 +213,14 @@ function PricingItem(
<Separator />
<div className={'flex flex-col space-y-1'}>
<div className={'flex flex-col space-y-2'}>
<Price>
{lineItem ? (
formatCurrency(props.product.currency, lineItem.cost)
) : props.plan.label ? (
<Trans i18nKey={props.plan.label} defaults={props.plan.label} />
) : (
<Trans i18nKey={'billing:custom'} />
)}
<LineItemPrice
plan={props.plan}
product={props.product}
interval={interval}
lineItem={lineItem}
/>
</Price>
<If condition={props.plan.name}>
@@ -337,15 +340,19 @@ function FeaturesList(
function Price({ children }: React.PropsWithChildren) {
return (
<div
className={`animate-in slide-in-from-left-4 fade-in items-center duration-500`}
className={`animate-in slide-in-from-left-4 fade-in flex items-end gap-2 duration-500`}
>
<span
className={
'font-heading flex items-center text-3xl font-bold tracking-tighter lg:text-4xl'
'font-heading flex items-center text-3xl font-semibold tracking-tighter'
}
>
{children}
</span>
<span className={'text-muted-foreground text-sm leading-loose'}>
<Trans i18nKey={'billing:perMonth'} />
</span>
</div>
);
}
@@ -368,9 +375,9 @@ function ListItem({ children }: React.PropsWithChildren) {
function PlanIntervalSwitcher(
props: React.PropsWithChildren<{
intervals: string[];
interval: string;
setInterval: (interval: string) => void;
intervals: Interval[];
interval: Interval;
setInterval: (interval: Interval) => void;
}>,
) {
return (
@@ -470,3 +477,40 @@ function DefaultCheckoutButton(
</Link>
);
}
function LineItemPrice({
lineItem,
plan,
interval,
product,
}: {
lineItem: z.infer<typeof LineItemSchema> | undefined;
plan: {
label?: string;
};
interval: Interval | undefined;
product: {
currency: string;
};
}) {
const { i18n } = useTranslation();
const isYearlyPricing = interval === 'year';
const cost = lineItem
? isYearlyPricing
? Number(lineItem.cost / 12).toFixed(2)
: lineItem?.cost
: 0;
const costString = lineItem && formatCurrency({
currencyCode: product.currency,
locale: i18n.language,
value: cost,
});
const labelString = plan.label && (
<Trans i18nKey={plan.label} defaults={plan.label} />
);
return costString ?? labelString ?? <Trans i18nKey={'billing:custom'} />;
}

View File

@@ -1,7 +1,8 @@
{
"extends": "@kit/tsconfig/base.json",
"compilerOptions": {
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json",
"types": ["react/experimental"]
},
"include": ["*.ts", "src"],
"exclude": ["node_modules"]