Skip to content

Commit

Permalink
fix preview
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorVation committed May 18, 2023
1 parent 311be52 commit f4b94c9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 24 deletions.
70 changes: 47 additions & 23 deletions app/editor/[siteId]/SiteSettingsCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
"use client";

import { X, Loader2, ChevronsUpDownIcon, Palette } from "lucide-react";
import {
X,
Loader2,
ChevronsUpDownIcon,
Palette,
ClipboardCopy,
} from "lucide-react";
import { useRouter } from "next/navigation";

import { useForm } from "react-hook-form";
Expand Down Expand Up @@ -32,6 +38,14 @@ type Inputs = {
backgroundColor: string;
};

async function copyLinkToClipboard(e: React.SyntheticEvent, siteName: string) {
e.preventDefault();
await navigator.clipboard.writeText(
`${process.env.NEXT_PUBLIC_BASE_URL}/${siteName}`
);
toast.success("Link copied!", { id: "clipboard" });
}

export default function AddLinkCard({ siteName, siteId }: Props) {
const router = useRouter();
const {
Expand Down Expand Up @@ -73,24 +87,34 @@ export default function AddLinkCard({ siteName, siteId }: Props) {
>
<div className="grid w-full items-center gap-1.5">
<Label htmlFor="siteName">Site Name</Label>
<div
className={
"text-md h-13 flex w-full flex-row justify-start rounded-md border border-input bg-transparent px-3 align-middle ring-offset-background"
}
>
<label
htmlFor="siteName"
className=" m-auto block cursor-text select-none text-muted-foreground"

<div className="flex w-full items-center space-x-2">
<div
className={
"text-md h-13 flex w-full flex-row justify-start rounded-md border border-input bg-transparent px-3 align-middle ring-offset-background"
}
>
introducty.com/
</label>
<Input
type="text"
id="siteName"
placeholder="Title"
className="block border-none pl-0 focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0"
{...register("siteName", { required: true })}
/>
<label
htmlFor="siteName"
className=" m-auto block cursor-text select-none text-muted-foreground"
>
introducty.com/
</label>
<Input
type="text"
id="siteName"
placeholder="Title"
className="block border-none pl-0 focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0"
{...register("siteName", { required: true })}
/>
</div>
<Button
className="p-4 py-6"
variant="outline"
onClick={(e) => copyLinkToClipboard(e, siteName)}
>
<ClipboardCopy />
</Button>
</div>
{errors.siteName && (
<p className="text-sm text-rose-400">This field is required</p>
Expand All @@ -110,6 +134,11 @@ export default function AddLinkCard({ siteName, siteId }: Props) {
{...backgroundColorFields}
/>
<Popover>
<PopoverTrigger asChild>
<Button className="p-4 py-6" variant="outline">
<Palette />
</Button>
</PopoverTrigger>
<PopoverContent className="w-auto bg-background p-2">
<HexColorPicker
color={watch("backgroundColor")}
Expand All @@ -119,11 +148,6 @@ export default function AddLinkCard({ siteName, siteId }: Props) {
}}
/>
</PopoverContent>
<PopoverTrigger asChild>
<Button className="p-4 py-6" variant="outline">
<Palette />
</Button>
</PopoverTrigger>
</Popover>
</div>
{errors.backgroundColor && (
Expand Down
4 changes: 3 additions & 1 deletion app/editor/[siteId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export default async function Editor({ params }: Props) {
return (
<EditorContextProvider>
<div
className={" mx-auto flex max-w-screen-xl justify-between gap-2 py-20 "}
className={
"mx-auto flex max-w-screen-xl flex-wrap justify-between gap-2 py-20 md:flex-nowrap"
}
>
<div className="mx-auto grid grid-cols-1 gap-4 xl:grid-flow-col xl:grid-cols-2">
<SiteSettingsCard siteId={siteId} siteName={siteName} />
Expand Down

1 comment on commit f4b94c9

@vercel
Copy link

@vercel vercel bot commented on f4b94c9 May 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.