Perf improvements and billing updates
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@radix-ui/react-accordion": "1.1.2",
|
||||
"@radix-ui/react-avatar": "^1.0.4",
|
||||
"@radix-ui/react-checkbox": "^1.0.4",
|
||||
"@radix-ui/react-dialog": "^1.0.5",
|
||||
@@ -44,7 +45,6 @@
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0",
|
||||
"@tanstack/react-table": "^8.11.3",
|
||||
"@types/react": "^18.2.48",
|
||||
"@types/react-dom": "^18.2.18",
|
||||
"date-fns": "^3.2.0",
|
||||
@@ -67,6 +67,7 @@
|
||||
},
|
||||
"prettier": "@kit/prettier-config",
|
||||
"exports": {
|
||||
"./accordion": "./src/shadcn/accordion.tsx",
|
||||
"./avatar": "./src/shadcn/avatar.tsx",
|
||||
"./button": "./src/shadcn/button.tsx",
|
||||
"./calendar": "./src/shadcn/calendar.tsx",
|
||||
@@ -117,4 +118,4 @@
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
'use client';
|
||||
|
||||
import { useMemo } from 'react';
|
||||
|
||||
import Link from 'next/link';
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import { cn } from './utils';
|
||||
|
||||
const NavigationContainer: React.FC<{
|
||||
className?: string;
|
||||
}> = ({ children, className }) => {
|
||||
return (
|
||||
<div
|
||||
className={cn(`dark:border-dark-800 border-b border-gray-50`, className)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default NavigationContainer;
|
||||
@@ -1,124 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { useContext } from 'react';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
|
||||
import Trans from '@/components/app/Trans';
|
||||
import { cva } from 'class-variance-authority';
|
||||
|
||||
import isRouteActive from '@kit/generic/is-route-active';
|
||||
|
||||
import { NavigationMenuContext } from './navigation-menu-context';
|
||||
import { cn } from './utils';
|
||||
|
||||
interface Link {
|
||||
path: string;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
const NavigationMenuItem: React.FC<{
|
||||
link: Link;
|
||||
depth?: number;
|
||||
disabled?: boolean;
|
||||
shallow?: boolean;
|
||||
className?: string;
|
||||
}> = ({ link, disabled, shallow, depth, ...props }) => {
|
||||
const pathName = usePathname() ?? '';
|
||||
const active = isRouteActive(link.path, pathName, depth ?? 3);
|
||||
const menuProps = useContext(NavigationMenuContext);
|
||||
const label = link.label;
|
||||
|
||||
const itemClassName = getNavigationMenuItemClassBuilder()({
|
||||
active,
|
||||
...menuProps,
|
||||
});
|
||||
|
||||
const className = cn(itemClassName, props.className ?? ``);
|
||||
|
||||
return (
|
||||
<li className={className}>
|
||||
<Link
|
||||
className={
|
||||
'justify-center transition-transform duration-500 lg:justify-start'
|
||||
}
|
||||
aria-disabled={disabled}
|
||||
href={disabled ? '' : link.path}
|
||||
shallow={shallow ?? active}
|
||||
>
|
||||
<Trans i18nKey={label} defaults={label} />
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
};
|
||||
|
||||
export default NavigationMenuItem;
|
||||
|
||||
function getNavigationMenuItemClassBuilder() {
|
||||
return cva(
|
||||
[
|
||||
`flex items-center justify-center font-medium lg:justify-start rounded-md text-sm transition colors transform *:active:translate-y-[2px]`,
|
||||
'*:p-1 *:lg:px-2.5 *:s-full *:flex *:items-center',
|
||||
'aria-disabled:cursor-not-allowed aria-disabled:opacity-50',
|
||||
],
|
||||
{
|
||||
compoundVariants: [
|
||||
// not active - shared
|
||||
{
|
||||
active: false,
|
||||
className: `font-medium hover:underline`,
|
||||
},
|
||||
// active - shared
|
||||
{
|
||||
active: true,
|
||||
className: `font-semibold`,
|
||||
},
|
||||
// active - pill
|
||||
{
|
||||
active: true,
|
||||
pill: true,
|
||||
className: `bg-gray-50 text-gray-800 dark:bg-primary-300/10`,
|
||||
},
|
||||
// not active - pill
|
||||
{
|
||||
active: false,
|
||||
pill: true,
|
||||
className: `hover:bg-gray-50 active:bg-gray-100 text-gray-500 dark:text-gray-300 dark:hover:bg-background dark:active:bg-dark-900/90`,
|
||||
},
|
||||
// not active - bordered
|
||||
{
|
||||
active: false,
|
||||
bordered: true,
|
||||
className: `hover:bg-gray-50 active:bg-gray-100 dark:active:bg-dark-800 dark:hover:bg-dark/90 transition-colors rounded-lg border-transparent`,
|
||||
},
|
||||
// active - bordered
|
||||
{
|
||||
active: true,
|
||||
bordered: true,
|
||||
className: `top-[0.4rem] border-b-[0.25rem] rounded-none border-primary bg-transparent pb-[0.55rem] text-primary-700 dark:text-white`,
|
||||
},
|
||||
// active - secondary
|
||||
{
|
||||
active: true,
|
||||
secondary: true,
|
||||
className: `bg-transparent font-semibold`,
|
||||
},
|
||||
],
|
||||
variants: {
|
||||
active: {
|
||||
true: ``,
|
||||
},
|
||||
pill: {
|
||||
true: `[&>*]:py-2`,
|
||||
},
|
||||
bordered: {
|
||||
true: `relative h-10`,
|
||||
},
|
||||
secondary: {
|
||||
true: ``,
|
||||
},
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { createContext } from 'react';
|
||||
|
||||
import type { NavigationMenuProps } from './navigation-menu';
|
||||
|
||||
export const NavigationMenuContext = createContext<NavigationMenuProps>({});
|
||||
@@ -1,49 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import type { PropsWithChildren } from 'react';
|
||||
|
||||
import { cva } from 'class-variance-authority';
|
||||
|
||||
import { NavigationMenuContext } from './navigation-menu-context';
|
||||
|
||||
type Vertical = {
|
||||
vertical?: boolean;
|
||||
};
|
||||
|
||||
type Bordered = {
|
||||
bordered?: boolean;
|
||||
};
|
||||
|
||||
type Pill = {
|
||||
pill?: boolean;
|
||||
};
|
||||
|
||||
export type NavigationMenuProps = Vertical & (Bordered | Pill);
|
||||
|
||||
function NavigationMenu(props: PropsWithChildren<NavigationMenuProps>) {
|
||||
const className = getNavigationMenuClassBuilder()(props);
|
||||
|
||||
return (
|
||||
<ul className={className}>
|
||||
<NavigationMenuContext.Provider value={props}>
|
||||
{props.children}
|
||||
</NavigationMenuContext.Provider>
|
||||
</ul>
|
||||
);
|
||||
}
|
||||
|
||||
export default NavigationMenu;
|
||||
|
||||
function getNavigationMenuClassBuilder() {
|
||||
return cva(['w-full dark:text-gray-300 items-center flex-wrap flex'], {
|
||||
variants: {
|
||||
vertical: {
|
||||
true: `flex items-start justify-between space-x-2
|
||||
lg:flex-col lg:justify-start lg:space-x-0 lg:space-y-1.5 [&>li>a]:w-full`,
|
||||
},
|
||||
bordered: {
|
||||
true: `lg:space-x-3 border-b border-gray-100 dark:border-dark-800 pb-1.5`,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -21,7 +21,6 @@ function Spinner(
|
||||
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||
fill="currentColor"
|
||||
/>
|
||||
|
||||
<path
|
||||
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||
fill="currentFill"
|
||||
|
||||
58
packages/ui/src/shadcn/accordion.tsx
Normal file
58
packages/ui/src/shadcn/accordion.tsx
Normal file
@@ -0,0 +1,58 @@
|
||||
'use client';
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
||||
import { ChevronDownIcon } from '@radix-ui/react-icons';
|
||||
|
||||
import { cn } from '../utils';
|
||||
|
||||
const Accordion = AccordionPrimitive.Root;
|
||||
|
||||
const AccordionItem = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Item>,
|
||||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
|
||||
>(({ className, ...props }, ref) => (
|
||||
<AccordionPrimitive.Item
|
||||
ref={ref}
|
||||
className={cn('border-b', className)}
|
||||
{...props}
|
||||
/>
|
||||
));
|
||||
AccordionItem.displayName = 'AccordionItem';
|
||||
|
||||
const AccordionTrigger = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Trigger>,
|
||||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<AccordionPrimitive.Header className="flex">
|
||||
<AccordionPrimitive.Trigger
|
||||
ref={ref}
|
||||
className={cn(
|
||||
'flex flex-1 items-center justify-between py-4 text-sm font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
<ChevronDownIcon className="h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-200" />
|
||||
</AccordionPrimitive.Trigger>
|
||||
</AccordionPrimitive.Header>
|
||||
));
|
||||
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;
|
||||
|
||||
const AccordionContent = React.forwardRef<
|
||||
React.ElementRef<typeof AccordionPrimitive.Content>,
|
||||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
|
||||
>(({ className, children, ...props }, ref) => (
|
||||
<AccordionPrimitive.Content
|
||||
ref={ref}
|
||||
className="overflow-hidden text-sm data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down"
|
||||
{...props}
|
||||
>
|
||||
<div className={cn('pb-4 pt-0', className)}>{children}</div>
|
||||
</AccordionPrimitive.Content>
|
||||
));
|
||||
AccordionContent.displayName = AccordionPrimitive.Content.displayName;
|
||||
|
||||
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
|
||||
@@ -17,7 +17,7 @@ const badgeVariants = cva(
|
||||
'border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80',
|
||||
outline: 'text-foreground',
|
||||
success:
|
||||
'border-transparent bg-green-50 text-green-500 dark:bg-transparent',
|
||||
'border-transparent bg-green-50 text-green-500 dark:bg-green-500/20',
|
||||
warning:
|
||||
'border-transparent bg-orange-50 text-orange-500 dark:bg-transparent',
|
||||
info: 'border-transparent bg-blue-50 text-blue-500 dark:bg-transparent',
|
||||
|
||||
Reference in New Issue
Block a user