Show the add feed form in the 'highlight' area (3dcfae9d)...
Dan Wolff
·
2023-01-22
·
via RSS Minima activity
Commit
3dcfae9d
authored
by
Dan Wolff
Browse files
| Original line number |
Diff line number |
Diff line |
|
|
import { FunctionComponent } from "preact";
|
|
|
import { useEffect } from "preact/hooks";
|
|
|
import { addFeed } from "../state/operations.ts";
|
|
|
import useAppState from "../state/useAppState.ts";
|
|
|
import Button from "./Button.tsx";
|
|
@@ -7,6 +6,7 @@ import TextField from "./TextField.tsx"; |
|
|
import { useSignal } from "@preact/signals";
|
|
|
import Alert from "../components/Alert.tsx";
|
|
|
import CopyButton from "./CopyButton.tsx";
|
|
|
import Typography from "./Typography.tsx";
|
|
|
|
|
|
async function rss() {
|
|
|
const div = document.createElement("div");
|
|
@@ -71,8 +71,11 @@ const AddFeedForm: FunctionComponent = function () { |
|
|
e.preventDefault();
|
|
|
dispatch(addFeed, url.value);
|
|
|
}}
|
|
|
class="border p-4 mb-4"
|
|
|
>
|
|
|
<Typography variant="h3" class="mb-2">
|
|
|
Add feed
|
|
|
</Typography>
|
|
|
|
|
|
<TextField
|
|
|
label="URL"
|
|
|
value={url.value}
|
|
@@ -90,7 +93,7 @@ const AddFeedForm: FunctionComponent = function () { |
|
|
{error instanceof Error ? error.message : JSON.stringify(error)}
|
|
|
</Alert>
|
|
|
)}
|
|
|
<hr class="my-4" />
|
|
|
<hr class="my-4 border-gray-500" />
|
|
|
<div class="flex gap-4">
|
|
|
<CopyButton
|
|
|
title="Copy script to find URL from a webpage"
|
|
|
| Original line number |
Diff line number |
Diff line |
|
@@ -28,12 +28,7 @@ const listDisplayOptions: { value: string; label: string }[] = [ |
|
|
];
|
|
|
|
|
|
const App: FunctionComponent = function () {
|
|
|
const {
|
|
|
addFeed: { show: showAddFeed },
|
|
|
listDisplay,
|
|
|
nextFeedRefresh,
|
|
|
dispatch,
|
|
|
} = useAppState();
|
|
|
const { listDisplay, nextFeedRefresh, dispatch } = useAppState();
|
|
|
|
|
|
useEffect(() => {
|
|
|
const nextRefresh = nextFeedRefresh.value;
|
|
@@ -72,7 +67,6 @@ const App: FunctionComponent = function () { |
|
|
|
|
|
<div class="h-0 flex-grow flex gap-4">
|
|
|
<div class="pl-4 pb-8 w-0 flex-1 max-w-[35rem] overflow-auto">
|
|
|
{showAddFeed.value && <AddFeedForm />}
|
|
|
<List />
|
|
|
</div>
|
|
|
<div class="pr-4 pb-8 w-0 flex-1 overflow-auto">
|
|
|
| Original line number |
Diff line number |
Diff line |
|
|
import { FunctionComponent } from "preact";
|
|
|
import useAppState from "../state/useAppState.ts";
|
|
|
import AddFeedForm from "./AddFeedForm.tsx";
|
|
|
import HighlightFeed from "./HighlightFeed.tsx";
|
|
|
import HighlightFeedEntry from "./HighlightFeedEntry.tsx";
|
|
|
|
|
@@ -12,6 +13,10 @@ const Highlight: FunctionComponent = function () { |
|
|
}
|
|
|
|
|
|
const { type, feed, feedItem } = item;
|
|
|
if (type === "addFeed") {
|
|
|
return <AddFeedForm />;
|
|
|
}
|
|
|
|
|
|
if (type === "feed") {
|
|
|
return <HighlightFeed feed={feed} />;
|
|
|
}
|
|
|
| Original line number |
Diff line number |
Diff line |
|
|
import { JSX } from "preact/jsx-runtime";
|
|
|
|
|
|
interface TypographyProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
|
|
variant: "h1";
|
|
|
variant: "h1" | "h3";
|
|
|
}
|
|
|
|
|
|
type Variant = TypographyProps["variant"];
|
|
|
|
|
|
const variantComponents = {
|
|
|
h1: "h1",
|
|
|
h3: "h3",
|
|
|
} as const;
|
|
|
|
|
|
const variantStyles: Record<Variant, string> = {
|
|
|
h1: "text-3xl",
|
|
|
h3: "text-lg",
|
|
|
};
|
|
|
|
|
|
export default function Typography({ variant, ...rest }: TypographyProps) {
|
|
|
| Original line number |
Diff line number |
Diff line |
|
@@ -33,11 +33,13 @@ type AsyncOperation< |
|
|
|
|
|
export type HighlightedItemId =
|
|
|
| { type: "feed"; feedId: number; feedItemId?: undefined }
|
|
|
| { type: "feedItem"; feedId: number; feedItemId: number };
|
|
|
| { type: "feedItem"; feedId: number; feedItemId: number }
|
|
|
| { type: "addFeed"; feedId?: undefined; feedItemId?: undefined };
|
|
|
|
|
|
type HighlightedItem =
|
|
|
| { type: "feed"; feed: Feed; feedItem?: undefined }
|
|
|
| { type: "feedItem"; feed: Feed; feedItem: FeedItem };
|
|
|
| { type: "feedItem"; feed: Feed; feedItem: FeedItem }
|
|
|
| { type: "addFeed"; feed?: undefined; feedItem?: undefined };
|
|
|
|
|
|
interface NextFeedRefresh {
|
|
|
feed: Feed;
|
|
@@ -52,7 +54,6 @@ export type ListDisplay = |
|
|
export default interface State {
|
|
|
feeds: Signal<Feed[]>;
|
|
|
addFeed: {
|
|
|
show: Signal<boolean>;
|
|
|
submission: Signal<AsyncOperation<{ url: string }>>;
|
|
|
};
|
|
|
removingFeed: Signal<AsyncOperation<{ feedId: number }>>;
|
|
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。