diff --git a/src/routes/resources/animtab/index.tsx b/src/routes/resources/animtab/index.tsx index f74d3d96..a92a7016 100644 --- a/src/routes/resources/animtab/index.tsx +++ b/src/routes/resources/animtab/index.tsx @@ -1,10 +1,10 @@ -import { $, component$, useStore, useTask$, useVisibleTask$ } from '@builder.io/qwik'; +import { $, component$, useSignal, useStore, useTask$, useVisibleTask$ } from '@builder.io/qwik'; import { routeLoader$, type DocumentHead } from '@builder.io/qwik-city'; import { defaults, loadPreset, types, v3formats, presets as presetlist } from '~/components/util/PresetUtils'; import { AnimationOutput, convertToHex, convertToRGB, getAnimFrames, getBrightness, getRandomColor } from '~/components/util/RGBUtils'; -import { Add, BarChartOutline, ChevronDown, ChevronUp, ColorFillOutline, DiceOutline, DownloadOutline, GlobeOutline, LinkOutline, SaveOutline, SettingsOutline, ShareOutline, Text, TrashOutline } from 'qwik-ionicons'; +import { Add, BarChartOutline, ChevronDown, ChevronUp, CloseOutline, ColorFillOutline, DiceOutline, DownloadOutline, GlobeOutline, LinkOutline, SaveOutline, SettingsOutline, ShareOutline, Text, TrashOutline } from 'qwik-ionicons'; import { Dropdown, Toggle, NumberInput, ColorPicker } from '@luminescent/ui-qwik'; import { inlineTranslate, useSpeak } from 'qwik-speak'; @@ -32,7 +32,7 @@ export const useCookies = routeLoader$(async ({ cookie, url }) => { return { animtab: animtabCookies, rgb: rgbCookies, - presets: presetCookies.savedPresets || [], + presets: presetCookies, }; }); @@ -45,6 +45,9 @@ export default component$(() => { ...structuredClone(rgbDefaults), ...cookies.rgb, }, { deep: true }); + const presetstore = useStore({ + ...cookies.presets, + }); const animtabstore = useStore({ ...animTABDefaults, @@ -88,6 +91,8 @@ export default component$(() => { store.colors = sortColors(newColors); }); + const modalRef = useSignal(); + // eslint-disable-next-line qwik/no-use-visible-task useVisibleTask$(async () => { let lastTime = performance.now(); @@ -633,7 +638,7 @@ export default component$(() => { }, 2000); } } values={ - cookies.presets.map((preset) => ({ + presetstore.savedPresets.map((preset) => ({ name: @@ -667,22 +672,52 @@ export default component$(() => { Browse + +
+

+ {t('color.savePreset@@Save Preset')} +

+ + + +
+ + +
+
+
@@ -730,7 +765,7 @@ export default component$(() => {
+ +
+

+ {t('color.savePreset@@Save Preset')} +

+ + + +
+ + +
+
+
diff --git a/src/routes/resources/rgb/presets/index.tsx b/src/routes/resources/rgb/presets/index.tsx index a2391f66..bee483cc 100644 --- a/src/routes/resources/rgb/presets/index.tsx +++ b/src/routes/resources/rgb/presets/index.tsx @@ -25,7 +25,7 @@ export default component$(() => { }); const filteredPresets = (store.showSaved && store.savedPresets.length > 0 ? store.savedPresets : presets).filter((preset) => - preset.name!.toLowerCase().includes(store.searchTerm.toLowerCase()), + (preset.name ?? 'Untitled').toLowerCase().includes(store.searchTerm.toLowerCase()), ); return ( @@ -81,7 +81,7 @@ export default component$(() => { }}> {(() => { const colors = sortColors(preset.colors ?? presets[0].colors).map((color) => ({ rgb: convertToRGB(color.hex), pos: color.pos })); - if (colors.length < 2) return preset.name; + if (colors.length < 2) return preset.name ?? 'Untitled'; const gradient = new Gradient(colors, Math.ceil((preset.name ?? 'Untitled').length)); @@ -97,10 +97,6 @@ export default component$(() => { }); })()} -

- Birdflop - Birdflop -