🎥 Make videos programmatically with React
`@remotion/studio`: Reset timeline color picker opacity (#8314)
Jonny Burger20ddd1b9cf28
diff --git a/packages/studio/src/components/ColorPicker/ColorPickerPopup.tsx b/packages/studio/src/components/ColorPicker/ColorPickerPopup.tsxindex bce6cdfc81..056eedd93c 100644--- a/packages/studio/src/components/ColorPicker/ColorPickerPopup.tsx+++ b/packages/studio/src/components/ColorPicker/ColorPickerPopup.tsx@@ -121,6 +121,14 @@ const eyedropperButtonStyle: React.CSSProperties = {const hasEyeDropper = (): boolean =>typeof window !== 'undefined' && 'EyeDropper' in window;+export const parseEyeDropperColor = (pickedColor: string) => {+ const parsed = parseAnyColor(pickedColor);+ return {+ ...parsed,+ a: 255,+ };+};+export type ChannelKey = 'r' | 'g' | 'b' | 'a-percent';type ChannelInputProps = {@@ -376,10 +384,7 @@ export const ColorPickerPopup: React.FC<{dropper.open().then((result) => {- const parsed = parseAnyColor(result.sRGBHex);- // `EyeDropper` always returns full opacity; preserve the user's- // previously chosen alpha so opening it doesn't drop transparency.- parsed.a = rgba.a;+ const parsed = parseEyeDropperColor(result.sRGBHex);const newHsva = rgbaToHsva(parsed);if (newHsva.s === 0) {newHsva.h = hsva.h;@@ -390,7 +395,7 @@ export const ColorPickerPopup: React.FC<{.catch(() => {// Aborted; ignore.});- }, [emit, hsva.h, rgba.a]);+ }, [emit, hsva.h]);const previewFill: React.CSSProperties = useMemo(() => {return {diff --git a/packages/studio/src/test/color-conversion.test.ts b/packages/studio/src/test/color-conversion.test.tsindex e85d30f6dd..628b426e93 100644--- a/packages/studio/src/test/color-conversion.test.ts+++ b/packages/studio/src/test/color-conversion.test.ts@@ -1,4 +1,5 @@import {expect, test} from 'bun:test';+import {parseEyeDropperColor} from '../components/ColorPicker/ColorPickerPopup';import {formatRgba,hsvToRgb,@@ -35,6 +36,15 @@ test('formatRgba returns rgba when transparent', () => {expect(formatRgba({r: 255, g: 0, b: 0, a: 128})).toBe('rgba(255, 0, 0, 0.5)');});+test('parseEyeDropperColor always returns a fully opaque color', () => {+ expect(parseEyeDropperColor('#ff000080')).toEqual({+ r: 255,+ g: 0,+ b: 0,+ a: 255,+ });+});+test('rgbToHsv / hsvToRgb roundtrip primaries', () => {const reds = rgbToHsv({r: 255, g: 0, b: 0});expect(Math.round(reds.h)).toBe(0);