From 5246455aca00fdf15baa5d3bd465be18b5495aba Mon Sep 17 00:00:00 2001 From: alexsparkes Date: Tue, 3 Feb 2026 21:31:50 +0000 Subject: [PATCH] feat(ItemSettingsModal): enhance settings UI with improved input styling and dynamic field handling --- src/features/background/api/photoPackAPI.js | 5 +- .../components/Modals/ItemSettingsModal.jsx | 39 ++++++++++----- .../components/Modals/ItemSettingsModal.scss | 47 +++++++++++++++++++ 3 files changed, 78 insertions(+), 13 deletions(-) diff --git a/src/features/background/api/photoPackAPI.js b/src/features/background/api/photoPackAPI.js index 7decf2cb..111ffddb 100644 --- a/src/features/background/api/photoPackAPI.js +++ b/src/features/background/api/photoPackAPI.js @@ -44,13 +44,14 @@ export async function fetchFromMUE(packId, settings) { */ export async function fetchFromUnsplash(packId, settings) { const { collections } = settings; + const trimmedCollections = collections?.trim(); const params = new URLSearchParams({ quality: 'high', }); - if (collections) { - params.append('collections', collections); + if (trimmedCollections) { + params.append('collections', trimmedCollections); } try { diff --git a/src/features/marketplace/components/Modals/ItemSettingsModal.jsx b/src/features/marketplace/components/Modals/ItemSettingsModal.jsx index facf95cb..8bfe1e87 100644 --- a/src/features/marketplace/components/Modals/ItemSettingsModal.jsx +++ b/src/features/marketplace/components/Modals/ItemSettingsModal.jsx @@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from 'react'; import Modal from 'react-modal'; import variables from 'config/variables'; import EventBus from 'utils/eventbus'; -import { Dropdown, Text, Switch, Slider, ChipSelect } from 'components/Form/Settings'; +import { Dropdown, Switch, Slider, ChipSelect } from 'components/Form/Settings'; import { Button } from 'components/Elements'; import { refreshAPIPackCache } from 'features/background/api/photoPackAPI'; import { MdRefresh, MdWarning, MdClose, MdCheckCircle, MdCancel } from 'react-icons/md'; @@ -78,11 +78,24 @@ const ItemSettingsModal = ({ pack, isOpen, onClose, isEnabled }) => { validateSettings(); }, [settings, validateSettings, pack.settings_schema]); - const handleSettingChange = (key, value, secure = false) => { + const handleSettingChange = async (key, value, secure = false) => { const processedValue = secure ? btoa(value) : value; const newSettings = { ...settings, [key]: processedValue }; setSettings(newSettings); localStorage.setItem(`photopack_settings_${pack.id}`, JSON.stringify(newSettings)); + + // Clear cache and immediately refresh when settings change + const apiPackCache = JSON.parse(localStorage.getItem('api_pack_cache') || '{}'); + if (apiPackCache[pack.id]) { + delete apiPackCache[pack.id]; + localStorage.setItem('api_pack_cache', JSON.stringify(apiPackCache)); + } + + // Trigger immediate refresh with new settings + setIsRefreshing(true); + await refreshAPIPackCache(pack.id); + setIsRefreshing(false); + EventBus.emit('refresh', 'background'); }; const handleManualRefresh = async () => { @@ -130,15 +143,19 @@ const ItemSettingsModal = ({ pack, isOpen, onClose, isEnabled }) => { case 'text': return ( - handleSettingChange(field.key, e.target.value, field.secure)} - subtitle={field.help_text} - /> +
+ + handleSettingChange(field.key, e.target.value, field.secure)} + placeholder={field.placeholder || ''} + className="itemSettings-field-input" + /> + {field.help_text && ( +

{field.help_text}

+ )} +
); case 'switch': diff --git a/src/features/marketplace/components/Modals/ItemSettingsModal.scss b/src/features/marketplace/components/Modals/ItemSettingsModal.scss index 74cf3371..49bfaa16 100644 --- a/src/features/marketplace/components/Modals/ItemSettingsModal.scss +++ b/src/features/marketplace/components/Modals/ItemSettingsModal.scss @@ -1,3 +1,5 @@ +@use 'scss/variables' as *; + .itemSettingsModal { max-width: 600px; width: 90%; @@ -149,6 +151,51 @@ width: 100%; } +.itemSettings-field-group { + display: flex; + flex-direction: column; + gap: 8px; +} + +.itemSettings-field-label { + font-size: 0.75rem; + text-transform: uppercase; + letter-spacing: 0.5px; + color: var(--subtitle-color, rgba(255, 255, 255, 0.5)); + font-weight: 600; +} + +.itemSettings-field-description { + font-size: 0.7rem; + color: var(--subtitle-color, rgba(255, 255, 255, 0.4)); + margin: 0; + line-height: 1.4; +} + +.itemSettings-field-input { + height: 56px; + padding: 0 16px; + border: 1px solid rgba(255, 255, 255, 0.1); + border-radius: 8px; + transition: all 0.2s; + font-size: 1rem; + + @include themed() { + background: t($modal-sidebar); + border: 1px solid t($modal-sidebarActive); + border-radius: t($borderRadius); + color: t($color); + &:hover, + &:focus { + border-color: t($color); + } + + &::placeholder { + color: t($subColor); + } + } +} + .itemSettings-actions { display: flex; justify-content: flex-end;