Restore Ultracite + fix sidebar (#1233)

This commit is contained in:
Hayden Bleasel 2025-09-21 11:02:31 -07:00 committed by GitHub
parent 8fbfc253fa
commit 947ed094a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
177 changed files with 6908 additions and 8306 deletions

View file

@ -1,23 +1,21 @@
'use client';
"use client";
import { isAfter } from 'date-fns';
import { motion } from 'framer-motion';
import { useState } from 'react';
import { useSWRConfig } from 'swr';
import { useWindowSize } from 'usehooks-ts';
import { isAfter } from "date-fns";
import { motion } from "framer-motion";
import { useState } from "react";
import { useSWRConfig } from "swr";
import { useWindowSize } from "usehooks-ts";
import { useArtifact } from "@/hooks/use-artifact";
import type { Document } from "@/lib/db/schema";
import { getDocumentTimestampByIndex } from "@/lib/utils";
import { LoaderIcon } from "./icons";
import { Button } from "./ui/button";
import type { Document } from '@/lib/db/schema';
import { getDocumentTimestampByIndex } from '@/lib/utils';
import { LoaderIcon } from './icons';
import { Button } from './ui/button';
import { useArtifact } from '@/hooks/use-artifact';
interface VersionFooterProps {
handleVersionChange: (type: 'next' | 'prev' | 'toggle' | 'latest') => void;
documents: Array<Document> | undefined;
type VersionFooterProps = {
handleVersionChange: (type: "next" | "prev" | "toggle" | "latest") => void;
documents: Document[] | undefined;
currentVersionIndex: number;
}
};
export const VersionFooter = ({
handleVersionChange,
@ -32,15 +30,17 @@ export const VersionFooter = ({
const { mutate } = useSWRConfig();
const [isMutating, setIsMutating] = useState(false);
if (!documents) return;
if (!documents) {
return;
}
return (
<motion.div
className="absolute bottom-0 z-50 flex w-full flex-col justify-between gap-4 border-t bg-background p-4 lg:flex-row"
initial={{ y: isMobile ? 200 : 77 }}
animate={{ y: 0 }}
className="absolute bottom-0 z-50 flex w-full flex-col justify-between gap-4 border-t bg-background p-4 lg:flex-row"
exit={{ y: isMobile ? 200 : 77 }}
transition={{ type: 'spring', stiffness: 140, damping: 20 }}
initial={{ y: isMobile ? 200 : 77 }}
transition={{ type: "spring", stiffness: 140, damping: 20 }}
>
<div>
<div>You are viewing a previous version</div>
@ -60,11 +60,11 @@ export const VersionFooter = ({
await fetch(
`/api/document?id=${artifact.documentId}&timestamp=${getDocumentTimestampByIndex(
documents,
currentVersionIndex,
currentVersionIndex
)}`,
{
method: 'DELETE',
},
method: "DELETE",
}
),
{
optimisticData: documents
@ -75,14 +75,14 @@ export const VersionFooter = ({
new Date(
getDocumentTimestampByIndex(
documents,
currentVersionIndex,
),
),
),
currentVersionIndex
)
)
)
),
]
: [],
},
}
);
}}
>
@ -94,10 +94,10 @@ export const VersionFooter = ({
)}
</Button>
<Button
variant="outline"
onClick={() => {
handleVersionChange('latest');
handleVersionChange("latest");
}}
variant="outline"
>
Back to latest version
</Button>