From 84ac24e173451dbdf90947915fdcd2f321420edf Mon Sep 17 00:00:00 2001 From: olaven Date: Fri, 10 Mar 2023 13:57:50 +0100 Subject: [PATCH] Small UX improvements and basic mobile UI - cards have full width on mobile - input has full width on mobile - copy-on-click for the feed URLs --- components/Button.tsx | 12 ------------ components/Search.tsx | 8 ++++---- components/SeriesCard.tsx | 19 +++++++++++++------ fresh.gen.ts | 5 ++++- islands/CopyButton.tsx | 28 ++++++++++++++++++++++++++++ routes/index.tsx | 9 ++++++--- 6 files changed, 55 insertions(+), 26 deletions(-) delete mode 100644 components/Button.tsx create mode 100644 islands/CopyButton.tsx diff --git a/components/Button.tsx b/components/Button.tsx deleted file mode 100644 index 909d380..0000000 --- a/components/Button.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { JSX } from "preact"; -import { IS_BROWSER } from "$fresh/runtime.ts"; - -export function Button(props: JSX.HTMLAttributes) { - return ( - + + ); } diff --git a/components/SeriesCard.tsx b/components/SeriesCard.tsx index d74ce01..0d9701a 100644 --- a/components/SeriesCard.tsx +++ b/components/SeriesCard.tsx @@ -1,14 +1,21 @@ import { Serie } from "../lib/nrk.ts" +import CopyButton from "../islands/CopyButton.tsx"; export function SerieCard(props: { serie: Serie, origin: string }) { const feedUrl = new URL(`/api/feeds/${props.serie.seriesId}`, props.origin); + console.log(feedUrl.toString()) + return ( -
-

{props.serie.title}

-

{props.serie.description}

- -

Feed: {feedUrl.toString()}

-
+
+
+

{props.serie.title}

+

{props.serie.description}

+ + + Kopier URL + +
+
); } diff --git a/fresh.gen.ts b/fresh.gen.ts index 756abf4..2b0a226 100644 --- a/fresh.gen.ts +++ b/fresh.gen.ts @@ -6,6 +6,7 @@ import config from "./deno.json" assert { type: "json" }; import * as $0 from "./routes/api/feeds/[seriesId].ts"; import * as $1 from "./routes/api/search.ts"; import * as $2 from "./routes/index.tsx"; +import * as $$0 from "./islands/CopyButton.tsx"; const manifest = { routes: { @@ -13,7 +14,9 @@ const manifest = { "./routes/api/search.ts": $1, "./routes/index.tsx": $2, }, - islands: {}, + islands: { + "./islands/CopyButton.tsx": $$0, + }, baseUrl: import.meta.url, config, }; diff --git a/islands/CopyButton.tsx b/islands/CopyButton.tsx new file mode 100644 index 0000000..82a32da --- /dev/null +++ b/islands/CopyButton.tsx @@ -0,0 +1,28 @@ +import Preact from "preact"; +import { useState } from "preact/hooks" +import { IS_BROWSER } from "$fresh/runtime.ts"; + +export default function CopyButton(props: { textBefore: string, textAfter: string } & Preact.PropsWithChildren) { + + const [clicked, setClicked] = useState(false); + + const startReset = () => { + setTimeout(() => { + setClicked(false); + }, 2_000); + } + + return ( + + ); +} diff --git a/routes/index.tsx b/routes/index.tsx index 9e5c81c..4599bdc 100644 --- a/routes/index.tsx +++ b/routes/index.tsx @@ -20,7 +20,7 @@ export const handler: Handlers = { } return ctx.render({ query: query || "", result, origin: url.origin }); }, - }; +}; export default function Home({ data }: PageProps) { return ( @@ -29,10 +29,13 @@ export default function Home({ data }: PageProps) { NRSS
-

NRSS - NRK-podcast som RSS

+
+

NRSS

+

NRK-podcast som RSS

+
{data.result ? ( -
+
{data.result.map(result => )}
) : null}