Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ import {
PopoverTrigger,
} from "@chakra-ui/react"
import { memo, useEffect, useState } from "react"
import ColorPicker from "react-best-gradient-color-picker"
import ColorPicker, { ColorPickerProps } from "react-best-gradient-color-picker"
import { useDebounce } from "../../hooks/useDebounce"

const ColorPickerField = ({
fieldName,
value,
setValue,
fieldProps,
}: {
fieldName: string
value: string
setValue: (name: string, value: string) => void
fieldProps?: ColorPickerProps
}) => {
const [localValue, setLocalValue] = useState<string>(value)

Expand All @@ -35,7 +37,7 @@ const ColorPickerField = ({
.map((v) => v.toString(16).padStart(2, "0"))
.join("")

if (a === undefined) {
if (fieldProps?.hideOpacity === true || a === undefined) {
setLocalValue(`#${rgbHex}`)
} else {
const alphaDec = a > 1 ? a / 100 : a
Expand Down Expand Up @@ -107,6 +109,8 @@ const ColorPickerField = ({
hideInputs
hideAdvancedSliders
hideColorGuide
// @ts-expect-error - fieldProps may include props not declared in ColorPickerProps, but they are intentionally forwarded
{...fieldProps}
/>
</PopoverBody>
</PopoverContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { SidebarBody } from "./sidebar-body"
import { SidebarFooter } from "./sidebar-footer"
import { SidebarHeader } from "./sidebar-header"
import { SidebarRoot } from "./sidebar-root"
import { ColorPickerProps } from "react-best-gradient-color-picker"

export const TransformationConfigSidebar: React.FC = () => {
const {
Expand Down Expand Up @@ -533,6 +534,7 @@ export const TransformationConfigSidebar: React.FC = () => {
fieldName={field.name}
value={watch(field.name) as string}
setValue={setValue}
fieldProps={field.fieldProps as ColorPickerProps}
/>
) : null}
{field.fieldType === "anchor" ? (
Expand Down
Loading