From d095e4b35a3e6a71c5b76e45b0a5254d6bc11c80 Mon Sep 17 00:00:00 2001 From: Athou Date: Fri, 5 May 2023 14:03:28 +0200 Subject: [PATCH] restore custom css setting (#1024) --- commafeed-client/index.html | 23 +++--- .../src/components/content/FeedEntries.tsx | 3 +- .../src/components/settings/CustomCss.tsx | 72 +++++++++++++++++++ commafeed-client/src/locales/ar/messages.po | 10 +++ commafeed-client/src/locales/ca/messages.po | 10 +++ commafeed-client/src/locales/cs/messages.po | 10 +++ commafeed-client/src/locales/cy/messages.po | 10 +++ commafeed-client/src/locales/da/messages.po | 10 +++ commafeed-client/src/locales/de/messages.po | 10 +++ commafeed-client/src/locales/en/messages.po | 10 +++ commafeed-client/src/locales/es/messages.po | 10 +++ commafeed-client/src/locales/fa/messages.po | 10 +++ commafeed-client/src/locales/fi/messages.po | 10 +++ commafeed-client/src/locales/fr/messages.po | 10 +++ commafeed-client/src/locales/gl/messages.po | 10 +++ commafeed-client/src/locales/hu/messages.po | 10 +++ commafeed-client/src/locales/id/messages.po | 10 +++ commafeed-client/src/locales/it/messages.po | 10 +++ commafeed-client/src/locales/ja/messages.po | 10 +++ commafeed-client/src/locales/ko/messages.po | 10 +++ commafeed-client/src/locales/ms/messages.po | 10 +++ commafeed-client/src/locales/nb/messages.po | 10 +++ commafeed-client/src/locales/nl/messages.po | 10 +++ commafeed-client/src/locales/nn/messages.po | 10 +++ commafeed-client/src/locales/pl/messages.po | 10 +++ commafeed-client/src/locales/pt/messages.po | 10 +++ commafeed-client/src/locales/ru/messages.po | 10 +++ commafeed-client/src/locales/sk/messages.po | 10 +++ commafeed-client/src/locales/sv/messages.po | 10 +++ commafeed-client/src/locales/tr/messages.po | 10 +++ commafeed-client/src/locales/zh/messages.po | 10 +++ commafeed-client/src/pages/app/AddPage.tsx | 6 +- commafeed-client/src/pages/app/Layout.tsx | 5 +- .../src/pages/app/SettingsPage.tsx | 14 +++- commafeed-client/vite.config.ts | 1 + 35 files changed, 384 insertions(+), 20 deletions(-) create mode 100644 commafeed-client/src/components/settings/CustomCss.tsx diff --git a/commafeed-client/index.html b/commafeed-client/index.html index 96e735df..b31c73fb 100644 --- a/commafeed-client/index.html +++ b/commafeed-client/index.html @@ -1,14 +1,15 @@ - - - - - - CommaFeed - - -
- - + + + + + + + CommaFeed + + +
+ + diff --git a/commafeed-client/src/components/content/FeedEntries.tsx b/commafeed-client/src/components/content/FeedEntries.tsx index c1157f8e..b4221eba 100644 --- a/commafeed-client/src/components/content/FeedEntries.tsx +++ b/commafeed-client/src/components/content/FeedEntries.tsx @@ -20,8 +20,8 @@ import { useMousetrap } from "hooks/useMousetrap" import throttle from "lodash/throttle" import { useEffect } from "react" import InfiniteScroll from "react-infinite-scroller" -import { FeedEntry } from "./FeedEntry" import { useViewMode } from "../../hooks/useViewMode" +import { FeedEntry } from "./FeedEntry" export function FeedEntries() { const source = useAppSelector(state => state.entries.source) @@ -239,6 +239,7 @@ export function FeedEntries() { if (!entries) return return ( dispatch(loadMoreEntries())} hasMore={hasMore} diff --git a/commafeed-client/src/components/settings/CustomCss.tsx b/commafeed-client/src/components/settings/CustomCss.tsx new file mode 100644 index 00000000..13097855 --- /dev/null +++ b/commafeed-client/src/components/settings/CustomCss.tsx @@ -0,0 +1,72 @@ +import { Trans } from "@lingui/macro" +import { Button, Group, Stack, Textarea } from "@mantine/core" +import { useForm } from "@mantine/form" +import { useEffect } from "react" +import { useAsyncCallback } from "react-async-hook" +import { TbDeviceFloppy } from "react-icons/tb" +import { client } from "../../app/client" +import { redirectToSelectedSource } from "../../app/slices/redirect" +import { useAppDispatch, useAppSelector } from "../../app/store" + +interface FormData { + customCss: string +} + +export function CustomCss() { + const settings = useAppSelector(state => state.user.settings) + const customCss = settings?.customCss + const dispatch = useAppDispatch() + + const form = useForm() + const { setValues } = form + + const saveCustomCss = useAsyncCallback(client.user.saveSettings, { + onSuccess: () => { + window.location.reload() + }, + }) + + useEffect(() => { + if (!customCss) return + setValues({ + customCss, + }) + }, [setValues, customCss]) + + return ( +
{ + if (!settings) return + saveCustomCss + .execute({ + ...settings, + customCss: data.customCss, + }) + .then(() => window.location.reload()) + })} + > + +