Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Color editor allow any color representation
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelEstes committed Aug 16, 2024
1 parent 615a547 commit 05bc999
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/ui/src/primitives/tailwind/Color/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ Ethereal Engine. All Rights Reserved.
import { ColorResult } from '@uiw/color-convert'
import SketchPicker from '@uiw/react-color-sketch'
import React from 'react'
import { Color } from 'three'
import { Color, ColorRepresentation } from 'three'

import { twMerge } from 'tailwind-merge'
import Text from '../Text'

interface ColorInputProp {
value: Color
value: ColorRepresentation
onChange: (color: Color) => void
onRelease?: (color: Color) => void
disabled?: boolean
Expand All @@ -50,7 +50,8 @@ export function ColorInput({
textClassName,
sketchPickerClassName
}: ColorInputProp) {
const hexColor = typeof value.getHexString === 'function' ? '#' + value.getHexString() : '#000'
const color = new Color(value)
const hexColor = typeof color.getHexString === 'function' ? '#' + color.getHexString() : '#000'

const handleChange = (result: ColorResult) => {
const color = new Color(result.hex)
Expand Down Expand Up @@ -78,7 +79,7 @@ export function ColorInput({
onChange={handleChange}
disableAlpha={true}
onPointerLeave={() => {
onRelease && onRelease(value)
onRelease && onRelease(color)
}}
/>
</div>
Expand Down

0 comments on commit 05bc999

Please sign in to comment.