Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions components/view/background-snippets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

import { useState } from "react";

import { Button } from "@/components/ui/button";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Switch } from "@/components/ui/switch";
import { useMediaQuery } from "@/components/ui/use-media-query";
import { useGradientStops } from "@/hooks/use-gradient-stops";
import { cn } from "@/lib/utils";
import { ChevronsDown } from "lucide-react";
import { Bookmark, ChevronsDown, PanelsTopLeft, Settings2 } from "lucide-react";
import { CodeDisplay } from "./code-output/code-display";
import { getFullCode } from "./code-output/code-generator";
import { ColorPickerPopover } from "./color-pickers/color-picker-popover";
Expand Down Expand Up @@ -62,6 +63,7 @@ export default function BackgroundPatternGenerator() {
const [activePresetId, setActivePresetId] = useState<string | undefined>(
undefined,
);
const [activeSidebarTab, setActiveSidebarTab] = useState<"presets" | "settings" | "saved">("settings");

const [gradientPositionX, setGradientPositionX] = useState(30);
const [gradientPositionY, setGradientPositionY] = useState(10);
Expand Down Expand Up @@ -281,7 +283,14 @@ export default function BackgroundPatternGenerator() {
{!isMobile && (
<ScrollArea className="inset-shadow-[0_1px_rgb(0_0_0/0.10)] max-h-[95vh] rounded-xl border bg-card-bg p-3 lg:col-span-4 xl:col-span-1 dark:inset-shadow-[0_1px_rgb(255_255_255/0.15)] dark:border-0 ">
<div className="space-y-3">
<div className="space-y-2 rounded-lg border bg-main p-3">
<div className="grid grid-cols-3 gap-2">
{[{ key: "presets", icon: PanelsTopLeft }, { key: "settings", icon: Settings2 }, { key: "saved", icon: Bookmark }].map(({ key, icon: Icon }) => (
<Button key={key} variant="empty" className={cn("h-9 rounded-md border", activeSidebarTab === key && "bg-main")} onClick={() => setActiveSidebarTab(key as "presets" | "settings" | "saved")}>
<Icon className="size-4" />
</Button>
))}
</div>
{activeSidebarTab === "settings" && <div className="space-y-2 rounded-lg border bg-main p-3">
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Close the settings conditional before the next panel

In the Background Snippets editor, this new {activeSidebarTab === "settings" && <div ...> expression is never closed with a } before the following GradientControls <div> sibling, so the TSX is syntactically invalid and this page will fail to compile/render as soon as the file is parsed.

Useful? React with 👍 / 👎.

<ColorPickerPopover
color={bgColor}
onChange={setBgColor}
Expand Down
3 changes: 2 additions & 1 deletion components/view/mesh-gradient/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
} from "@/types/shader-gradient";
import { ShaderGradientCanvas } from "@shadergradient/react";
import { ShaderGradient } from "@shadergradient/react";
import { ChevronsDown, Menu, MenuIcon } from "lucide-react";
import { Bookmark, ChevronsDown, PanelsTopLeft, Settings2 } from "lucide-react";
import { type JSX, Suspense, useState } from "react";
import { ControlPanel } from "./control-panel";
import { CopyCode } from "./copy-code";
Expand Down Expand Up @@ -261,6 +261,7 @@ export function ShaderGradientGenerator(): JSX.Element {
const [settings, setSettings] =
useState<ShaderGradientSettings>(defaultSettings);
const [selectedExample, setSelectedExample] = useState<string>("");
const [activeSidebarTab, setActiveSidebarTab] = useState<"presets" | "settings" | "saved">("presets");
const updateSettings = (
newSettings: Partial<ShaderGradientSettings>,
): void => {
Expand Down