-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
520 additions
and
490 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
apps/palette/web/src/components/actions/DeleteColorAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ActionButton } from '@a-type/ui/components/actions'; | ||
import { Icon } from '@a-type/ui/components/icon'; | ||
import { useColorSelection } from '../projects/hooks.js'; | ||
import { Project } from '@palette.biscuits/verdant'; | ||
import { hooks } from '@/hooks.js'; | ||
|
||
export function DeleteColorAction({ project }: { project: Project }) { | ||
const { colors } = hooks.useWatch(project); | ||
|
||
const [selectedId, selectId] = useColorSelection(); | ||
|
||
const deleteSelectedColor = () => { | ||
if (selectedId) { | ||
const val = colors.find((c) => c.get('id') === selectedId); | ||
if (val) { | ||
colors.removeAll(val); | ||
} | ||
selectId(null); | ||
} | ||
}; | ||
|
||
return ( | ||
<ActionButton | ||
color="destructive" | ||
onClick={deleteSelectedColor} | ||
icon={<Icon name="trash" />} | ||
visible={!!selectedId} | ||
> | ||
Delete color | ||
</ActionButton> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { ActionButton } from '@a-type/ui/components/actions'; | ||
import { ColorSort, useSort } from '../projects/hooks.js'; | ||
import { Icon } from '@a-type/ui/components/icon'; | ||
|
||
export function SortAction() { | ||
const [sort, setSort] = useSort(); | ||
|
||
const goNext = () => { | ||
const currentIndex = orderedOptions.indexOf(sort); | ||
const nextIndex = (currentIndex + 1) % orderedOptions.length; | ||
setSort(orderedOptions[nextIndex]); | ||
}; | ||
|
||
return ( | ||
<ActionButton | ||
onClick={goNext} | ||
icon={<Icon name="drag_vertical" />} | ||
className="capitalize" | ||
> | ||
{sort} | ||
</ActionButton> | ||
); | ||
} | ||
|
||
const orderedOptions: ColorSort[] = ['hue', 'saturation', 'lightness']; |
21 changes: 21 additions & 0 deletions
21
apps/palette/web/src/components/actions/ToggleBubblesAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { useSnapshot } from 'valtio'; | ||
import { toolState } from '../projects/state.js'; | ||
import { ActionButton } from '@a-type/ui/components/actions'; | ||
import { Icon } from '@a-type/ui/components/icon'; | ||
|
||
export interface ToggleBubblesActionProps {} | ||
|
||
export function ToggleBubblesAction({}: ToggleBubblesActionProps) { | ||
const showBubbles = useSnapshot(toolState).showBubbles; | ||
|
||
return ( | ||
<ActionButton | ||
icon={<Icon name={showBubbles ? 'eye' : 'eyeClosed'} />} | ||
toggled={showBubbles} | ||
toggleMode="state-only" | ||
onClick={() => (toolState.showBubbles = !showBubbles)} | ||
> | ||
Dots | ||
</ActionButton> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.