Skip to content

Commit

Permalink
save to clone
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Jan 19, 2024
1 parent 6e9e697 commit 8924356
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/ColorScatterPlot.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
startDragging();
const targetIsPoint = typeof idx === "number";
let target = e.target;
const isMetaKey = e.metaKey || e.shiftKey;
const isMetaKey = e.metaKey || e.shiftKey || e.ctrlKey;
isPointDrag = false;
if (targetIsPoint && !focusSet.has(idx)) {
const newSet = isMetaKey ? [...focusSet, idx] : [idx];
Expand Down
11 changes: 11 additions & 0 deletions src/components/KeyboardHooks.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@
colorStore.setCurrentPalColors(newColors);
}
// SAVE BY DUPLICATING PALETTE
if (key === "s" && metaKey) {
e.preventDefault();
const newPal = {
...$colorStore.currentPal,
name: `${$colorStore.currentPal.name} copy`,
colors: [...$colorStore.currentPal.colors],
};
colorStore.createNewPal(newPal);
}
// COPY PASTE
if (key === "c" && metaKey && $focusStore.focusedColors.length) {
copiedData = $colorStore.currentPal.colors.filter((_, idx) =>
Expand Down
2 changes: 1 addition & 1 deletion src/stores/color-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function insertPalette(palettes: Palette[], pal: Palette): Palette[] {
0
);
const name = nameCount === 0 ? pal.name : `${pal.name} ${nameCount}`;
return [...palettes, { ...pal, name }];
return [{ ...pal, name }, ...palettes];
}

// install defaults if not present
Expand Down

0 comments on commit 8924356

Please sign in to comment.