diff --git a/.husky/commit-msg b/.husky/commit-msg old mode 100755 new mode 100644 index c160a77..8fe1e0a --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -npx --no -- commitlint --edit ${1} +npx --no -- commitlint --edit ${1} \ No newline at end of file diff --git a/.husky/pre-push b/.husky/pre-push old mode 100755 new mode 100644 index 2c3af06..3bf9ea3 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,4 +1 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -pnpm lint +pnpm lint \ No newline at end of file diff --git a/package.json b/package.json index e2d336c..dedeb67 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "license": "MIT", "packageManager": "pnpm@8.15.1", "scripts": { - "prepare": "husky install", + "prepare": "husky", "clean": "rimraf dist storybook-static deployment", "dev": "vite --open", "build": "tsc && vite build", diff --git a/src/components/library/editor/atoms/filters/BlurFilterAtom.ts b/src/components/library/editor/atoms/filters/BlurFilterAtom.ts deleted file mode 100644 index 4777ca8..0000000 --- a/src/components/library/editor/atoms/filters/BlurFilterAtom.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { atom } from "jotai"; - -export const blurFilterAtom = atom(0); diff --git a/src/components/library/editor/atoms/filters/FilterAtoms.ts b/src/components/library/editor/atoms/filters/FilterAtoms.ts new file mode 100644 index 0000000..21370a6 --- /dev/null +++ b/src/components/library/editor/atoms/filters/FilterAtoms.ts @@ -0,0 +1,38 @@ +import { atom } from "jotai"; +import type { StagedFilter } from "../../stage/StagedFilters"; + +export const blurFilterAtom = atom(0); +export const brightnessFilterAtom = atom(1); +export const contrastFilterAtom = atom(1); +export const saturationFilterAtom = atom(1); + +// Derived +export const controlFilterAtom = atom( + (get) => { + const blur = get(blurFilterAtom); + const brightness = get(brightnessFilterAtom); + const contrast = get(contrastFilterAtom); + const saturation = get(saturationFilterAtom); + + return { + blur, + brightness, + contrast, + saturation, + }; + }, + (_get, set, update: Partial) => { + if (update.blur !== undefined) { + set(blurFilterAtom, update.blur); + } + if (update.brightness !== undefined) { + set(brightnessFilterAtom, update.brightness); + } + if (update.contrast !== undefined) { + set(contrastFilterAtom, update.contrast); + } + if (update.saturation !== undefined) { + set(saturationFilterAtom, update.saturation); + } + } +); diff --git a/src/components/library/editor/drawer/FilterDrawer.stories.tsx b/src/components/library/editor/drawer/FilterDrawer.stories.tsx index 0df8164..7e3626e 100644 --- a/src/components/library/editor/drawer/FilterDrawer.stories.tsx +++ b/src/components/library/editor/drawer/FilterDrawer.stories.tsx @@ -13,9 +13,12 @@ type Story = StoryObj; const commonProps = { open: true, - onClose: () => console.log("onClose"), blur: 40, - onBlurChange: () => console.log("onBlurChange"), + brightness: 1, + contrast: 1, + saturation: 1, + onFilterChange: () => console.log("onFilterChange"), + onClose: () => console.log("onClose"), } satisfies ComponentProps; export const Filter = { diff --git a/src/components/library/editor/drawer/FilterDrawer.tsx b/src/components/library/editor/drawer/FilterDrawer.tsx index 21630ce..5efe3d7 100644 --- a/src/components/library/editor/drawer/FilterDrawer.tsx +++ b/src/components/library/editor/drawer/FilterDrawer.tsx @@ -1,15 +1,27 @@ import { useRef, type ReactElement } from "react"; import { XMarkIcon } from "@heroicons/react/24/solid"; import { useOnClickOutside } from "usehooks-ts"; +import type { StagedFilter } from "../stage/StagedFilters"; export interface FilterDrawerProps { open: boolean; - onClose: () => void; blur: number; - onBlurChange: (value: number) => void; + brightness: number; + contrast: number; + saturation: number; + onFilterChange: (filter: Partial) => void; + onClose: () => void; } -export function FilterDrawer({ open, onClose, blur, onBlurChange }: FilterDrawerProps): ReactElement { +export function FilterDrawer({ + open, + onClose, + blur, + brightness, + contrast, + saturation, + onFilterChange, +}: FilterDrawerProps): ReactElement { const menuRef = useRef(null); useOnClickOutside(menuRef, onClose); @@ -19,23 +31,58 @@ export function FilterDrawer({ open, onClose, blur, onBlurChange }: FilterDrawer