diff options
| author | Xe Iaso <me@xeiaso.net> | 2023-04-02 16:01:51 -0400 |
|---|---|---|
| committer | Xe Iaso <me@xeiaso.net> | 2023-04-02 16:01:51 -0400 |
| commit | 7b691babb3312d9c2284416f03b50de34638bc58 (patch) | |
| tree | fb23e724991fa356896b2edb014ea82295aa3eec /src | |
| parent | e8347815f7b1bfce0d5db600cdffc60ba1b3531a (diff) | |
| download | xesite-7b691babb3312d9c2284416f03b50de34638bc58.tar.xz xesite-7b691babb3312d9c2284416f03b50de34638bc58.zip | |
use the useState monad
Signed-off-by: Xe Iaso <me@xeiaso.net>
Diffstat (limited to 'src')
| -rw-r--r-- | src/frontend/components/MastodonShareButton.tsx | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/frontend/components/MastodonShareButton.tsx b/src/frontend/components/MastodonShareButton.tsx index 2de0173..21b6d4d 100644 --- a/src/frontend/components/MastodonShareButton.tsx +++ b/src/frontend/components/MastodonShareButton.tsx @@ -2,6 +2,7 @@ // @jsxRuntime automatic import { u } from "xeact"; +import { useState } from "@/state.js"; export interface MastodonShareButtonProps { title: string; @@ -27,18 +28,8 @@ ${series ? "#" + series + " " : ""}${ tags ? tags.map((x) => "#" + x).join(" ") : "" } @cadey@pony.social`; - const instanceBox = ( - <input - type="text" - placeholder="https://pony.social" - value={defaultURL} - /> - ); - const tootBox = ( - <textarea rows={6} cols={40}> - {tootTemplate} - </textarea> - ); + const [getURL, setURL] = useState(defaultURL); + const [getToot, setToot] = useState(tootTemplate); return ( <div> @@ -46,20 +37,31 @@ ${series ? "#" + series + " " : ""}${ <summary>Share on Mastodon</summary> <span>{"Instance URL (https://mastodon.example)"}</span> <br /> - {instanceBox} + <input + type="text" + placeholder="https://pony.social" + value={defaultURL} + oninput={(e) => setURL(e.target.value)} + /> <br /> - {tootBox} + <textarea + rows={6} + cols={40} + oninput={(e) => setToot(e.target.value)} + > + {getToot()} + </textarea> <br /> <button onclick={() => { - let instanceURL = instanceBox.value; + let instanceURL = getURL(); if (!instanceURL.startsWith("https://")) { instanceURL = `https://${instanceURL}`; } localStorage["mastodon_instance"] = instanceURL; - const text = tootBox.value; + const text = getToot(); const mastodonURL = u(instanceURL + "/share", { text, visibility: "public", |
