diff --git a/src/web/pages/gallery/config.tsx b/src/web/pages/gallery/config.tsx index 9a39f84..ae72898 100644 --- a/src/web/pages/gallery/config.tsx +++ b/src/web/pages/gallery/config.tsx @@ -1,6 +1,7 @@ import { useI18n } from '@solid-primitives/i18n' import { css, styled } from 'decorock' -import { Component, For } from 'solid-js' +import { Component, For, onMount } from 'solid-js' +import { createStore } from 'solid-js/store' import { Button } from '~/web/components/ui/button' import { IconButton } from '~/web/components/ui/icon-button' @@ -16,56 +17,52 @@ const Container = styled.div` text-align: left; ` -const Paths: Component = () => { - return ( -
- - {(path, i) => ( -
- setConfig('gallery/dirs', i(), e.currentTarget.value)} - /> - { - setConfig('gallery/dirs', (dirs) => dirs.filter((_, i2) => i2 !== i())) - }} - > - - -
- )} -
-
- { - setConfig('gallery/dirs', (paths) => ['', ...paths]) - }} - > - - -
- ) -} - export const Config: Component = () => { const [t] = useI18n() + const [dirs, setDirs] = createStore([]) + + onMount(() => setDirs(config['gallery/dirs'])) return ( - + +
+ + {(path, i) => ( +
+ setDirs(i(), e.currentTarget.value)} /> + { + setDirs((dirs) => dirs.filter((_, i2) => i2 !== i())) + }} + > + + +
+ )} +
+
+ { + setDirs((paths) => [...paths, '']) + }} + > + + +