Skip to content

Commit

Permalink
fix: fix rgb format input value error
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwusanyu-c committed Mar 15, 2024
1 parent ed8a5db commit df7706b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions components/ColorPicker/src/format.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
const dispatch = createEventDispatcher();
function handleInput(e: CustomEvent, type: 'hr' | 'sg' | 'vb' | 'a' | 'hex') {
if (e.detail === null) return;
if (type === 'hr') {
hRValue = e.detail;
}
Expand Down Expand Up @@ -145,7 +146,7 @@
{#if formatValue !== 'hex'}
<KInputNumber
value={hRValue}
min={1}
min={0}
step={1}
stepStrictly
max={hRMaxValue}
Expand All @@ -155,7 +156,7 @@
></KInputNumber>
<KInputNumber
value={sGValue}
min={1}
min={0}
step={1}
max={sGMaxValue}
stepStrictly
Expand All @@ -166,7 +167,7 @@

<KInputNumber
value={vBValue}
min={1}
min={0}
step={1}
max={vBMaxValue}
stepStrictly
Expand Down
5 changes: 3 additions & 2 deletions components/ColorPicker/src/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,14 @@
}
let hsvValue: HsvaColor = { h: 0, s: 0, v: 0, a: 100 };
let hsvDefaultValue: HsvaColor = { h: 0, s: 0, v: 0, a: 100 };
$: {
hsvValue = tinycolor(value).toHsv() as HsvaColor;
hsvValue.s = hsvValue.s * 100;
hsvValue.v = hsvValue.v * 100;
}
let hsvDefaultValue: HsvaColor = { h: 0, s: 0, v: 0, a: 100 };
$: {
hsvDefaultValue = tinycolor(defaultValue).toHsv();
hsvDefaultValue.s = hsvDefaultValue.s * 100;
hsvDefaultValue.v = hsvDefaultValue.v * 100;
Expand Down Expand Up @@ -158,7 +160,6 @@
<div slot="text" class={txtCls} style:display={showText ? 'initial' : 'none'}>
{#if showText}
<slot name="text">
{formatValue}
{formatColor(formatValue, blockColor)}
</slot>
{/if}
Expand Down
1 change: 0 additions & 1 deletion components/ColorPicker/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ export type KColorPickerFormatProps = {
// TODO 馃搶0000鏃舵嫿涓嶅姩
// TODO 馃搶360 鏃跺彉鎴愪簡0
// TODO: 馃搶鎷栨嫿浼樺寲

export interface RgbaColor {
r: number;
g: number;
Expand Down

0 comments on commit df7706b

Please sign in to comment.