11 Commits
55 changed files with 4060 additions and 3835 deletions
-19
View File
@@ -1,19 +0,0 @@
module.exports = {
root: true,
env: { browser: true, es2020: true, node: false },
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"prettier",
],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
};
+2 -1
View File
@@ -1,4 +1,5 @@
{
"endOfLine": "lf",
"plugins": ["prettier-plugin-tailwindcss"]
"plugins": ["prettier-plugin-tailwindcss"],
"tailwindStylesheet": "./src/index.css"
}
+1 -1
View File
@@ -1,5 +1,5 @@
# Base Node Environment.
FROM node:21.7-alpine3.19 AS app-base
FROM node:22-alpine AS app-base
WORKDIR /app
ENV PATH=/app/node_modules/.bin:$PATH
COPY package.json ./
+3 -2
View File
@@ -4,7 +4,7 @@
"rsc": false,
"tsx": true,
"tailwind": {
"config": "tailwind.config.js",
"config": "",
"css": "src/index.css",
"baseColor": "stone",
"cssVariables": true,
@@ -16,5 +16,6 @@
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
}
},
"iconLibrary": "lucide"
}
+55
View File
@@ -0,0 +1,55 @@
const { defineConfig, globalIgnores } = require("eslint/config");
const globals = require("globals");
const { fixupConfigRules } = require("@eslint/compat");
const tsParser = require("@typescript-eslint/parser");
const reactRefresh = require("eslint-plugin-react-refresh");
const js = require("@eslint/js");
const { FlatCompat } = require("@eslint/eslintrc");
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
module.exports = defineConfig([
{
languageOptions: {
globals: {
...globals.browser,
...Object.fromEntries(
Object.entries(globals.node).map(([key]) => [key, "off"]),
),
},
parser: tsParser,
},
extends: fixupConfigRules(
compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"prettier",
),
),
plugins: {
"react-refresh": reactRefresh,
},
rules: {
"react-refresh/only-export-components": [
"warn",
{
allowConstantExport: true,
},
],
},
},
globalIgnores(["**/dist", "eslint.config.cjs"]),
]);
+2391 -2603
View File
File diff suppressed because it is too large Load Diff
+41 -36
View File
@@ -11,50 +11,55 @@
"preview": "vite preview"
},
"dependencies": {
"@hookform/resolvers": "^3.9.0",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
"@radix-ui/react-label": "^2.1.0",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.1.0",
"@radix-ui/react-toast": "^1.1.5",
"@radix-ui/react-tooltip": "^1.0.7",
"class-variance-authority": "^0.7.0",
"@hookform/resolvers": "^5.1.1",
"@radix-ui/react-checkbox": "^1.3.2",
"@radix-ui/react-dropdown-menu": "^2.1.15",
"@radix-ui/react-label": "^2.1.7",
"@radix-ui/react-popover": "^1.1.14",
"@radix-ui/react-separator": "^1.1.7",
"@radix-ui/react-slot": "^1.2.3",
"@radix-ui/react-toast": "^1.2.14",
"@radix-ui/react-tooltip": "^1.2.7",
"@tailwindcss/vite": "^4.1.8",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"date-fns": "^3.6.0",
"embla-carousel-react": "^8.0.2",
"lucide-react": "^0.378.0",
"date-fns": "^4.1.0",
"embla-carousel-react": "^8.6.0",
"lucide-react": "^0.513.0",
"react": "^18.2.0",
"react-day-picker": "^8.10.1",
"react-day-picker": "^9.7.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.53.0",
"react-hook-form": "^7.57.0",
"react-router-dom": "^6.23.0",
"swr": "^2.2.5",
"tailwind-merge": "^2.3.0",
"zod": "^3.23.8",
"zustand": "^4.5.2"
"swr": "^2.3.3",
"tailwind-merge": "^3.3.0",
"zod": "^3.25.57",
"zustand": "^5.0.5"
},
"devDependencies": {
"@types/node": "^20.12.8",
"@eslint/compat": "^1.2.9",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.28.0",
"@iconify-icon/react": "^3.0.0",
"@tailwindcss/postcss": "^4.1.8",
"@types/node": "^22.15.30",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
"@types/react-router-dom": "^5.3.3",
"@typescript-eslint/eslint-plugin": "^7.2.0",
"@typescript-eslint/parser": "^7.2.0",
"@vitejs/plugin-react-swc": "^3.5.0",
"autoprefixer": "^10.4.19",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.6",
"postcss": "^8.4.38",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.6",
"tailwindcss": "^3.4.3",
"tailwindcss-animate": "^1.0.7",
"typescript": "^5.2.2",
"vite": "^5.2.0"
"@typescript-eslint/eslint-plugin": "^8.34.0",
"@typescript-eslint/parser": "^8.34.0",
"@vitejs/plugin-react-swc": "^3.10.1",
"eslint": "^9.28.0",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.20",
"globals": "^16.2.0",
"postcss": "^8.5.4",
"prettier": "^3.5.3",
"prettier-plugin-tailwindcss": "^0.6.12",
"tailwindcss": "^4.1.8",
"tw-animate-css": "^1.3.4",
"typescript": "^5.8.3",
"vite": "^6.3.5"
}
}
+1 -2
View File
@@ -1,6 +1,5 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
'@tailwindcss/postcss': {},
},
};
+3 -3
View File
@@ -2,7 +2,7 @@ import { RoomCategory } from "@/model/RoomCategory";
import { fetcher, fetcherUnwraper } from "./backend";
import useSWR from "swr";
export function useAPIRoomCategories() {
export function useAPIRoomCategoryList() {
const { data, error, isLoading } = useSWR<RoomCategory[]>(
"/api/room/category",
fetcherUnwraper,
@@ -15,8 +15,8 @@ export function useAPIRoomCategories() {
};
}
export function useAPIRoomCategoryId(categoryId: number) {
const url = categoryId ? "/api/room/category/" + categoryId : null;
export function useAPIRoomCategory(categoryId: number) {
const url = `/api/room/category/${categoryId}`;
const { data, error, isLoading } = useSWR<RoomCategory>(url, fetcher);
+6 -3
View File
@@ -12,7 +12,8 @@ import {
export function useAPIRoomAvailability(filter: AvailabilityFilter | null) {
const request: AvailabilityRequest | null = filter
? {
filter: filter,
startDate: filter.startDate,
endDate: filter.endDate,
}
: null;
@@ -32,12 +33,14 @@ export function useAPIRoomAvailability(filter: AvailabilityFilter | null) {
export function useAPIRoomPrices(filter: FareFilter | null) {
const request: FareRequest | null = filter
? {
filter: filter,
roomCategory: filter.roomCategory,
startDate: filter.startDate,
endDate: filter.endDate,
}
: null;
const { data, isLoading, error } = useSWR(
request ? ["/api/search/fares", request] : null,
request ? ["/api/search/prices", request] : null,
([url, request]) => fetcherUnwraperWithFilter<RoomPrice[]>(url, request),
);
+36 -27
View File
@@ -1,6 +1,5 @@
import { useAPIRoomCategoryId } from "@/api/api-roomCategories";
import { useAPIRoomCategory } from "@/api/api-roomCategories";
import { Card, CardContent } from "../ui/card";
import { useMemo } from "react";
import { Typography } from "../ui/typography";
import {
Table,
@@ -12,14 +11,14 @@ import {
} from "../ui/table";
import { Skeleton } from "../ui/skeleton";
import { useAppStore } from "@/store";
import { DateRange } from "react-day-picker";
import { FareFilter } from "@/model/RoomSearch";
import { useAPIRoomPrices } from "@/api/api-roomSearch";
import { NumberSelector } from "../ui/number-selector";
import { NewBooking, NewBookingRoom } from "@/model/Bookings";
import { RoomItemCard } from "./room-item-card";
import { IconWithTooltip } from "../ui/icon-number-tooltip";
import { UserIcon } from "lucide-react";
import { makeFareFilterFromSearchFilter } from "@/utils/utils";
import { SearchFilter } from "@/model/InternalTypes";
function RoomBooking({
roomCategoryId,
@@ -28,12 +27,12 @@ function RoomBooking({
roomCategoryId: number;
availableAmount: number;
}) {
const currentDates: DateRange = useAppStore(
(state) => state.searchFilter.dateRange,
const appSearchFilter: SearchFilter = useAppStore(
(state) => state.searchFilter,
);
const addNewRoom = useAppStore((state) => state.addNewBookingRoom);
const addNewRoom = useAppStore((state) => state.currentBookingAddRoom);
const bookingRooms: NewBooking | null = useAppStore(
(state) => state.newBookingData,
(state) => state.currentBooking,
);
function onSelectedAmountUpdate(
@@ -59,34 +58,35 @@ function RoomBooking({
addNewRoom(newRoom);
}
const totalSelected = () => {
const getSelectedRoomAmount = (guestNumber: number | null) => {
let sum = 0;
bookingRooms &&
if (bookingRooms) {
//Rooms with same category and, if guestNumber is set, rooms with same guestNumber.
bookingRooms.rooms
.filter((v) => v.roomCategory == roomCategoryId)
.filter((v) => {
const isSameCat = v.roomCategory == roomCategoryId;
const isSameGuestNum =
guestNumber != null ? v.guestNumber == guestNumber : true;
return isSameCat && isSameGuestNum;
})
.forEach((v) => (sum += v.amount));
}
return sum;
};
const canAddMore: boolean = availableAmount > totalSelected();
const totalSelectAmount = getSelectedRoomAmount(null);
const canAddMoreRooms: boolean = availableAmount > totalSelectAmount;
//This seems a little bit overkill, but IDK.
const fareFilter: FareFilter | null = useMemo(() => {
if (currentDates && currentDates.from && currentDates.to) {
const filter: FareFilter = {
startDate: currentDates.from?.toDateString(),
endDate: currentDates.to?.toDateString(),
roomCategory: roomCategoryId,
};
return filter;
}
return null;
}, [currentDates, roomCategoryId]);
const fareFilter = makeFareFilterFromSearchFilter(
appSearchFilter,
roomCategoryId,
);
const {
roomCategory,
isLoading: isLoadingCategory,
isError: isErrorCategory,
} = useAPIRoomCategoryId(roomCategoryId);
} = useAPIRoomCategory(roomCategoryId);
const {
roomPriceList,
isLoading: isLoadingPrices,
@@ -111,9 +111,15 @@ function RoomBooking({
const hasPrices = roomPriceList != null && roomPriceList?.length > 0;
let priceTable = null;
if (hasPrices) {
const tableRows = roomPriceList?.map((el) => {
//A row for each room guestNumber.
let tableRows = null;
if (!isLoadingPrices) {
tableRows = roomPriceList?.map((el) => {
const selectedRoomAmount =
totalSelectAmount > 0 ? getSelectedRoomAmount(el.guestNumber) : 0;
return (
<TableRow key={el.guestNumber}>
<TableRow key={roomCategoryId + "-" + el.guestNumber}>
<TableCell>
<IconWithTooltip
label={el.guestNumber?.toString()}
@@ -129,13 +135,16 @@ function RoomBooking({
updateCount={(count) =>
onSelectedAmountUpdate(el.guestNumber, count, el.price)
}
addEnabled={canAddMore}
addEnabled={canAddMoreRooms}
initialValue={selectedRoomAmount}
></NumberSelector>
</TableCell>
</TableRow>
);
});
}
//Element for
priceTable = (
<Table className="overflow-hidden">
<TableHeader>
+23 -36
View File
@@ -1,11 +1,12 @@
import { Separator } from "../ui/separator";
import { Card, CardContent } from "../ui/card";
import { Typography } from "../ui/typography";
import { BedDoubleIcon, BedSingleIcon, UserIcon } from "lucide-react";
import { UserIcon } from "lucide-react";
import { RoomCategory, RoomCategoryPhoto } from "@/model/RoomCategory";
import { IconWithTooltip } from "../ui/icon-number-tooltip";
import roomImg from "@/res/SomniaRoomImage.svg";
import { cn } from "@/lib/utils";
import { Icon } from "@iconify-icon/react";
interface RoomItemCardProps {
room: RoomCategory;
@@ -16,38 +17,43 @@ const defaultRoom: RoomCategory = {
id: -1,
name: "Sample Room",
description: "Lorem Ipsum",
bedType: "0,1",
maxGuestNum: 2,
roomCategoryDetails: [],
orderHomePage: undefined,
roomCategoryPhotos: [],
roomCategoryBedTypes: [],
};
export function RoomItemCard({
room = defaultRoom,
className,
}: RoomItemCardProps) {
const mainPhoto: RoomCategoryPhoto | undefined = room.roomCategoryPhotos.find(
(element) => {
return (element.kind = "main");
},
//FIXME: Use PhotoOrder.
const mainPhoto: RoomCategoryPhoto | undefined =
room.roomCategoryPhotos.length > 0
? room.roomCategoryPhotos.at(0)
: undefined;
const bedTypeIconList = room.roomCategoryBedTypes.map((e) => {
return (
<IconWithTooltip
key={room.id.toString() + e.bedTypeIcon}
tooltipText={e.bedTypeName}
label={e.amount.toString()}
>
<Icon icon={e.bedTypeIcon} height="auto" />
</IconWithTooltip>
);
const bedTypeList: number[] = room.bedType
.split(",")
.map((e) => Number.parseInt(e));
const hasSingleBed: boolean =
bedTypeList.at(0) !== undefined && bedTypeList[0] > 0;
const hasDoubleBed: boolean =
bedTypeList.at(1) !== undefined && bedTypeList[1] > 0;
});
return (
<Card id={room.id.toString()} className={cn(className, "relative")}>
<Card key={room.id} className={cn(className, "relative", "py-0")}>
{/* <CardHeader className="p-0 m-0 mb-5">
</CardHeader> */}
<CardContent className="flex h-full w-full flex-col p-0">
<div className="">
<img
src={mainPhoto?.path ?? roomImg}
className="aspect-[4/3] w-full rounded-t-md object-cover"
className="aspect-4/3 w-full rounded-t-md object-cover"
></img>
<Separator className="my-0 border-2" />
</div>
@@ -64,26 +70,7 @@ export function RoomItemCard({
<div className="mt-auto pb-4">
<Separator className="my-4" />
<div className="flex justify-around">
<div className="flex flex-row gap-2">
{hasSingleBed && (
<IconWithTooltip
tooltipText="Single bed"
label={bedTypeList[0]?.toString()}
>
<BedSingleIcon />
</IconWithTooltip>
)}
{hasDoubleBed && (
<>
<IconWithTooltip
tooltipText="Double bed"
label={bedTypeList[1]?.toString()}
>
<BedDoubleIcon />
</IconWithTooltip>
</>
)}
</div>
<div className="flex flex-row gap-2">{bedTypeIconList}</div>
<div className="flex flex-row">
<IconWithTooltip
tooltipText="Max. gests"
+7 -18
View File
@@ -6,37 +6,28 @@ import { DatePickerWithRange } from "../ui/dateRange-picker";
import { Button } from "../ui/button";
import { SearchIcon } from "lucide-react";
import { useState } from "react";
import { SearchFilter } from "@/model/SearchFilter";
import { SearchFilter } from "@/model/InternalTypes";
import { DateRange } from "react-day-picker";
import { useToast } from "../ui/use-toast";
import { useAppStore } from "@/store";
type funOnSearchClick = (newFilter: SearchFilter) => void;
export function SearchFilterCard({
onSearchClick,
initialsearchFilter,
}: {
onSearchClick?: funOnSearchClick;
initialsearchFilter?: SearchFilter;
}) {
//App filter. Updated on btSearchClick.
const appSearchFilter = useAppStore((state) => state.searchFilter);
const setAppSearchFilter = useAppStore((state) => state.setSearchFilter);
//Local Filter state.
const [searchFilter, setSearchFilter] =
useState<SearchFilter>(appSearchFilter);
//On location change, try to load searchFilter from state.
//FIXME: Si llegamos sin state, hay que borrar el state global...
// const location = useLocation();
// useEffect(() => {
// setSearchFilter(location.state);
// }, [location]);
const [searchFilter, setSearchFilter] = useState<SearchFilter | null>(
initialsearchFilter ?? null,
);
const { toast } = useToast();
// Validate and call callback on btSearch click.
//TODOME: Add data validations and show messages.
//TODOME: Add data validations and show messages as form instead of toasts.
const btSearchClick = () => {
if (!searchFilter || !searchFilter.dateRange) {
toast({
@@ -55,8 +46,6 @@ export function SearchFilterCard({
return;
}
setAppSearchFilter(searchFilter);
if (onSearchClick) {
onSearchClick(searchFilter);
}
+2 -2
View File
@@ -7,7 +7,7 @@ import { BookAIcon, HomeIcon } from "lucide-react";
function AppHeader() {
return (
<Card className="mx-10 my-4 flex items-center">
<Card className="mx-10 my-4 flex items-center py-0">
<CardContent className="w-full py-2">
<div className="flex items-center justify-around">
<div className="relative flex flex-row items-center gap-2">
@@ -15,7 +15,7 @@ function AppHeader() {
<Typography variant={"largeText"}>Somnia Rooms</Typography>
<a
href="https://duck.com"
className="absolute h-[100%] w-[100%]"
className="absolute h-full w-full"
></a>
</div>
<Button variant="ghost" className="h-15">
+4 -4
View File
@@ -4,7 +4,7 @@ import { Typography } from "../ui/typography";
import { differenceInDays } from "date-fns";
import { Separator } from "../ui/separator";
import { Button } from "../ui/button";
import { useAPIRoomCategories } from "@/api/api-roomCategories";
import { useAPIRoomCategoryList } from "@/api/api-roomCategories";
import { IconWithTooltip } from "../ui/icon-number-tooltip";
import { UserIcon } from "lucide-react";
@@ -18,8 +18,8 @@ export function BookingDetails({
onBookingConfirm?: OnBookingClickFunction;
mode: BookingDetailsModes;
}) {
const bookingData = useAppStore((state) => state.newBookingData);
const roomCategoryList = useAPIRoomCategories();
const bookingData = useAppStore((state) => state.currentBooking);
const roomCategoryList = useAPIRoomCategoryList();
const onBtBookingClick = () => {
if (onBookingConfirm) {
@@ -51,7 +51,7 @@ export function BookingDetails({
return (
<Card
key={room.roomCategory.toString() + room.guestNumber.toString()}
className="my-3 flex flex-row bg-accent"
className="my-3 flex flex-row bg-accent py-0"
>
{photo && (
<img
+5 -2
View File
@@ -1,4 +1,4 @@
import { MoonIcon, SunIcon } from "@radix-ui/react-icons";
import { MonitorIcon, MoonIcon, SunIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import {
@@ -14,7 +14,7 @@ export function ModeToggle() {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<DropdownMenuTrigger>
<Button variant="outline" size="icon">
<SunIcon className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
<MoonIcon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
@@ -23,12 +23,15 @@ export function ModeToggle() {
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => setTheme("light")}>
<SunIcon className="h-[1.2rem] w-[1.2rem] scale-100" />
Light
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme("dark")}>
<MoonIcon className="h-[1.2rem] w-[1.2rem] scale-100" />
Dark
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme("system")}>
<MonitorIcon className="h-[1.2rem] w-[1.2rem] scale-100" />
System
</DropdownMenuItem>
</DropdownMenuContent>
+22 -11
View File
@@ -1,20 +1,22 @@
import * as React from "react";
import { Slot } from "@radix-ui/react-slot";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
const badgeVariants = cva(
"inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
"inline-flex items-center justify-center rounded-md border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
{
variants: {
variant: {
default:
"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
secondary:
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",
destructive:
"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
outline: "text-foreground",
"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
outline:
"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground",
},
},
defaultVariants: {
@@ -23,14 +25,23 @@ const badgeVariants = cva(
},
);
export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}
function Badge({
className,
variant,
asChild = false,
...props
}: React.ComponentProps<"span"> &
VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
const Comp = asChild ? Slot : "span";
function Badge({ className, variant, ...props }: BadgeProps) {
return (
<div className={cn(badgeVariants({ variant }), className)} {...props} />
<Comp
data-slot="badge"
className={cn(badgeVariants({ variant }), className)}
{...props}
/>
);
}
export { Badge };
// eslint-disable-next-line react-refresh/only-export-components
export { Badge, badgeVariants };
+23 -21
View File
@@ -5,26 +5,27 @@ import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
const buttonVariants = cva(
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
{
variants: {
variant: {
default:
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
destructive:
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
outline:
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
secondary:
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
ghost: "hover:bg-accent hover:text-accent-foreground",
"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
ghost:
"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
link: "text-primary underline-offset-4 hover:underline",
},
size: {
default: "h-9 px-4 py-2",
sm: "h-8 rounded-md px-3 text-xs",
lg: "h-10 rounded-md px-8",
icon: "h-9 w-9",
default: "h-9 px-4 py-2 has-[>svg]:px-3",
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
icon: "size-9",
},
},
defaultVariants: {
@@ -34,25 +35,26 @@ const buttonVariants = cva(
},
);
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
function Button({
className,
variant,
size,
asChild = false,
...props
}: React.ComponentProps<"button"> &
VariantProps<typeof buttonVariants> & {
asChild?: boolean;
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
}) {
const Comp = asChild ? Slot : "button";
return (
<Comp
data-slot="button"
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
);
},
);
Button.displayName = "Button";
}
// eslint-disable-next-line react-refresh/only-export-components
export { Button, buttonVariants };
+182 -44
View File
@@ -1,70 +1,208 @@
import * as React from "react";
import { ChevronLeftIcon, ChevronRightIcon } from "@radix-ui/react-icons";
import { DayPicker } from "react-day-picker";
import {
ChevronDownIcon,
ChevronLeftIcon,
ChevronRightIcon,
} from "lucide-react";
import { DayButton, DayPicker, getDefaultClassNames } from "react-day-picker";
import { cn } from "@/lib/utils";
import { buttonVariants } from "@/components/ui/button";
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
import { Button, buttonVariants } from "@/components/ui/button";
function Calendar({
className,
classNames,
showOutsideDays = true,
captionLayout = "label",
buttonVariant = "ghost",
formatters,
components,
...props
}: CalendarProps) {
}: React.ComponentProps<typeof DayPicker> & {
buttonVariant?: React.ComponentProps<typeof Button>["variant"];
}) {
const defaultClassNames = getDefaultClassNames();
return (
<DayPicker
showOutsideDays={showOutsideDays}
className={cn("p-3", className)}
className={cn(
"group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
className,
)}
captionLayout={captionLayout}
formatters={{
formatMonthDropdown: (date) =>
date.toLocaleString("default", { month: "short" }),
...formatters,
}}
classNames={{
months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
month: "space-y-4",
caption: "flex justify-center pt-1 relative items-center",
caption_label: "text-sm font-medium",
nav: "space-x-1 flex items-center",
nav_button: cn(
buttonVariants({ variant: "outline" }),
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100",
root: cn("w-fit", defaultClassNames.root),
months: cn(
"flex gap-4 flex-col md:flex-row relative",
defaultClassNames.months,
),
nav_button_previous: "absolute left-1",
nav_button_next: "absolute right-1",
table: "w-full border-collapse space-y-1",
head_row: "flex",
head_cell:
"text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]",
row: "flex w-full mt-2",
cell: cn(
"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md",
props.mode === "range"
? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md"
: "[&:has([aria-selected])]:rounded-md",
month: cn("flex flex-col w-full gap-4", defaultClassNames.month),
nav: cn(
"flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",
defaultClassNames.nav,
),
button_previous: cn(
buttonVariants({ variant: buttonVariant }),
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
defaultClassNames.button_previous,
),
button_next: cn(
buttonVariants({ variant: buttonVariant }),
"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",
defaultClassNames.button_next,
),
month_caption: cn(
"flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",
defaultClassNames.month_caption,
),
dropdowns: cn(
"w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",
defaultClassNames.dropdowns,
),
dropdown_root: cn(
"relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md",
defaultClassNames.dropdown_root,
),
dropdown: cn("absolute inset-0 opacity-0", defaultClassNames.dropdown),
caption_label: cn(
"select-none font-medium",
captionLayout === "label"
? "text-sm"
: "rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5",
defaultClassNames.caption_label,
),
table: "w-full border-collapse",
weekdays: cn("flex", defaultClassNames.weekdays),
weekday: cn(
"text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none",
defaultClassNames.weekday,
),
week: cn("flex w-full mt-2", defaultClassNames.week),
week_number_header: cn(
"select-none w-(--cell-size)",
defaultClassNames.week_number_header,
),
week_number: cn(
"text-[0.8rem] select-none text-muted-foreground",
defaultClassNames.week_number,
),
day: cn(
buttonVariants({ variant: "ghost" }),
"h-8 w-8 p-0 font-normal aria-selected:opacity-100",
"relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",
defaultClassNames.day,
),
day_range_start: "day-range-start",
day_range_end: "day-range-end",
day_selected:
"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
day_today: "bg-accent text-accent-foreground",
day_outside:
"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
day_disabled: "text-muted-foreground opacity-50",
day_range_middle:
"aria-selected:bg-accent aria-selected:text-accent-foreground",
day_hidden: "invisible",
range_start: cn(
"rounded-l-md bg-accent",
defaultClassNames.range_start,
),
range_middle: cn("rounded-none", defaultClassNames.range_middle),
range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
today: cn(
"bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none",
defaultClassNames.today,
),
outside: cn(
"text-muted-foreground aria-selected:text-muted-foreground",
defaultClassNames.outside,
),
disabled: cn(
"text-muted-foreground opacity-50",
defaultClassNames.disabled,
),
hidden: cn("invisible", defaultClassNames.hidden),
...classNames,
}}
components={{
IconLeft: () => <ChevronLeftIcon className="h-4 w-4" />,
IconRight: () => <ChevronRightIcon className="h-4 w-4" />,
Root: ({ className, rootRef, ...props }) => {
return (
<div
data-slot="calendar"
ref={rootRef}
className={cn(className)}
{...props}
/>
);
},
Chevron: ({ className, orientation, ...props }) => {
if (orientation === "left") {
return (
<ChevronLeftIcon className={cn("size-4", className)} {...props} />
);
}
if (orientation === "right") {
return (
<ChevronRightIcon
className={cn("size-4", className)}
{...props}
/>
);
}
return (
<ChevronDownIcon className={cn("size-4", className)} {...props} />
);
},
DayButton: CalendarDayButton,
WeekNumber: ({ children, ...props }) => {
return (
<td {...props}>
<div className="flex size-(--cell-size) items-center justify-center text-center">
{children}
</div>
</td>
);
},
...components,
}}
{...props}
/>
);
}
Calendar.displayName = "Calendar";
export { Calendar };
function CalendarDayButton({
className,
day,
modifiers,
...props
}: React.ComponentProps<typeof DayButton>) {
const defaultClassNames = getDefaultClassNames();
const ref = React.useRef<HTMLButtonElement>(null);
React.useEffect(() => {
if (modifiers.focused) ref.current?.focus();
}, [modifiers.focused]);
return (
<Button
ref={ref}
variant="ghost"
size="icon"
data-day={day.date.toLocaleDateString()}
data-selected-single={
modifiers.selected &&
!modifiers.range_start &&
!modifiers.range_end &&
!modifiers.range_middle
}
data-range-start={modifiers.range_start}
data-range-end={modifiers.range_end}
data-range-middle={modifiers.range_middle}
className={cn(
"flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-accent-foreground [&>span]:text-xs [&>span]:opacity-70",
defaultClassNames.day,
className,
)}
{...props}
/>
);
}
export { Calendar, CalendarDayButton };
+58 -49
View File
@@ -2,82 +2,91 @@ import * as React from "react";
import { cn } from "@/lib/utils";
const Card = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
function Card({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
ref={ref}
data-slot="card"
className={cn(
"rounded-xl border bg-card text-card-foreground shadow",
"flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",
className,
)}
{...props}
/>
));
Card.displayName = "Card";
);
}
const CardHeader = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
ref={ref}
className={cn("flex flex-col space-y-1.5 p-6", className)}
data-slot="card-header"
className={cn(
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
className,
)}
{...props}
/>
));
CardHeader.displayName = "CardHeader";
);
}
const CardTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h3
ref={ref}
className={cn("font-semibold leading-none tracking-tight", className)}
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-title"
className={cn("leading-none font-semibold", className)}
{...props}
/>
));
CardTitle.displayName = "CardTitle";
);
}
const CardDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<p
ref={ref}
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-description"
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
));
CardDescription.displayName = "CardDescription";
);
}
const CardContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
));
CardContent.displayName = "CardContent";
const CardFooter = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
ref={ref}
className={cn("flex items-center p-6 pt-0", className)}
data-slot="card-action"
className={cn(
"col-start-2 row-span-2 row-start-1 self-start justify-self-end",
className,
)}
{...props}
/>
));
CardFooter.displayName = "CardFooter";
);
}
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-content"
className={cn("px-6", className)}
{...props}
/>
);
}
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
data-slot="card-footer"
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
{...props}
/>
);
}
export {
Card,
CardHeader,
CardFooter,
CardTitle,
CardAction,
CardDescription,
CardContent,
};
+40 -61
View File
@@ -1,8 +1,8 @@
import * as React from "react";
import { ArrowLeftIcon, ArrowRightIcon } from "@radix-ui/react-icons";
import useEmblaCarousel, {
type UseEmblaCarouselType,
} from "embla-carousel-react";
import { ArrowLeft, ArrowRight } from "lucide-react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
@@ -40,12 +40,7 @@ function useCarousel() {
return context;
}
const Carousel = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> & CarouselProps
>(
(
{
function Carousel({
orientation = "horizontal",
opts,
setApi,
@@ -53,9 +48,7 @@ const Carousel = React.forwardRef<
className,
children,
...props
},
ref,
) => {
}: React.ComponentProps<"div"> & CarouselProps) {
const [carouselRef, api] = useEmblaCarousel(
{
...opts,
@@ -67,10 +60,7 @@ const Carousel = React.forwardRef<
const [canScrollNext, setCanScrollNext] = React.useState(false);
const onSelect = React.useCallback((api: CarouselApi) => {
if (!api) {
return;
}
if (!api) return;
setCanScrollPrev(api.canScrollPrev());
setCanScrollNext(api.canScrollNext());
}, []);
@@ -97,18 +87,12 @@ const Carousel = React.forwardRef<
);
React.useEffect(() => {
if (!api || !setApi) {
return;
}
if (!api || !setApi) return;
setApi(api);
}, [api, setApi]);
React.useEffect(() => {
if (!api) {
return;
}
if (!api) return;
onSelect(api);
api.on("reInit", onSelect);
api.on("select", onSelect);
@@ -133,31 +117,29 @@ const Carousel = React.forwardRef<
}}
>
<div
ref={ref}
onKeyDownCapture={handleKeyDown}
className={cn("relative", className)}
role="region"
aria-roledescription="carousel"
data-slot="carousel"
{...props}
>
{children}
</div>
</CarouselContext.Provider>
);
},
);
Carousel.displayName = "Carousel";
}
const CarouselContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => {
function CarouselContent({ className, ...props }: React.ComponentProps<"div">) {
const { carouselRef, orientation } = useCarousel();
return (
<div ref={carouselRef} className="overflow-hidden">
<div
ref={ref}
ref={carouselRef}
className="overflow-hidden"
data-slot="carousel-content"
>
<div
className={cn(
"flex",
orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col",
@@ -167,20 +149,16 @@ const CarouselContent = React.forwardRef<
/>
</div>
);
});
CarouselContent.displayName = "CarouselContent";
}
const CarouselItem = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => {
function CarouselItem({ className, ...props }: React.ComponentProps<"div">) {
const { orientation } = useCarousel();
return (
<div
ref={ref}
role="group"
aria-roledescription="slide"
data-slot="carousel-item"
className={cn(
"min-w-0 shrink-0 grow-0 basis-full",
orientation === "horizontal" ? "pl-4" : "pt-4",
@@ -189,24 +167,25 @@ const CarouselItem = React.forwardRef<
{...props}
/>
);
});
CarouselItem.displayName = "CarouselItem";
}
const CarouselPrevious = React.forwardRef<
HTMLButtonElement,
React.ComponentProps<typeof Button>
>(({ className, variant = "outline", size = "icon", ...props }, ref) => {
function CarouselPrevious({
className,
variant = "outline",
size = "icon",
...props
}: React.ComponentProps<typeof Button>) {
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
return (
<Button
ref={ref}
data-slot="carousel-previous"
variant={variant}
size={size}
className={cn(
"absolute h-8 w-8 rounded-full",
"absolute size-8 rounded-full",
orientation === "horizontal"
? "-left-12 top-1/2 -translate-y-1/2"
? "top-1/2 -left-12 -translate-y-1/2"
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
className,
)}
@@ -214,28 +193,29 @@ const CarouselPrevious = React.forwardRef<
onClick={scrollPrev}
{...props}
>
<ArrowLeftIcon className="h-4 w-4" />
<ArrowLeft />
<span className="sr-only">Previous slide</span>
</Button>
);
});
CarouselPrevious.displayName = "CarouselPrevious";
}
const CarouselNext = React.forwardRef<
HTMLButtonElement,
React.ComponentProps<typeof Button>
>(({ className, variant = "outline", size = "icon", ...props }, ref) => {
function CarouselNext({
className,
variant = "outline",
size = "icon",
...props
}: React.ComponentProps<typeof Button>) {
const { orientation, scrollNext, canScrollNext } = useCarousel();
return (
<Button
ref={ref}
data-slot="carousel-next"
variant={variant}
size={size}
className={cn(
"absolute h-8 w-8 rounded-full",
"absolute size-8 rounded-full",
orientation === "horizontal"
? "-right-12 top-1/2 -translate-y-1/2"
? "top-1/2 -right-12 -translate-y-1/2"
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
className,
)}
@@ -243,12 +223,11 @@ const CarouselNext = React.forwardRef<
onClick={scrollNext}
{...props}
>
<ArrowRightIcon className="h-4 w-4" />
<ArrowRight />
<span className="sr-only">Next slide</span>
</Button>
);
});
CarouselNext.displayName = "CarouselNext";
}
export {
type CarouselApi,
+13 -11
View File
@@ -1,28 +1,30 @@
import * as React from "react";
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
import { CheckIcon } from "@radix-ui/react-icons";
import { CheckIcon } from "lucide-react";
import { cn } from "@/lib/utils";
const Checkbox = React.forwardRef<
React.ElementRef<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(({ className, ...props }, ref) => (
function Checkbox({
className,
...props
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
return (
<CheckboxPrimitive.Root
ref={ref}
data-slot="checkbox"
className={cn(
"peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
"peer size-4 shrink-0 rounded-[4px] border border-input shadow-xs transition-shadow outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:bg-input/30 dark:aria-invalid:ring-destructive/40 dark:data-[state=checked]:bg-primary",
className,
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn("flex items-center justify-center text-current")}
data-slot="checkbox-indicator"
className="flex items-center justify-center text-current transition-none"
>
<CheckIcon className="h-4 w-4" />
<CheckIcon className="size-3.5" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
));
Checkbox.displayName = CheckboxPrimitive.Root.displayName;
);
}
export { Checkbox };
+14 -24
View File
@@ -1,14 +1,8 @@
"use client";
import * as React from "react";
import { CalendarIcon } from "@radix-ui/react-icons";
import { format } from "date-fns";
import {
ActiveModifiers,
DateBefore,
DateRange,
Matcher,
} from "react-day-picker";
import { DateBefore, DateRange, Matcher, Modifiers } from "react-day-picker";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
@@ -19,6 +13,7 @@ import {
PopoverTrigger,
} from "@/components/ui/popover";
import { Typography } from "./typography";
import { CalendarIcon } from "lucide-react";
export type UpdateRangeFunction = (newRange: DateRange) => void;
@@ -43,7 +38,7 @@ export function DatePickerWithRange({
//TODOME: Si el día es mods.outside, navegar al mes correspondiente.
// Handle Day change events.
const handleDayClickFrom = (day: Date, mods: ActiveModifiers) => {
const handleDayClickFrom = (day: Date, mods: Modifiers) => {
const newDateRange: DateRange = {
from: mods.selected ? undefined : day,
to: undefined,
@@ -52,7 +47,7 @@ export function DatePickerWithRange({
fnUpdateRange(newDateRange);
};
const handleDayClickTo = (day: Date, mods: ActiveModifiers) => {
const handleDayClickTo = (day: Date, mods: Modifiers) => {
const newDateRange: DateRange = {
from: dateRange?.from,
to: mods.selected ? undefined : day,
@@ -90,18 +85,16 @@ export function DatePickerWithRange({
Hasta
</Typography>
<Popover>
<PopoverTrigger asChild>
<PopoverTrigger>
<Button
id="dateFrom"
variant={"outline"}
className={cn(
"justify-start text-left font-normal",
!dateRange && "text-muted-foreground",
)}
variant="outline"
data-empty={!dateRange}
className="w-[100%] justify-start text-left font-normal data-[empty=true]:text-muted-foreground"
>
<CalendarIcon className="mr-2 h-4 w-4" />
<CalendarIcon />
{dateRange?.from ? (
format(dateRange.from, "LLL dd, y")
format(dateRange.from, "PPP")
) : (
<span>Pick a date</span>
)}
@@ -109,7 +102,6 @@ export function DatePickerWithRange({
</PopoverTrigger>
<PopoverContent className="w-auto p-0" align="center">
<Calendar
initialFocus
mode="single"
defaultMonth={dateRange?.from}
selected={dateRange?.from}
@@ -120,14 +112,12 @@ export function DatePickerWithRange({
</PopoverContent>
</Popover>
<Popover>
<PopoverTrigger asChild>
<PopoverTrigger>
<Button
id="dateTo"
variant={"outline"}
className={cn(
"justify-start text-left font-normal",
!dateRange && "text-muted-foreground",
)}
data-empty={!dateRange}
className="w-[100%] justify-start text-left font-normal data-[empty=true]:text-muted-foreground"
>
<CalendarIcon className="mr-2 h-4 w-4" />
{dateRange?.to ? (
@@ -139,7 +129,7 @@ export function DatePickerWithRange({
</PopoverTrigger>
<PopoverContent className="w-auto p-0" align="center">
<Calendar
initialFocus
autoFocus
mode="single"
defaultMonth={dateRange?.to ?? dateRange?.from}
selected={dateRange?.to}
+175 -123
View File
@@ -1,203 +1,255 @@
import * as React from "react";
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
import {
CheckIcon,
ChevronRightIcon,
DotFilledIcon,
} from "@radix-ui/react-icons";
import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
import { cn } from "@/lib/utils";
const DropdownMenu = DropdownMenuPrimitive.Root;
function DropdownMenu({
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />;
}
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
function DropdownMenuPortal({
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Portal>) {
return (
<DropdownMenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
);
}
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
const DropdownMenuSubTrigger = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
inset?: boolean;
}
>(({ className, inset, children, ...props }, ref) => (
<DropdownMenuPrimitive.SubTrigger
ref={ref}
className={cn(
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
inset && "pl-8",
className,
)}
{...props}
>
{children}
<ChevronRightIcon className="ml-auto h-4 w-4" />
</DropdownMenuPrimitive.SubTrigger>
));
DropdownMenuSubTrigger.displayName =
DropdownMenuPrimitive.SubTrigger.displayName;
const DropdownMenuSubContent = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent>
>(({ className, ...props }, ref) => (
<DropdownMenuPrimitive.SubContent
ref={ref}
className={cn(
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className,
)}
function DropdownMenuTrigger({
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>) {
return (
<DropdownMenuPrimitive.Trigger
data-slot="dropdown-menu-trigger"
{...props}
/>
));
DropdownMenuSubContent.displayName =
DropdownMenuPrimitive.SubContent.displayName;
);
}
const DropdownMenuContent = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
function DropdownMenuContent({
className,
sideOffset = 4,
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
return (
<DropdownMenuPrimitive.Portal>
<DropdownMenuPrimitive.Content
ref={ref}
data-slot="dropdown-menu-content"
sideOffset={sideOffset}
className={cn(
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
className,
)}
{...props}
/>
</DropdownMenuPrimitive.Portal>
));
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
);
}
const DropdownMenuItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
function DropdownMenuGroup({
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Group>) {
return (
<DropdownMenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
);
}
function DropdownMenuItem({
className,
inset,
variant = "default",
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Item> & {
inset?: boolean;
}
>(({ className, inset, ...props }, ref) => (
variant?: "default" | "destructive";
}) {
return (
<DropdownMenuPrimitive.Item
ref={ref}
data-slot="dropdown-menu-item"
data-inset={inset}
data-variant={variant}
className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
inset && "pl-8",
"relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:!text-destructive",
className,
)}
{...props}
/>
));
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
);
}
const DropdownMenuCheckboxItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
>(({ className, children, checked, ...props }, ref) => (
function DropdownMenuCheckboxItem({
className,
children,
checked,
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.CheckboxItem>) {
return (
<DropdownMenuPrimitive.CheckboxItem
ref={ref}
data-slot="dropdown-menu-checkbox-item"
className={cn(
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
"relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className,
)}
checked={checked}
{...props}
>
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
<DropdownMenuPrimitive.ItemIndicator>
<CheckIcon className="h-4 w-4" />
<CheckIcon className="size-4" />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
</DropdownMenuPrimitive.CheckboxItem>
));
DropdownMenuCheckboxItem.displayName =
DropdownMenuPrimitive.CheckboxItem.displayName;
);
}
const DropdownMenuRadioItem = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
>(({ className, children, ...props }, ref) => (
function DropdownMenuRadioGroup({
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioGroup>) {
return (
<DropdownMenuPrimitive.RadioGroup
data-slot="dropdown-menu-radio-group"
{...props}
/>
);
}
function DropdownMenuRadioItem({
className,
children,
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.RadioItem>) {
return (
<DropdownMenuPrimitive.RadioItem
ref={ref}
data-slot="dropdown-menu-radio-item"
className={cn(
"relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
"relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className,
)}
{...props}
>
<span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<span className="pointer-events-none absolute left-2 flex size-3.5 items-center justify-center">
<DropdownMenuPrimitive.ItemIndicator>
<DotFilledIcon className="h-4 w-4 fill-current" />
<CircleIcon className="size-2 fill-current" />
</DropdownMenuPrimitive.ItemIndicator>
</span>
{children}
</DropdownMenuPrimitive.RadioItem>
));
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
);
}
const DropdownMenuLabel = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
function DropdownMenuLabel({
className,
inset,
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Label> & {
inset?: boolean;
}
>(({ className, inset, ...props }, ref) => (
}) {
return (
<DropdownMenuPrimitive.Label
ref={ref}
data-slot="dropdown-menu-label"
data-inset={inset}
className={cn(
"px-2 py-1.5 text-sm font-semibold",
inset && "pl-8",
"px-2 py-1.5 text-sm font-medium data-[inset]:pl-8",
className,
)}
{...props}
/>
));
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
);
}
const DropdownMenuSeparator = React.forwardRef<
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
>(({ className, ...props }, ref) => (
<DropdownMenuPrimitive.Separator
ref={ref}
className={cn("-mx-1 my-1 h-px bg-muted", className)}
{...props}
/>
));
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
const DropdownMenuShortcut = ({
function DropdownMenuSeparator({
className,
...props
}: React.HTMLAttributes<HTMLSpanElement>) => {
}: React.ComponentProps<typeof DropdownMenuPrimitive.Separator>) {
return (
<span
className={cn("ml-auto text-xs tracking-widest opacity-60", className)}
<DropdownMenuPrimitive.Separator
data-slot="dropdown-menu-separator"
className={cn("-mx-1 my-1 h-px bg-border", className)}
{...props}
/>
);
};
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
}
function DropdownMenuShortcut({
className,
...props
}: React.ComponentProps<"span">) {
return (
<span
data-slot="dropdown-menu-shortcut"
className={cn(
"ml-auto text-xs tracking-widest text-muted-foreground",
className,
)}
{...props}
/>
);
}
function DropdownMenuSub({
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Sub>) {
return <DropdownMenuPrimitive.Sub data-slot="dropdown-menu-sub" {...props} />;
}
function DropdownMenuSubTrigger({
className,
inset,
children,
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubTrigger> & {
inset?: boolean;
}) {
return (
<DropdownMenuPrimitive.SubTrigger
data-slot="dropdown-menu-sub-trigger"
data-inset={inset}
className={cn(
"flex cursor-default items-center rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[inset]:pl-8 data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
className,
)}
{...props}
>
{children}
<ChevronRightIcon className="ml-auto size-4" />
</DropdownMenuPrimitive.SubTrigger>
);
}
function DropdownMenuSubContent({
className,
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
return (
<DropdownMenuPrimitive.SubContent
data-slot="dropdown-menu-sub-content"
className={cn(
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg",
className,
)}
{...props}
/>
);
}
export {
DropdownMenu,
DropdownMenuPortal,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuLabel,
DropdownMenuItem,
DropdownMenuCheckboxItem,
DropdownMenuRadioGroup,
DropdownMenuRadioItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuGroup,
DropdownMenuPortal,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuRadioGroup,
DropdownMenuSubContent,
};
+33 -44
View File
@@ -3,11 +3,12 @@ import * as LabelPrimitive from "@radix-ui/react-label";
import { Slot } from "@radix-ui/react-slot";
import {
Controller,
ControllerProps,
FieldPath,
FieldValues,
FormProvider,
useFormContext,
useFormState,
type ControllerProps,
type FieldPath,
type FieldValues,
} from "react-hook-form";
import { cn } from "@/lib/utils";
@@ -42,8 +43,8 @@ const FormField = <
const useFormField = () => {
const fieldContext = React.useContext(FormFieldContext);
const itemContext = React.useContext(FormItemContext);
const { getFieldState, formState } = useFormContext();
const { getFieldState } = useFormContext();
const formState = useFormState({ name: fieldContext.name });
const fieldState = getFieldState(fieldContext.name, formState);
if (!fieldContext) {
@@ -70,47 +71,44 @@ const FormItemContext = React.createContext<FormItemContextValue>(
{} as FormItemContextValue,
);
const FormItem = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => {
function FormItem({ className, ...props }: React.ComponentProps<"div">) {
const id = React.useId();
return (
<FormItemContext.Provider value={{ id }}>
<div ref={ref} className={cn("space-y-2", className)} {...props} />
<div
data-slot="form-item"
className={cn("grid gap-2", className)}
{...props}
/>
</FormItemContext.Provider>
);
});
FormItem.displayName = "FormItem";
}
const FormLabel = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
>(({ className, ...props }, ref) => {
function FormLabel({
className,
...props
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
const { error, formItemId } = useFormField();
return (
<Label
ref={ref}
className={cn(error && "text-destructive", className)}
data-slot="form-label"
data-error={!!error}
className={cn("data-[error=true]:text-destructive", className)}
htmlFor={formItemId}
{...props}
/>
);
});
FormLabel.displayName = "FormLabel";
}
const FormControl = React.forwardRef<
React.ElementRef<typeof Slot>,
React.ComponentPropsWithoutRef<typeof Slot>
>(({ ...props }, ref) => {
function FormControl({ ...props }: React.ComponentProps<typeof Slot>) {
const { error, formItemId, formDescriptionId, formMessageId } =
useFormField();
return (
<Slot
ref={ref}
data-slot="form-control"
id={formItemId}
aria-describedby={
!error
@@ -121,32 +119,24 @@ const FormControl = React.forwardRef<
{...props}
/>
);
});
FormControl.displayName = "FormControl";
}
const FormDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => {
function FormDescription({ className, ...props }: React.ComponentProps<"p">) {
const { formDescriptionId } = useFormField();
return (
<p
ref={ref}
data-slot="form-description"
id={formDescriptionId}
className={cn("text-[0.8rem] text-muted-foreground", className)}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
);
});
FormDescription.displayName = "FormDescription";
}
const FormMessage = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, children, ...props }, ref) => {
function FormMessage({ className, ...props }: React.ComponentProps<"p">) {
const { error, formMessageId } = useFormField();
const body = error ? String(error?.message) : children;
const body = error ? String(error?.message ?? "") : props.children;
if (!body) {
return null;
@@ -154,16 +144,15 @@ const FormMessage = React.forwardRef<
return (
<p
ref={ref}
data-slot="form-message"
id={formMessageId}
className={cn("text-[0.8rem] font-medium text-destructive", className)}
className={cn("text-sm text-destructive", className)}
{...props}
>
{body}
</p>
);
});
FormMessage.displayName = "FormMessage";
}
export {
// eslint-disable-next-line react-refresh/only-export-components
+6 -10
View File
@@ -2,24 +2,20 @@ import * as React from "react";
import { cn } from "@/lib/utils";
export interface InputProps
extends React.InputHTMLAttributes<HTMLInputElement> {}
const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, type, ...props }, ref) => {
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
return (
<input
type={type}
data-slot="input"
className={cn(
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
"flex h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30",
"focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
"aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40",
className,
)}
ref={ref}
{...props}
/>
);
},
);
Input.displayName = "Input";
}
export { Input };
+12 -14
View File
@@ -1,24 +1,22 @@
import * as React from "react";
import * as LabelPrimitive from "@radix-ui/react-label";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
);
const Label = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => (
function Label({
className,
...props
}: React.ComponentProps<typeof LabelPrimitive.Root>) {
return (
<LabelPrimitive.Root
ref={ref}
className={cn(labelVariants(), className)}
data-slot="label"
className={cn(
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
className,
)}
{...props}
/>
));
Label.displayName = LabelPrimitive.Root.displayName;
);
}
export { Label };
+3 -1
View File
@@ -8,12 +8,14 @@ export function NumberSelector({
updateCount,
addEnabled = true,
allowNegative = false,
initialValue = 0,
}: {
updateCount: UpdateSelectedNumberFunction;
addEnabled?: boolean;
allowNegative?: boolean;
initialValue?: number;
}) {
const [count, setCount] = useState<number>(0);
const [count, setCount] = useState<number>(initialValue);
const counterUpdated = (newAmount: number) => {
setCount(newAmount);
+32 -17
View File
@@ -1,31 +1,46 @@
import * as React from "react";
import * as PopoverPrimitive from "@radix-ui/react-popover";
import * as React from "react"
import * as PopoverPrimitive from "@radix-ui/react-popover"
import { cn } from "@/lib/utils";
import { cn } from "@/lib/utils"
const Popover = PopoverPrimitive.Root;
function Popover({
...props
}: React.ComponentProps<typeof PopoverPrimitive.Root>) {
return <PopoverPrimitive.Root data-slot="popover" {...props} />
}
const PopoverTrigger = PopoverPrimitive.Trigger;
function PopoverTrigger({
...props
}: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
}
const PopoverAnchor = PopoverPrimitive.Anchor;
const PopoverContent = React.forwardRef<
React.ElementRef<typeof PopoverPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
function PopoverContent({
className,
align = "center",
sideOffset = 4,
...props
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
return (
<PopoverPrimitive.Portal>
<PopoverPrimitive.Content
ref={ref}
data-slot="popover-content"
align={align}
sideOffset={sideOffset}
className={cn(
"z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
className,
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
className
)}
{...props}
/>
</PopoverPrimitive.Portal>
));
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
)
}
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor };
function PopoverAnchor({
...props
}: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
}
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
+11 -14
View File
@@ -3,27 +3,24 @@ import * as SeparatorPrimitive from "@radix-ui/react-separator";
import { cn } from "@/lib/utils";
const Separator = React.forwardRef<
React.ElementRef<typeof SeparatorPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
>(
(
{ className, orientation = "horizontal", decorative = true, ...props },
ref,
) => (
function Separator({
className,
orientation = "horizontal",
decorative = true,
...props
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
return (
<SeparatorPrimitive.Root
ref={ref}
data-slot="separator"
decorative={decorative}
orientation={orientation}
className={cn(
"shrink-0 bg-border",
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
"shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
className,
)}
{...props}
/>
),
);
Separator.displayName = SeparatorPrimitive.Root.displayName;
);
}
export { Separator };
+3 -5
View File
@@ -1,12 +1,10 @@
import { cn } from "@/lib/utils";
function Skeleton({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) {
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
return (
<div
className={cn("animate-pulse rounded-md bg-primary/10", className)}
data-slot="skeleton"
className={cn("animate-pulse rounded-md bg-accent", className)}
{...props}
/>
);
+53 -59
View File
@@ -2,111 +2,105 @@ import * as React from "react";
import { cn } from "@/lib/utils";
const Table = React.forwardRef<
HTMLTableElement,
React.HTMLAttributes<HTMLTableElement>
>(({ className, ...props }, ref) => (
<div className="relative w-full overflow-auto">
function Table({ className, ...props }: React.ComponentProps<"table">) {
return (
<div
data-slot="table-container"
className="relative w-full overflow-x-auto"
>
<table
ref={ref}
data-slot="table"
className={cn("w-full caption-bottom text-sm", className)}
{...props}
/>
</div>
));
Table.displayName = "Table";
);
}
const TableHeader = React.forwardRef<
HTMLTableSectionElement,
React.HTMLAttributes<HTMLTableSectionElement>
>(({ className, ...props }, ref) => (
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
));
TableHeader.displayName = "TableHeader";
function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {
return (
<thead
data-slot="table-header"
className={cn("[&_tr]:border-b", className)}
{...props}
/>
);
}
const TableBody = React.forwardRef<
HTMLTableSectionElement,
React.HTMLAttributes<HTMLTableSectionElement>
>(({ className, ...props }, ref) => (
function TableBody({ className, ...props }: React.ComponentProps<"tbody">) {
return (
<tbody
ref={ref}
data-slot="table-body"
className={cn("[&_tr:last-child]:border-0", className)}
{...props}
/>
));
TableBody.displayName = "TableBody";
);
}
const TableFooter = React.forwardRef<
HTMLTableSectionElement,
React.HTMLAttributes<HTMLTableSectionElement>
>(({ className, ...props }, ref) => (
function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) {
return (
<tfoot
ref={ref}
data-slot="table-footer"
className={cn(
"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
className,
)}
{...props}
/>
));
TableFooter.displayName = "TableFooter";
);
}
const TableRow = React.forwardRef<
HTMLTableRowElement,
React.HTMLAttributes<HTMLTableRowElement>
>(({ className, ...props }, ref) => (
function TableRow({ className, ...props }: React.ComponentProps<"tr">) {
return (
<tr
ref={ref}
data-slot="table-row"
className={cn(
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
className,
)}
{...props}
/>
));
TableRow.displayName = "TableRow";
);
}
const TableHead = React.forwardRef<
HTMLTableCellElement,
React.ThHTMLAttributes<HTMLTableCellElement>
>(({ className, ...props }, ref) => (
function TableHead({ className, ...props }: React.ComponentProps<"th">) {
return (
<th
ref={ref}
data-slot="table-head"
className={cn(
"h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
"h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
className,
)}
{...props}
/>
));
TableHead.displayName = "TableHead";
);
}
const TableCell = React.forwardRef<
HTMLTableCellElement,
React.TdHTMLAttributes<HTMLTableCellElement>
>(({ className, ...props }, ref) => (
function TableCell({ className, ...props }: React.ComponentProps<"td">) {
return (
<td
ref={ref}
data-slot="table-cell"
className={cn(
"p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
"p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
className,
)}
{...props}
/>
));
TableCell.displayName = "TableCell";
);
}
const TableCaption = React.forwardRef<
HTMLTableCaptionElement,
React.HTMLAttributes<HTMLTableCaptionElement>
>(({ className, ...props }, ref) => (
function TableCaption({
className,
...props
}: React.ComponentProps<"caption">) {
return (
<caption
ref={ref}
data-slot="table-caption"
className={cn("mt-4 text-sm text-muted-foreground", className)}
{...props}
/>
));
TableCaption.displayName = "TableCaption";
);
}
export {
Table,
+7 -9
View File
@@ -1,9 +1,9 @@
import * as React from "react";
import { Cross2Icon } from "@radix-ui/react-icons";
import * as ToastPrimitives from "@radix-ui/react-toast";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
import { XIcon } from "lucide-react";
const ToastProvider = ToastPrimitives.Provider;
@@ -14,7 +14,7 @@ const ToastViewport = React.forwardRef<
<ToastPrimitives.Viewport
ref={ref}
className={cn(
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
"fixed top-0 z-100 flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
className,
)}
{...props}
@@ -23,7 +23,7 @@ const ToastViewport = React.forwardRef<
ToastViewport.displayName = ToastPrimitives.Viewport.displayName;
const toastVariants = cva(
"group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
"group pointer-events-auto relative flex w-full items-center justify-between space-x-2 overflow-hidden rounded-md border p-4 pr-6 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-(--radix-toast-swipe-end-x) data-[swipe=move]:translate-x-(--radix-toast-swipe-move-x) data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full sm:data-[state=open]:slide-in-from-bottom-full",
{
variants: {
variant: {
@@ -32,9 +32,7 @@ const toastVariants = cva(
"destructive group border-destructive bg-destructive text-destructive-foreground",
},
},
defaultVariants: {
variant: "default",
},
defaultVariants: { variant: "default" },
},
);
@@ -60,7 +58,7 @@ const ToastAction = React.forwardRef<
<ToastPrimitives.Action
ref={ref}
className={cn(
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-none focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium transition-colors hover:bg-secondary focus:outline-hidden focus:ring-1 focus:ring-ring disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 hover:group-[.destructive]:border-destructive/30 hover:group-[.destructive]:bg-destructive hover:group-[.destructive]:text-destructive-foreground focus:group-[.destructive]:ring-destructive",
className,
)}
{...props}
@@ -75,13 +73,13 @@ const ToastClose = React.forwardRef<
<ToastPrimitives.Close
ref={ref}
className={cn(
"absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
"absolute right-1 top-1 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-hidden focus:ring-1 group-hover:opacity-100 group-[.destructive]:text-red-300 hover:group-[.destructive]:text-red-50 focus:group-[.destructive]:ring-red-400 focus:group-[.destructive]:ring-offset-red-600",
className,
)}
toast-close=""
{...props}
>
<Cross2Icon className="h-4 w-4" />
<XIcon className="h-4 w-4" />
</ToastPrimitives.Close>
));
ToastClose.displayName = ToastPrimitives.Close.displayName;
+43 -12
View File
@@ -3,26 +3,57 @@ import * as TooltipPrimitive from "@radix-ui/react-tooltip";
import { cn } from "@/lib/utils";
const TooltipProvider = TooltipPrimitive.Provider;
function TooltipProvider({
delayDuration = 0,
...props
}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {
return (
<TooltipPrimitive.Provider
data-slot="tooltip-provider"
delayDuration={delayDuration}
{...props}
/>
);
}
const Tooltip = TooltipPrimitive.Root;
function Tooltip({
...props
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
return (
<TooltipProvider>
<TooltipPrimitive.Root data-slot="tooltip" {...props} />
</TooltipProvider>
);
}
const TooltipTrigger = TooltipPrimitive.Trigger;
function TooltipTrigger({
...props
}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {
return <TooltipPrimitive.Trigger data-slot="tooltip-trigger" {...props} />;
}
const TooltipContent = React.forwardRef<
React.ElementRef<typeof TooltipPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content>
>(({ className, sideOffset = 4, ...props }, ref) => (
function TooltipContent({
className,
sideOffset = 0,
children,
...props
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
return (
<TooltipPrimitive.Portal>
<TooltipPrimitive.Content
ref={ref}
data-slot="tooltip-content"
sideOffset={sideOffset}
className={cn(
"z-50 overflow-hidden rounded-md bg-primary px-3 py-1.5 text-xs text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
"animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md bg-primary px-3 py-1.5 text-xs text-balance text-primary-foreground",
className,
)}
{...props}
/>
));
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
>
{children}
<TooltipPrimitive.Arrow className="z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-primary fill-primary" />
</TooltipPrimitive.Content>
</TooltipPrimitive.Portal>
);
}
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
+5 -5
View File
@@ -8,7 +8,7 @@ import { Slot } from "@radix-ui/react-slot";
const typographyVariants = cva("text-foreground", {
variants: {
variant: {
h1: "scroll-m-20 text-4xl font-extrabold tracking-tight lg:text-5xl",
h1: "scroll-m-20 text-center text-4xl font-extrabold tracking-tight text-balance",
h2: "scroll-m-20 border-b pb-2 text-3xl font-semibold tracking-tight first:mt-0",
h3: "scroll-m-20 text-2xl font-semibold tracking-tight",
h4: "scroll-m-20 text-xl font-semibold tracking-tight",
@@ -19,11 +19,11 @@ const typographyVariants = cva("text-foreground", {
blockquote: "mt-6 border-l-2 pl-6 italic",
ul: "my-6 ml-6 list-disc [&>li]:mt-2",
inlineCode:
"relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",
lead: "text-xl text-muted-foreground",
"bg-muted relative rounded px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",
lead: "text-muted-foreground text-xl",
largeText: "text-lg font-semibold",
smallText: "text-sm font-medium leading-none",
mutedText: "text-sm text-muted-foreground",
smallText: "text-sm leading-none font-medium",
mutedText: "text-muted-foreground text-sm",
},
},
defaultVariants: {
+9 -40
View File
@@ -1,4 +1,3 @@
// Inspired by react-hot-toast library
import * as React from "react";
import type { ToastActionElement, ToastProps } from "src/components/ui/toast";
@@ -30,22 +29,10 @@ function genId() {
type ActionType = typeof actionTypes;
type Action =
| {
type: ActionType["ADD_TOAST"];
toast: ToasterToast;
}
| {
type: ActionType["UPDATE_TOAST"];
toast: Partial<ToasterToast>;
}
| {
type: ActionType["DISMISS_TOAST"];
toastId?: ToasterToast["id"];
}
| {
type: ActionType["REMOVE_TOAST"];
toastId?: ToasterToast["id"];
};
| { type: ActionType["ADD_TOAST"]; toast: ToasterToast }
| { type: ActionType["UPDATE_TOAST"]; toast: Partial<ToasterToast> }
| { type: ActionType["DISMISS_TOAST"]; toastId?: ToasterToast["id"] }
| { type: ActionType["REMOVE_TOAST"]; toastId?: ToasterToast["id"] };
interface State {
toasts: ToasterToast[];
@@ -60,10 +47,7 @@ const addToRemoveQueue = (toastId: string) => {
const timeout = setTimeout(() => {
toastTimeouts.delete(toastId);
dispatch({
type: "REMOVE_TOAST",
toastId: toastId,
});
dispatch({ type: "REMOVE_TOAST", toastId: toastId });
}, TOAST_REMOVE_DELAY);
toastTimeouts.set(toastId, timeout);
@@ -101,21 +85,13 @@ export const reducer = (state: State, action: Action): State => {
return {
...state,
toasts: state.toasts.map((t) =>
t.id === toastId || toastId === undefined
? {
...t,
open: false,
}
: t,
t.id === toastId || toastId === undefined ? { ...t, open: false } : t,
),
};
}
case "REMOVE_TOAST":
if (action.toastId === undefined) {
return {
...state,
toasts: [],
};
return { ...state, toasts: [] };
}
return {
...state,
@@ -141,10 +117,7 @@ function toast({ ...props }: Toast) {
const id = genId();
const update = (props: ToasterToast) =>
dispatch({
type: "UPDATE_TOAST",
toast: { ...props, id },
});
dispatch({ type: "UPDATE_TOAST", toast: { ...props, id } });
const dismiss = () => dispatch({ type: "DISMISS_TOAST", toastId: id });
dispatch({
@@ -159,11 +132,7 @@ function toast({ ...props }: Toast) {
},
});
return {
id: id,
dismiss,
update,
};
return { id: id, dismiss, update };
}
function useToast() {
+217 -49
View File
@@ -1,60 +1,228 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@import 'tailwindcss';
@import "tw-animate-css";
@layer base {
:root {
--background: 0 0% 100%;
--foreground: 240 10% 3.9%;
--card: 0 0% 100%;
--card-foreground: 240 10% 3.9%;
--popover: 0 0% 100%;
--popover-foreground: 240 10% 3.9%;
--primary: 142.1 76.2% 36.3%;
--primary-foreground: 355.7 100% 97.3%;
--secondary: 240 4.8% 95.9%;
--secondary-foreground: 240 5.9% 10%;
--muted: 240 4.8% 95.9%;
--muted-foreground: 240 3.8% 46.1%;
--accent: 240 4.8% 95.9%;
--accent-foreground: 240 5.9% 10%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 0 0% 98%;
--border: 240 5.9% 90%;
--input: 240 5.9% 90%;
--ring: 142.1 76.2% 36.3%;
--radius: 0.75rem;
}
@custom-variant dark (&:is(.dark *));
.dark {
--background: 20 14.3% 4.1%;
--foreground: 0 0% 95%;
--card: 24 9.8% 10%;
--card-foreground: 0 0% 95%;
--popover: 0 0% 9%;
--popover-foreground: 0 0% 95%;
--primary: 142.1 70.6% 45.3%;
--primary-foreground: 144.9 80.4% 10%;
--secondary: 240 3.7% 15.9%;
--secondary-foreground: 0 0% 98%;
--muted: 0 0% 15%;
--muted-foreground: 240 5% 64.9%;
--accent: 12 6.5% 15.1%;
--accent-foreground: 0 0% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 85.7% 97.3%;
--border: 240 3.7% 15.9%;
--input: 240 3.7% 15.9%;
--ring: 142.4 71.8% 29.2%;
}
@theme inline {
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) + 4px);
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-card: var(--card);
--color-card-foreground: var(--card-foreground);
--color-popover: var(--popover);
--color-popover-foreground: var(--popover-foreground);
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
--color-secondary: var(--secondary);
--color-secondary-foreground: var(--secondary-foreground);
--color-muted: var(--muted);
--color-muted-foreground: var(--muted-foreground);
--color-accent: var(--accent);
--color-accent-foreground: var(--accent-foreground);
--color-destructive: var(--destructive);
--color-border: var(--border);
--color-input: var(--input);
--color-ring: var(--ring);
--color-chart-1: var(--chart-1);
--color-chart-2: var(--chart-2);
--color-chart-3: var(--chart-3);
--color-chart-4: var(--chart-4);
--color-chart-5: var(--chart-5);
--color-sidebar: var(--sidebar);
--color-sidebar-foreground: var(--sidebar-foreground);
--color-sidebar-primary: var(--sidebar-primary);
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
--color-sidebar-accent: var(--sidebar-accent);
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
--color-sidebar-border: var(--sidebar-border);
--color-sidebar-ring: var(--sidebar-ring);
}
:root {
--radius: 0.625rem;
--background: oklch(1 0 0);
--foreground: oklch(0.147 0.004 49.25);
--card: oklch(1 0 0);
--card-foreground: oklch(0.147 0.004 49.25);
--popover: oklch(1 0 0);
--popover-foreground: oklch(0.147 0.004 49.25);
--primary: oklch(0.216 0.006 56.043);
--primary-foreground: oklch(0.985 0.001 106.423);
--secondary: oklch(0.97 0.001 106.424);
--secondary-foreground: oklch(0.216 0.006 56.043);
--muted: oklch(0.97 0.001 106.424);
--muted-foreground: oklch(0.553 0.013 58.071);
--accent: oklch(0.97 0.001 106.424);
--accent-foreground: oklch(0.216 0.006 56.043);
--destructive: oklch(0.577 0.245 27.325);
--border: oklch(0.923 0.003 48.717);
--input: oklch(0.923 0.003 48.717);
--ring: oklch(0.709 0.01 56.259);
--chart-1: oklch(0.646 0.222 41.116);
--chart-2: oklch(0.6 0.118 184.704);
--chart-3: oklch(0.398 0.07 227.392);
--chart-4: oklch(0.828 0.189 84.429);
--chart-5: oklch(0.769 0.188 70.08);
--sidebar: oklch(0.985 0.001 106.423);
--sidebar-foreground: oklch(0.147 0.004 49.25);
--sidebar-primary: oklch(0.216 0.006 56.043);
--sidebar-primary-foreground: oklch(0.985 0.001 106.423);
--sidebar-accent: oklch(0.97 0.001 106.424);
--sidebar-accent-foreground: oklch(0.216 0.006 56.043);
--sidebar-border: oklch(0.923 0.003 48.717);
--sidebar-ring: oklch(0.709 0.01 56.259);
}
.dark {
--background: oklch(0.147 0.004 49.25);
--foreground: oklch(0.985 0.001 106.423);
--card: oklch(0.216 0.006 56.043);
--card-foreground: oklch(0.985 0.001 106.423);
--popover: oklch(0.216 0.006 56.043);
--popover-foreground: oklch(0.985 0.001 106.423);
--primary: oklch(0.923 0.003 48.717);
--primary-foreground: oklch(0.216 0.006 56.043);
--secondary: oklch(0.268 0.007 34.298);
--secondary-foreground: oklch(0.985 0.001 106.423);
--muted: oklch(0.268 0.007 34.298);
--muted-foreground: oklch(0.709 0.01 56.259);
--accent: oklch(0.268 0.007 34.298);
--accent-foreground: oklch(0.985 0.001 106.423);
--destructive: oklch(0.704 0.191 22.216);
--border: oklch(1 0 0 / 10%);
--input: oklch(1 0 0 / 15%);
--ring: oklch(0.553 0.013 58.071);
--chart-1: oklch(0.488 0.243 264.376);
--chart-2: oklch(0.696 0.17 162.48);
--chart-3: oklch(0.769 0.188 70.08);
--chart-4: oklch(0.627 0.265 303.9);
--chart-5: oklch(0.645 0.246 16.439);
--sidebar: oklch(0.216 0.006 56.043);
--sidebar-foreground: oklch(0.985 0.001 106.423);
--sidebar-primary: oklch(0.488 0.243 264.376);
--sidebar-primary-foreground: oklch(0.985 0.001 106.423);
--sidebar-accent: oklch(0.268 0.007 34.298);
--sidebar-accent-foreground: oklch(0.985 0.001 106.423);
--sidebar-border: oklch(1 0 0 / 10%);
--sidebar-ring: oklch(0.553 0.013 58.071);
}
@layer base {
* {
@apply border-border;
@apply border-border outline-ring/50;
}
body {
@apply bg-background text-foreground;
}
}
/* SomniaRooms Extended CSS */
@utility grid-cols-40/60 {
grid-template-columns: 40% 60%;
}
@utility grid-cols-60/40 {
grid-template-columns: 60% 40%;
}
+3 -3
View File
@@ -1,6 +1,6 @@
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
return twMerge(clsx(inputs))
}
+1 -1
View File
@@ -3,7 +3,7 @@ import ReactDOM from "react-dom/client";
import "./index.css";
import { RouterProvider, createBrowserRouter } from "react-router-dom";
import Root from "./routes/Root";
import ErrorPage from "./error-page";
import ErrorPage from "./routes/error-page";
import Homepage from "./routes/home-page";
import SearchPage from "./routes/search-page";
import BookPage from "./routes/book-page";
+2 -2
View File
@@ -1,10 +1,10 @@
"use client";
import { z } from "zod";
import { z } from "zod/v4";
export const BookingFormSchema = z.object({
name: z.string().min(2).max(50),
surname: z.string().min(2).max(50),
email: z.string().email(),
email: z.email(),
phone: z.string().min(8),
});
+10 -11
View File
@@ -1,22 +1,21 @@
export type RoomCategory = {
id: number;
name: string;
description: string;
bedType: string;
description: string | undefined;
maxGuestNum: number;
orderHomePage: number | undefined;
roomCategoryPhotos: RoomCategoryPhoto[];
roomCategoryDetails: RoomCategoryDetails[];
};
export type RoomCategoryDetails = {
id: number;
detailsSection: string;
detailValue: string;
roomCategoryBedTypes: RoomCategoryBedType[];
};
export type RoomCategoryPhoto = {
id: number;
path: string;
altText: string | undefined;
kind: string;
photoOrder: string | undefined;
};
export type RoomCategoryBedType = {
amount: number;
bedTypeName: string;
bedTypeIcon: string;
}
+5 -2
View File
@@ -9,7 +9,8 @@ export type RoomPrice = {
};
export type AvailabilityRequest = {
filter: AvailabilityFilter;
startDate: string;
endDate: string;
};
export type AvailabilityFilter = {
@@ -18,7 +19,9 @@ export type AvailabilityFilter = {
};
export type FareRequest = {
filter: FareFilter;
roomCategory: number;
startDate: string;
endDate: string;
};
export type FareFilter = {
+6
View File
@@ -14,3 +14,9 @@ html {
padding: 2rem;
text-align: center;
}
iconify-icon {
display: inline-block;
min-width: 1em;
min-height: 1em;
}
+3 -3
View File
@@ -17,7 +17,7 @@ import { useAppStore } from "@/store";
import { useState } from "react";
import { useForm } from "react-hook-form";
import { useNavigate } from "react-router-dom";
import { z } from "zod";
import { z } from "zod/v4";
import { zodResolver } from "@hookform/resolvers/zod";
enum PageState {
@@ -30,8 +30,8 @@ enum PageState {
function BookPage() {
const [pageState, setPageState] = useState<PageState>(PageState.showForm);
const bookingData = useAppStore((state) => state.newBookingData);
const setCustomerData = useAppStore((state) => state.setBookingCustomer);
const bookingData = useAppStore((state) => state.currentBooking);
const setCustomerData = useAppStore((state) => state.currentBookingSetCustomer);
const navigate = useNavigate();
const bookingForm = useForm<z.infer<typeof BookingFormSchema>>({
+27 -5
View File
@@ -1,4 +1,4 @@
import { useAPIRoomCategories } from "@/api/api-roomCategories";
import { useAPIRoomCategoryList } from "@/api/api-roomCategories";
import { RoomItemCard } from "@/components/Rooms/room-item-card";
import { SearchFilterCard } from "@/components/Search/SearchFilterCard";
import BackendConnectionStatus from "@/components/backend-conection-status";
@@ -6,28 +6,50 @@ import { Separator } from "@/components/ui/separator";
import { Skeleton } from "@/components/ui/skeleton";
import { Typography } from "@/components/ui/typography";
import { RoomCategory } from "@/model/RoomCategory";
import { SearchFilter } from "@/model/SearchFilter";
import { SearchFilter } from "@/model/InternalTypes";
import { eBookingState } from "@/utils/AppStateManager";
import { useNavigate } from "react-router-dom";
import { LoaderIcon } from "lucide-react";
import "./home-page.css";
import { useAppStore } from "@/store";
import { isValidSearchFilter, makeDayUTCDate } from "@/utils/utils";
function Homepage() {
const { roomCategoryList, isLoading, isError } = useAPIRoomCategories();
const appSearchFilter = useAppStore((state) => state.searchFilter);
const setAppSearchFilter = useAppStore((state) => state.setSearchFilter);
const setAppBookingState = useAppStore((state) => state.setBookingState);
const initAppBooking = useAppStore((state) => state.initCurrentBooking);
const { roomCategoryList, isLoading, isError } = useAPIRoomCategoryList();
const navigate = useNavigate();
const onBtSearchClick = (filter: SearchFilter) => {
if (!isValidSearchFilter(filter)) {
return;
}
setAppSearchFilter(filter);
setAppBookingState(eBookingState.Searched);
initAppBooking(
makeDayUTCDate(filter.dateRange.from),
makeDayUTCDate(filter.dateRange.to),
);
navigate("/search", { state: filter });
};
const roomList = roomCategoryList?.map((element: RoomCategory) => {
return <RoomItemCard key={element.id} room={element} />;
});
return (
<>
<Typography variant={"h1"}>Somnia Rooms</Typography>
<Separator className="my-10" />
<SearchFilterCard onSearchClick={onBtSearchClick} />
<SearchFilterCard
onSearchClick={onBtSearchClick}
initialsearchFilter={appSearchFilter}
/>
<Separator className="my-10" />
<div className="homePageRoomGrid grid gap-4">{roomList}</div>
{isLoading && (
+63 -58
View File
@@ -6,75 +6,68 @@ import { BookingDetails } from "@/components/booking/booking-details";
import { Separator } from "@/components/ui/separator";
import { Skeleton } from "@/components/ui/skeleton";
import { Typography } from "@/components/ui/typography";
import { AvailabilityFilter } from "@/model/RoomSearch";
import { SearchFilter } from "@/model/SearchFilter";
import { SearchFilter } from "@/model/InternalTypes";
import { eBookingState } from "@/utils/AppStateManager";
import { useAppStore } from "@/store";
import { useMemo, useState } from "react";
import {
isValidSearchFilter,
makeAvailabilityFilterFromSearchFilter,
makeDayUTCDate,
} from "@/utils/utils";
import { useNavigate } from "react-router-dom";
//TODOME: Igual podemos crear un StateMachine conjunta para los siguiente estados de la página: Sin Buscar, Sin disponibilidad, error, cargando.
//TODOME: Al pulsar el botón "buscar", si ya existen datos en la reserva (se han añadido habitaciones) mostrar un cuadro de aviso de que si se busca se borrará la selección actual.
//TODOME: Mediante los estados globales de la reserva, si ya está en estado "booking" añadiendo los datos, mostrar un mensaje y permitir redirigir directamente para que continue donde lo dejó.
function SearchPage() {
//const [availabilityFilter, setAvailabilityFilter] = useState<AvailabilityFilter>();
const searchFilter = useAppStore((state) => state.searchFilter);
const resetBooking = useAppStore((state) => state.resetBookingState);
const appBookingState = useAppStore((state) => state.bookingState);
const setAppBookingState = useAppStore((state) => state.setBookingState);
const appSearchFilter = useAppStore((state) => state.searchFilter);
const setAppSearchFilter = useAppStore((state) => state.setSearchFilter);
const initAppBooking = useAppStore((state) => state.initCurrentBooking);
const navigate = useNavigate();
const [isSearched, setIsSearched] = useState<boolean>(false);
//This seems a little bit overkill, but IDK.
const availabilityFilter: AvailabilityFilter | null = useMemo(() => {
if (
searchFilter &&
searchFilter.dateRange &&
searchFilter.dateRange.from &&
searchFilter.dateRange.to
) {
const newAvailabilityFilter: AvailabilityFilter = {
startDate: searchFilter.dateRange.from.toDateString(),
endDate: searchFilter.dateRange.to.toDateString(),
};
return newAvailabilityFilter;
}
return null;
}, [searchFilter]);
const {
roomAvailabilityList,
isLoading: isLoadingAvailability,
isError: isErrorAvailability,
} = useAPIRoomAvailability(availabilityFilter ?? null);
} = useAPIRoomAvailability(
makeAvailabilityFilterFromSearchFilter(appSearchFilter) ?? null,
);
const isLoading = isLoadingAvailability;
const isError = isErrorAvailability;
const hasRooms =
roomAvailabilityList?.length && roomAvailabilityList?.length > 0;
//TODOME: Hay que ver para mover esto a un método común.
const onBtSearchClick = (newFilter: SearchFilter) => {
console.log("onBtSearchClick: ");
console.log(newFilter);
if (
newFilter.dateRange &&
newFilter.dateRange.from &&
newFilter.dateRange.to
) {
setIsSearched(true);
resetBooking(newFilter.dateRange.from, newFilter.dateRange.to);
if (!isValidSearchFilter(newFilter)) {
return;
}
setAppSearchFilter(newFilter);
setAppBookingState(eBookingState.Searched);
initAppBooking(
makeDayUTCDate(newFilter.dateRange.from),
makeDayUTCDate(newFilter.dateRange.to),
);
};
const onBookingContinue = () => {
navigate("/book");
};
const roomList = roomAvailabilityList?.map((element) => {
const roomList =
roomAvailabilityList?.map((element) => {
return (
<RoomBooking
key={element.roomCategory}
key={element.roomCategory + "-" + appBookingState.lastSearchDate}
availableAmount={element.availability}
roomCategoryId={element.roomCategory}
/>
);
});
}) ?? null;
const noRoomsAvailable = (
<>
<Typography variant={"h3"} as="h3">
@@ -83,22 +76,23 @@ function SearchPage() {
</Typography>
</>
);
const hasRooms =
roomAvailabilityList?.length && roomAvailabilityList?.length > 0;
console.log(hasRooms);
const pageContent = isLoading ? (
const pageContentSearch = (
<Typography>
Realiza una búsqueda para ver la disponibilidad y los precios.
</Typography>
);
const pageContentLoading = (
<>
<Typography variant={"h3"} as="h2">
Loading...
</Typography>
<Skeleton className="mx-auto h-[200px] w-full" />
</>
) : (
);
const pageContentLoaded = (
<div className="2xl:grid 2xl:grid-cols-60/40 2xl:gap-6">
<div className="flex flex-col gap-5">
{hasRooms ? roomList : isSearched && noRoomsAvailable}
</div>
<div className="flex flex-col gap-5">{roomList}</div>
<Separator className="my-10 2xl:hidden" />
<BookingDetails
onBookingConfirm={onBookingContinue}
@@ -107,17 +101,28 @@ function SearchPage() {
</div>
);
const getPageContent = () => {
const isSearched = appBookingState.state == eBookingState.Searched;
if (!isSearched) {
return pageContentSearch;
}
if (isLoading) {
return pageContentLoading;
}
if (!hasRooms) {
return noRoomsAvailable;
}
return pageContentLoaded;
};
return (
<div className="bg-background text-foreground">
<SearchFilterCard onSearchClick={onBtSearchClick} />
<SearchFilterCard
onSearchClick={onBtSearchClick}
initialsearchFilter={appSearchFilter}
/>
<Separator className="my-10" />
{hasRooms ? (
pageContent
) : (
<Typography>
Realiza una búsqueda para ver la disponibilidad y los precios.
</Typography>
)}
{getPageContent()}
<Separator className="my-10" />
<BackendConnectionStatus isLoading={isLoading} isError={isError} />
</div>
+2 -3
View File
@@ -3,13 +3,12 @@ import { Card, CardContent, CardHeader } from "@/components/ui/card";
import { Typography } from "@/components/ui/typography";
import { NewBookingResponse } from "@/model/Bookings";
import { useAppStore } from "@/store";
import { addDays } from "date-fns";
import { useEffect, useState } from "react";
import { useLocation, useNavigate } from "react-router-dom";
function SuccessPage() {
const [pageState, setPageState] = useState<NewBookingResponse | null>(null);
const resetBookingState = useAppStore((state) => state.resetBookingState);
const resetBookingState = useAppStore((state) => state.resetCurrentBooking);
const location = useLocation();
const navigate = useNavigate();
@@ -22,7 +21,7 @@ function SuccessPage() {
}, [location, navigate]);
const handleBtBackClick = () => {
resetBookingState(new Date(), addDays(new Date(), 2));
resetBookingState();
navigate("/home");
};
+59 -34
View File
@@ -1,19 +1,31 @@
import { create } from "zustand";
import { SearchFilter } from "./model/SearchFilter";
import { SearchFilter } from "@/model/InternalTypes";
import {
BookingState,
eBookingState,
SetBookingState,
} from "./utils/AppStateManager";
import {
NewBooking,
NewBookingCustomerDetails,
NewBookingRoom,
} from "./model/Bookings";
interface AppState {
interface State {
searchFilter: SearchFilter;
currentBooking: NewBooking | null;
bookingState: BookingState;
}
interface Actions {
setSearchFilter: (newFilter: SearchFilter) => void;
newBookingData: NewBooking | null;
setNewBooking: (newBooking: NewBooking) => void;
resetBookingState: (arrival: Date, departure: Date) => void;
addNewBookingRoom: (newRoom: NewBookingRoom) => void;
setBookingCustomer: (newCustomer: NewBookingCustomerDetails) => void;
resetSearchFilter: () => void;
setCurrentBooking: (newBooking: NewBooking) => void;
resetCurrentBooking: () => void;
initCurrentBooking: (arrival: Date, departure: Date) => void;
currentBookingAddRoom: (newRoom: NewBookingRoom) => void;
currentBookingSetCustomer: (newCustomer: NewBookingCustomerDetails) => void;
setBookingState: (newState: eBookingState) => void;
}
const defaultSearchFilter: SearchFilter = {
@@ -32,7 +44,12 @@ const defaultNewBooking: NewBooking = {
rooms: [],
};
function getDefaultBookingData(arrivalDate: Date, departureDate: Date) {
const defaultBookingState: BookingState = {
state: eBookingState.None,
lastSearchDate: new Date(),
};
function getDefaultBooking(arrivalDate: Date, departureDate: Date) {
return {
...defaultNewBooking,
arrivalDate: arrivalDate,
@@ -40,19 +57,19 @@ function getDefaultBookingData(arrivalDate: Date, departureDate: Date) {
};
}
function addNewBookingRoomToCurrentState(
function addNewBookingRoom(
newRoom: NewBookingRoom,
currentState: NewBooking | null,
currentBookingState: NewBooking | null,
): NewBooking | null {
if (currentState == null) {
return currentState;
if (currentBookingState == null) {
return currentBookingState;
}
//Remove rooms with "same key".
const filteredRooms = currentState.rooms.filter((room) => {
const diffRoom = room.roomCategory != newRoom.roomCategory;
const diffAmount = room.guestNumber != newRoom.guestNumber;
if (diffRoom || (!diffRoom && diffAmount)) {
const filteredRooms = currentBookingState.rooms.filter((room) => {
const isDiffRoom = room.roomCategory != newRoom.roomCategory;
const isDiffAmount = room.guestNumber != newRoom.guestNumber;
if (isDiffRoom || (!isDiffRoom && isDiffAmount)) {
return true;
}
return false;
@@ -64,11 +81,11 @@ function addNewBookingRoomToCurrentState(
}
const newState: NewBooking = {
...currentState,
...currentBookingState,
rooms: filteredRooms ?? [],
};
console.log("AddRoomNewState:");
console.log("Updated 'currentBooking' state:");
console.log(newState);
return newState;
@@ -76,35 +93,43 @@ function addNewBookingRoomToCurrentState(
function setBookingCustomer(
newCustomer: NewBookingCustomerDetails,
currentState: NewBooking | null,
currentBookingState: NewBooking | null,
) {
if (currentState == null) {
return currentState;
if (currentBookingState == null) {
return currentBookingState;
}
const newState: NewBooking = {
...currentState,
...currentBookingState,
customerDetails: newCustomer,
};
return newState;
}
export const useAppStore = create<AppState>()((set) => ({
export const useAppStore = create<State & Actions>()((set) => ({
searchFilter: defaultSearchFilter,
currentBooking: null,
bookingState: defaultBookingState,
setSearchFilter: (newFilter) => set(() => ({ searchFilter: newFilter })),
newBookingData: null,
setNewBooking: (newBooking) => set(() => ({ newBookingData: newBooking })),
resetBookingState: (arrival, departure) =>
set(() => ({ newBookingData: getDefaultBookingData(arrival, departure) })),
addNewBookingRoom: (newRoom: NewBookingRoom) =>
resetSearchFilter: () => set(() => ({ searchFilter: defaultSearchFilter })),
setCurrentBooking: (newBooking) =>
set(() => ({ currentBooking: newBooking })),
resetCurrentBooking: () => set(() => ({ currentBooking: null })),
initCurrentBooking: (arrival, departure) =>
set(() => ({ currentBooking: getDefaultBooking(arrival, departure) })),
currentBookingAddRoom: (newRoom) =>
set((state) => ({
newBookingData: addNewBookingRoomToCurrentState(
newRoom,
state.newBookingData,
),
currentBooking: addNewBookingRoom(newRoom, state.currentBooking),
})),
setBookingCustomer: (newCustomer: NewBookingCustomerDetails) =>
currentBookingSetCustomer: (newCustomer) =>
set((state) => ({
newBookingData: setBookingCustomer(newCustomer, state.newBookingData),
currentBooking: setBookingCustomer(newCustomer, state.currentBooking),
})),
setBookingState: (newState) =>
set((state) => ({
bookingState: SetBookingState(newState, state.bookingState),
})),
}));
+27
View File
@@ -0,0 +1,27 @@
export type BookingState = {
state: eBookingState;
lastSearchDate: Date;
};
export enum eBookingState {
None = "NONE",
Searched = "SEARCHED",
Booking = "BOOKING",
Booked = "BOOKED",
}
export function SetBookingState(
newState: eBookingState,
currentAppBookingState: BookingState,
) {
const newAppState: BookingState = {
...currentAppBookingState,
state: newState,
};
if (newState == eBookingState.Searched) {
newAppState.lastSearchDate = new Date();
}
return newAppState;
}
+52
View File
@@ -0,0 +1,52 @@
import { AvailabilityFilter, FareFilter } from "@/model/RoomSearch";
import { SearchFilter } from "@/model/InternalTypes";
export function makeDayUTCDate(date: Date | undefined): Date {
if (!date) {
return new Date();
}
return new Date(
date.getFullYear(),
date.getMonth(),
date.getDate(),
23,
59,
59,
999,
);
}
export function isValidSearchFilter(sf: SearchFilter): boolean {
if (sf?.dateRange?.from && sf?.dateRange?.to) {
return true;
}
return false;
}
export function makeAvailabilityFilterFromSearchFilter(
sf: SearchFilter,
): AvailabilityFilter | null {
if (!isValidSearchFilter(sf)) {
return null;
}
return {
startDate: sf.dateRange.from!.toISOString(),
endDate: sf.dateRange.to!.toISOString(),
};
}
export function makeFareFilterFromSearchFilter(
sf: SearchFilter,
roomCategoryId: number,
): FareFilter | null {
if (!isValidSearchFilter(sf) || roomCategoryId < 0) {
return null;
}
return {
startDate: sf.dateRange.from!.toISOString(),
endDate: sf.dateRange.to!.toISOString(),
roomCategory: roomCategoryId,
};
}
-85
View File
@@ -1,85 +0,0 @@
import plugin from "tailwindcss-animate";
/** @type {import('tailwindcss').Config} */
export default {
darkMode: ["class"],
content: [
"./pages/**/*.{ts,tsx}",
"./components/**/*.{ts,tsx}",
"./app/**/*.{ts,tsx}",
"./src/**/*.{ts,tsx}",
],
prefix: "",
theme: {
container: {
center: true,
padding: "2rem",
screens: {
"2xl": "1400px",
},
},
extend: {
colors: {
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
foreground: "hsl(var(--secondary-foreground))",
},
destructive: {
DEFAULT: "hsl(var(--destructive))",
foreground: "hsl(var(--destructive-foreground))",
},
muted: {
DEFAULT: "hsl(var(--muted))",
foreground: "hsl(var(--muted-foreground))",
},
accent: {
DEFAULT: "hsl(var(--accent))",
foreground: "hsl(var(--accent-foreground))",
},
popover: {
DEFAULT: "hsl(var(--popover))",
foreground: "hsl(var(--popover-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
},
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
keyframes: {
"accordion-down": {
from: { height: "0" },
to: { height: "var(--radix-accordion-content-height)" },
},
"accordion-up": {
from: { height: "var(--radix-accordion-content-height)" },
to: { height: "0" },
},
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
},
//SomniaRooms Extends
gridTemplateColumns: {
"60/40": "60% 40%",
"40/60": "40% 60%",
},
},
},
plugins: [plugin],
};
+12
View File
@@ -0,0 +1,12 @@
{
"compilerOptions": {
// ...
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
}
// ...
}
}
+2 -1
View File
@@ -1,10 +1,11 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
import tailwindcss from "@tailwindcss/vite"
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
plugins: [react(), tailwindcss()],
server: {
host: true,
port: 3000,