From 2c0423667cf3c8fedb194c7b34b5edd5657628f4 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Sat, 2 Aug 2025 16:09:20 +0200 Subject: feat: background gradients to project settings --- .../editor/media-panel/views/settings.tsx | 111 ++++++++++++++++----- apps/web/src/components/editor/preview-panel.tsx | 4 +- 2 files changed, 89 insertions(+), 26 deletions(-) (limited to 'apps/web/src/components/editor') diff --git a/apps/web/src/components/editor/media-panel/views/settings.tsx b/apps/web/src/components/editor/media-panel/views/settings.tsx index 8667b9d1..3bce1753 100644 --- a/apps/web/src/components/editor/media-panel/views/settings.tsx +++ b/apps/web/src/components/editor/media-panel/views/settings.tsx @@ -22,9 +22,11 @@ import { useEditorStore } from "@/stores/editor-store"; import { useAspectRatio } from "@/hooks/use-aspect-ratio"; import Image from "next/image"; import { cn } from "@/lib/utils"; -import { colors } from "@/data/colors"; +import { colors } from "@/data/colors/solid"; +import { patternCraftGradients } from "@/data/colors/pattern-craft"; import { PipetteIcon } from "lucide-react"; import { useMemo, memo, useCallback } from "react"; +import { syntaxUIGradients } from "@/data/colors/syntax-ui"; export function SettingsView() { return ; @@ -137,8 +139,8 @@ const BlurPreview = memo( }) => (
@@ -161,6 +163,57 @@ const BlurPreview = memo( BlurPreview.displayName = "BlurPreview"; +const BackgroundPreviews = memo( + ({ + backgrounds, + currentBackgroundColor, + isColorBackground, + handleColorSelect, + useBackgroundColor = false, + }: { + backgrounds: string[]; + currentBackgroundColor: string; + isColorBackground: boolean; + handleColorSelect: (bg: string) => void; + useBackgroundColor?: boolean; + }) => { + return useMemo( + () => + backgrounds.map((bg) => ( +
handleColorSelect(bg)} + /> + )), + [ + backgrounds, + isColorBackground, + currentBackgroundColor, + handleColorSelect, + useBackgroundColor, + ] + ); + } +); + +BackgroundPreviews.displayName = "BackgroundPreviews"; + function BackgroundView() { const { activeProject, updateBackgroundType } = useProjectStore(); @@ -205,36 +258,46 @@ function BackgroundView() { [blurLevels, isBlurBackground, currentBlurIntensity, handleBlurSelect] ); - const colorPreviews = useMemo( - () => - colors.map((color) => ( -
handleColorSelect(color)} - /> - )), - [isColorBackground, currentBackgroundColor, handleColorSelect] - ); - return (
- +
{blurPreviews}
- +
- {colorPreviews} + +
+
+ + +
+ +
+
+ + +
+
diff --git a/apps/web/src/components/editor/preview-panel.tsx b/apps/web/src/components/editor/preview-panel.tsx index 3a962025..58cc5d5b 100644 --- a/apps/web/src/components/editor/preview-panel.tsx +++ b/apps/web/src/components/editor/preview-panel.tsx @@ -480,7 +480,7 @@ export function PreviewPanel() { style={{ width: previewDimensions.width, height: previewDimensions.height, - backgroundColor: + background: activeProject?.backgroundType === "blur" ? "transparent" : activeProject?.backgroundColor || "#000000", @@ -742,7 +742,7 @@ function FullscreenPreview({ style={{ width: previewDimensions.width, height: previewDimensions.height, - backgroundColor: + background: activeProject?.backgroundType === "blur" ? "#1a1a1a" : activeProject?.backgroundColor || "#1a1a1a", -- cgit v1.3.1