Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat(desktop): add brand colors to gradient editor
Richie McIlroy6aff2a0c2835
diff --git a/apps/desktop/src/routes/editor/GradientEditor.tsx b/apps/desktop/src/routes/editor/GradientEditor.tsxindex 81fad0a60..b09b7e09d 100644--- a/apps/desktop/src/routes/editor/GradientEditor.tsx+++ b/apps/desktop/src/routes/editor/GradientEditor.tsx@@ -1,5 +1,7 @@import { createMemo, createUniqueId, For, Show } from "solid-js";-import { RgbInput } from "./color-utils";+import type { OrganizationBrandColorSwatch } from "~/utils/organization-branding";+import { BrandColorsDropdown } from "./BrandColorsDropdown";+import { hexToRgb, RgbInput } from "./color-utils";import { useEditorContext } from "./context";import type { RGBColor } from "./projectConfig";import { Slider, Subfield } from "./ui";@@ -45,7 +47,9 @@ function randomColor(): RGBColor {];}-export function GradientEditor() {+export function GradientEditor(props: {+ brandColorSwatches: OrganizationBrandColorSwatch[];+}) {const { project, setProject } = useEditorContext();const filterId = createUniqueId();@@ -62,6 +66,13 @@ export function GradientEditor() {setProject("background", "source", updates as Record<string, unknown>);};+ const updateGradientColor = (key: "from" | "to", color: string) => {+ const rgb = hexToRgb(color);+ if (!rgb) return;+ const [r, g, b] = rgb;+ updateGradient({ [key]: [r, g, b] as RGBColor });+ };+const gradientCSS = createMemo(() => {const s = source();if (!s) return "";@@ -120,21 +131,33 @@ export function GradientEditor() {<div class="flex gap-3 items-end"><div class="flex-1 min-w-0"><span class="text-[11px] text-gray-10 mb-1 block">From</span>- <RgbInput- value={src().from}- onChange={(from) => {- updateGradient({ from });- }}- />+ <div class="flex flex-col gap-2">+ <RgbInput+ value={src().from}+ onChange={(from) => {+ updateGradient({ from });+ }}+ />+ <BrandColorsDropdown+ swatches={props.brandColorSwatches}+ onSelect={(color) => updateGradientColor("from", color)}+ />+ </div></div><div class="flex-1 min-w-0"><span class="text-[11px] text-gray-10 mb-1 block">To</span>- <RgbInput- value={src().to}- onChange={(to) => {- updateGradient({ to });- }}- />+ <div class="flex flex-col gap-2">+ <RgbInput+ value={src().to}+ onChange={(to) => {+ updateGradient({ to });+ }}+ />+ <BrandColorsDropdown+ swatches={props.brandColorSwatches}+ onSelect={(color) => updateGradientColor("to", color)}+ />+ </div></div></div>