diff --git a/components/Button.tsx b/components/Button.tsx new file mode 100644 index 0000000..28d4ad6 --- /dev/null +++ b/components/Button.tsx @@ -0,0 +1,31 @@ +import { ComponentChildren, JSX } from "preact"; + +type ButtonProps = { + children: ComponentChildren; +} & JSX.HTMLAttributes; + +const className = "p-2 border(gray-100 2) hover:bg-gray-200 bg-blue-200 w-max font-medium"; + +export function Button(props: ButtonProps) { + const { children, className: additionalClass = "", ...buttonProps } = props; + + return ( + + ); +} + +type AnchorProps = { + children: ComponentChildren; +} & JSX.HTMLAttributes; + +export function ButtonLink(props: AnchorProps) { + const { children, className: additionalClass = "", ...linkProps } = props; + + return ( + + {children} + + ); +} diff --git a/components/SeriesCard.tsx b/components/SeriesCard.tsx index 479c6ee..44e64d7 100644 --- a/components/SeriesCard.tsx +++ b/components/SeriesCard.tsx @@ -1,5 +1,7 @@ import CopyButton from "../islands/CopyButton.tsx"; import { SearchResult } from "../lib/nrk/nrk.ts"; +import { ButtonLink } from "./Button.tsx"; +import IconPodcast from "https://deno.land/x/tabler_icons_tsx@0.0.5/tsx/brand-apple-podcast.tsx"; export default function SeriesCard(props: { serie: SearchResult; origin: string }) { const feedUrl = new URL(`/api/feeds/${props.serie.seriesId}`, props.origin); @@ -10,10 +12,17 @@ export default function SeriesCard(props: { serie: SearchResult; origin: string

{props.serie.title}

{props.serie.description}

- {feedUrl.toString()} - - Kopier URL - + + Åpne i din podkast-app + +
+ + Kopier URL + +
+            {feedUrl.toString()}
+          
+
); diff --git a/islands/CopyButton.tsx b/islands/CopyButton.tsx index 759c2ef..70a8e5a 100644 --- a/islands/CopyButton.tsx +++ b/islands/CopyButton.tsx @@ -1,14 +1,19 @@ -import Preact from "preact"; +import { ComponentChildren, JSX } from "preact"; import { useState } from "preact/hooks"; import { IS_BROWSER } from "$fresh/runtime.ts"; +import { Button } from "../components/Button.tsx"; +import IconCopy from "https://deno.land/x/tabler_icons_tsx@0.0.5/tsx/copy.tsx"; +// BUG: We have to use the GitHub URL until they resolve the issue: https://github.com/hashrock/tabler-icons-tsx/issues/16 +import IconCopyCheck from "https://raw.githubusercontent.com/hashrock/tabler-icons-tsx/df5d89c516984fde5c8ec8a382a1348f9fa1aee6/tsx/copy-check.tsx"; type Props = { - text: string; - children: Preact.ComponentChildren; + copyText: string; + children: ComponentChildren; disabled?: boolean; -}; +} & JSX.HTMLAttributes; -export default function CopyButton({ text, disabled = false, children }: Props) { +export default function CopyButton(props: Props) { + const { copyText, disabled = false, children, className = "", ...buttonProps } = props; const [clicked, setClicked] = useState(false); const startReset = () => { @@ -18,16 +23,27 @@ export default function CopyButton({ text, disabled = false, children }: Props) }; return ( - + {clicked + ? ( + <> + Kopiert! + + ) + : ( + <> + {children} + + )} + ); }