Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat(editor): add getColorPreviewBorderColor utility with inset border

Richie McIlroybaac89cb79d2
diff --git a/apps/desktop/src/routes/editor/color-utils.tsx b/apps/desktop/src/routes/editor/color-utils.tsx
index 72c42397e..010f68b2c 100644
--- a/apps/desktop/src/routes/editor/color-utils.tsx
+++ b/apps/desktop/src/routes/editor/color-utils.tsx
@@ -1,6 +1,10 @@
import { createWritableMemo } from "@solid-primitives/memo";
import { TextInput } from "./TextInput";
+export function getColorPreviewBorderColor(color: string) {
+ return `color-mix(in srgb, ${color} 82%, black)`;
+}
+
export function rgbToHex(rgb: [number, number, number]) {
return `#${rgb
.map((c) => c.toString(16).padStart(2, "0"))
@@ -44,6 +48,9 @@ export function RgbInput(props: {
class="size-[2rem] rounded-[0.5rem]"
style={{
"background-color": rgbToHex(props.value),
+ "box-shadow": `inset 0 0 0 1px ${getColorPreviewBorderColor(
+ rgbToHex(props.value),
+ )}`,
}}
onClick={() => colorInput.click()}
/>