Skip to content

Commit

Permalink
fix: fixed missing includes bug and cleaned up typing in the text card
Browse files Browse the repository at this point in the history
  • Loading branch information
katungi committed Apr 11, 2024
1 parent 6d13ff0 commit 92b040d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Pasta",
"version": "0.1.0",
"version": "0.0.2",
"private": true,
"author": {
"name": "Daniel Denis",
Expand Down
6 changes: 5 additions & 1 deletion src/components/Empty.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client"

import dynamic from "next/dynamic"
import React from "react"

Expand All @@ -7,6 +9,8 @@ const Lottie = dynamic(() => import("lottie-react"), {
ssr: false, // Disable server-side rendering for this component
})

const Empty = () => <Lottie animationData={EmptyClipBoard} loop={true} width={80} height={80} />
const Empty = () => (
<Lottie animationData={EmptyClipBoard} loop={true} width={80} height={80} />
)

export default Empty
25 changes: 18 additions & 7 deletions src/components/TextCard.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
import { clipboard } from "@tauri-apps/api"
"use client"

import { formatDistanceToNow } from "date-fns"
import React from "react"
import toast from "react-hot-toast"
import clipboard from "tauri-plugin-clipboard-api"

import { ClipboardIcon, TrashIcon } from "@/components/Icons"
import { useClipStore } from "@/store/clips.store"

import { Button } from "./ui/button"

// @ts-ignore
export const ClipboardItem = ({ clip }) => {
interface Clip {
text: string
time: string // Assuming ISO string or similar
}

interface ClipboardItemProps {
clip: Clip
}

export const ClipboardItem: React.FC<ClipboardItemProps> = ({ clip }) => {
const { removeClip } = useClipStore()
async function AddToClipBoard() {
await clipboard.writeText(clip.text)
toast.success("Added to Clipboard")
}

return (
<div className="flex items-center gap-2 p-2 rounded-md bg-gray-100 dark:bg-gray-800 cursor-pointer hover:bg-gray-200">
<Button
size="sm"
variant={"ghost"}
onClick={async () => {
await clipboard.writeText(clip.text)
toast.success("Added to clipboard")
}}
onClick={async () => AddToClipBoard()}
>
<ClipboardIcon className="h-6 w-6 rounded-md text-muted" />
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const Home: NextPage = () => {
</CardHeader>
<CardContent className="p-0 flex flex-col overflow-auto">
<div className="flex-1 flex flex-col gap-2 px-6 items-start">
{clips.length >= 1 ? (
{clips.length && clips.length >= 1 ? (
<div className="grid gap-2 text-sm w-full">
{clips.map((item, index) => (
<ClipboardItem key={index} clip={item} />
Expand Down

0 comments on commit 92b040d

Please sign in to comment.