|
@@ -1,6 +1,6 @@
|
|
import * as React from 'react'
|
|
import * as React from 'react'
|
|
-import * as Popover from '@radix-ui/react-popover';
|
|
|
|
-import * as Slider from '@radix-ui/react-slider';
|
|
|
|
|
|
+import * as Popover from '@radix-ui/react-popover'
|
|
|
|
+import * as Slider from '@radix-ui/react-slider'
|
|
import { TablerIcon } from '../icons'
|
|
import { TablerIcon } from '../icons'
|
|
import { Color } from '@tldraw/core'
|
|
import { Color } from '@tldraw/core'
|
|
interface ColorInputProps extends React.InputHTMLAttributes<HTMLButtonElement> {
|
|
interface ColorInputProps extends React.InputHTMLAttributes<HTMLButtonElement> {
|
|
@@ -14,41 +14,45 @@ export function ColorInput({ color, opacity, setColor, setOpacity, ...rest }: Co
|
|
const ref = React.useRef<HTMLDivElement>(null)
|
|
const ref = React.useRef<HTMLDivElement>(null)
|
|
|
|
|
|
function renderColor(color: string) {
|
|
function renderColor(color: string) {
|
|
- return color ?
|
|
|
|
- <div className="tl-color-bg" style={{backgroundColor: color}}>
|
|
|
|
|
|
+ return color ? (
|
|
|
|
+ <div className="tl-color-bg" style={{ backgroundColor: color }}>
|
|
<div className={`w-full h-full bg-${color}-500`}></div>
|
|
<div className={`w-full h-full bg-${color}-500`}></div>
|
|
- </div> :
|
|
|
|
- <div className={"tl-color-bg"}><TablerIcon name="color-swatch" /></div>
|
|
|
|
|
|
+ </div>
|
|
|
|
+ ) : (
|
|
|
|
+ <div className={'tl-color-bg'}>
|
|
|
|
+ <TablerIcon name="color-swatch" />
|
|
|
|
+ </div>
|
|
|
|
+ )
|
|
}
|
|
}
|
|
|
|
|
|
return (
|
|
return (
|
|
<Popover.Root>
|
|
<Popover.Root>
|
|
-
|
|
|
|
<Popover.Trigger>
|
|
<Popover.Trigger>
|
|
- <button className="tl-color-drip mx-1">
|
|
|
|
- {renderColor(color)}
|
|
|
|
- </button>
|
|
|
|
|
|
+ <button className="tl-color-drip mx-1">{renderColor(color)}</button>
|
|
</Popover.Trigger>
|
|
</Popover.Trigger>
|
|
|
|
|
|
<Popover.Portal>
|
|
<Popover.Portal>
|
|
- <Popover.Content
|
|
|
|
- className="tl-popover-content"
|
|
|
|
- side="top"
|
|
|
|
- sideOffset={15}
|
|
|
|
- >
|
|
|
|
- <div className={"tl-color-palette"}>
|
|
|
|
- {Object.values(Color).map(value =>
|
|
|
|
|
|
+ <Popover.Content className="tl-popover-content" side="top" sideOffset={15}>
|
|
|
|
+ <div className={'tl-color-palette'}>
|
|
|
|
+ {Object.values(Color).map(value => (
|
|
<button
|
|
<button
|
|
- className={`tl-color-drip m-1${value === color ? " active" : ""}`}
|
|
|
|
- onClick={()=>setColor(value)}
|
|
|
|
|
|
+ className={`tl-color-drip m-1${value === color ? ' active' : ''}`}
|
|
|
|
+ onClick={() => setColor(value)}
|
|
>
|
|
>
|
|
{renderColor(value)}
|
|
{renderColor(value)}
|
|
</button>
|
|
</button>
|
|
- )}
|
|
|
|
|
|
+ ))}
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div className="m-1">
|
|
<div className="m-1">
|
|
- <Slider.Root defaultValue={[opacity]} onValueCommit={(value)=>setOpacity(value[0])} max={1} step={0.1} aria-label="Opacity" className="tl-slider-root">
|
|
|
|
|
|
+ <Slider.Root
|
|
|
|
+ defaultValue={[opacity]}
|
|
|
|
+ onValueCommit={value => setOpacity(value[0])}
|
|
|
|
+ max={1}
|
|
|
|
+ step={0.1}
|
|
|
|
+ aria-label="Opacity"
|
|
|
|
+ className="tl-slider-root"
|
|
|
|
+ >
|
|
<Slider.Track className="tl-slider-track">
|
|
<Slider.Track className="tl-slider-track">
|
|
<Slider.Range className="tl-slider-range" />
|
|
<Slider.Range className="tl-slider-range" />
|
|
</Slider.Track>
|
|
</Slider.Track>
|
|
@@ -57,7 +61,6 @@ export function ColorInput({ color, opacity, setColor, setOpacity, ...rest }: Co
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<Popover.Arrow className="tl-popover-arrow" />
|
|
<Popover.Arrow className="tl-popover-arrow" />
|
|
-
|
|
|
|
</Popover.Content>
|
|
</Popover.Content>
|
|
</Popover.Portal>
|
|
</Popover.Portal>
|
|
</Popover.Root>
|
|
</Popover.Root>
|