diff options
author | かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> | 2024-12-12 01:31:29 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-11 16:31:29 +0000 |
commit | de15f8e2d3264b9ffb18c3a089612ef604eb87b8 (patch) | |
tree | ae5419e798d55b978596ca7a396fdb395d2cf4fc /bskyembed/src/screens | |
parent | 48c5341644935b103fa81c91b23391f7b7c8a572 (diff) | |
download | voidsky-de15f8e2d3264b9ffb18c3a089612ef604eb87b8.tar.zst |
feat(embed): Add support for dark mode (#6912)
* feat(embed): Support dark mode (wip) * finishing up the implementation * fix tailwind color selector * tweak design * refactor: unify types * fix * fix english grammar * refactor: unify types * tweak design * remove the customization part
Diffstat (limited to 'bskyembed/src/screens')
-rw-r--r-- | bskyembed/src/screens/landing.tsx | 31 | ||||
-rw-r--r-- | bskyembed/src/screens/post.tsx | 9 |
2 files changed, 24 insertions, 16 deletions
diff --git a/bskyembed/src/screens/landing.tsx b/bskyembed/src/screens/landing.tsx index a9e08cd3f..a3448e90a 100644 --- a/bskyembed/src/screens/landing.tsx +++ b/bskyembed/src/screens/landing.tsx @@ -6,6 +6,7 @@ import {useEffect, useMemo, useRef, useState} from 'preact/hooks' import arrowBottom from '../../assets/arrowBottom_stroke2_corner0_rounded.svg' import logo from '../../assets/logo.svg' +import {initColorMode} from '../color-mode' import {Container} from '../components/container' import {Link} from '../components/link' import {Post} from '../components/post' @@ -21,6 +22,8 @@ export const EMBED_SCRIPT = `${EMBED_SERVICE}/static/embed.js` const root = document.getElementById('app') if (!root) throw new Error('No root element') +initColorMode() + const agent = new BskyAgent({ service: 'https://public.api.bsky.app', }) @@ -108,7 +111,7 @@ function LandingPage() { }, [uri]) return ( - <main className="w-full min-h-screen flex flex-col items-center gap-8 py-14 px-4 md:pt-32"> + <main className="w-full min-h-screen flex flex-col items-center gap-8 py-14 px-4 md:pt-32 dark:bg-dimmedBgDarken dark:text-slate-200"> <Link href="https://bsky.social/about" className="transition-transform hover:scale-110"> @@ -121,20 +124,22 @@ function LandingPage() { type="text" value={uri} onInput={e => setUri(e.currentTarget.value)} - className="border rounded-lg py-3 w-full max-w-[600px] px-4" + className="border rounded-lg py-3 w-full max-w-[600px] px-4 dark:bg-dimmedBg dark:border-slate-500" placeholder={DEFAULT_POST} /> - <img src={arrowBottom} className="w-6" /> + <img src={arrowBottom} className="w-6 dark:invert" /> {loading ? ( - <Skeleton /> + <div className="w-full max-w-[600px]"> + <Skeleton /> + </div> ) : ( <div className="w-full max-w-[600px] gap-8 flex flex-col"> {!error && thread && uri && <Snippet thread={thread} />} {!error && thread && <Post thread={thread} key={thread.post.uri} />} {error && ( - <div className="w-full border border-red-500 bg-red-50 px-4 py-3 rounded-lg"> + <div className="w-full border border-red-500 bg-red-500/10 px-4 py-3 rounded-lg"> <p className="text-red-500 text-center">{error}</p> </div> )} @@ -149,15 +154,15 @@ function Skeleton() { <Container> <div className="flex-1 flex-col flex gap-2 pb-8"> <div className="flex gap-2.5 items-center"> - <div className="w-10 h-10 overflow-hidden rounded-full bg-neutral-100 shrink-0 animate-pulse" /> + <div className="w-10 h-10 overflow-hidden rounded-full bg-neutral-100 dark:bg-slate-700 shrink-0 animate-pulse" /> <div className="flex-1"> - <div className="bg-neutral-100 animate-pulse w-64 h-4 rounded" /> - <div className="bg-neutral-100 animate-pulse w-32 h-3 mt-1 rounded" /> + <div className="bg-neutral-100 dark:bg-slate-700 animate-pulse w-64 h-4 rounded" /> + <div className="bg-neutral-100 dark:bg-slate-700 animate-pulse w-32 h-3 mt-1 rounded" /> </div> </div> - <div className="w-full h-4 mt-2 bg-neutral-100 rounded animate-pulse" /> - <div className="w-5/6 h-4 bg-neutral-100 rounded animate-pulse" /> - <div className="w-3/4 h-4 bg-neutral-100 rounded animate-pulse" /> + <div className="w-full h-4 mt-2 bg-neutral-100 dark:bg-slate-700 rounded animate-pulse" /> + <div className="w-5/6 h-4 bg-neutral-100 dark:bg-slate-700 rounded animate-pulse" /> + <div className="w-3/4 h-4 bg-neutral-100 dark:bg-slate-700 rounded animate-pulse" /> </div> </Container> ) @@ -220,7 +225,7 @@ function Snippet({thread}: {thread: AppBskyFeedDefs.ThreadViewPost}) { ref={ref} type="text" value={snippet} - className="border rounded-lg py-3 w-full px-4" + className="border rounded-lg py-3 w-full px-4 dark:bg-dimmedBg dark:border-slate-500" readOnly autoFocus onFocus={() => { @@ -228,7 +233,7 @@ function Snippet({thread}: {thread: AppBskyFeedDefs.ThreadViewPost}) { }} /> <button - className="rounded-lg bg-brand text-white color-white py-3 px-4 whitespace-nowrap min-w-28" + className="rounded-lg bg-brand text-white py-3 px-4 whitespace-nowrap min-w-28" onClick={() => { ref.current?.focus() ref.current?.select() diff --git a/bskyembed/src/screens/post.tsx b/bskyembed/src/screens/post.tsx index 6ccf10a79..1764442b7 100644 --- a/bskyembed/src/screens/post.tsx +++ b/bskyembed/src/screens/post.tsx @@ -4,6 +4,7 @@ import {AppBskyFeedDefs, AtpAgent} from '@atproto/api' import {h, render} from 'preact' import logo from '../../assets/logo.svg' +import {initColorMode} from '../color-mode' import {Container} from '../components/container' import {Link} from '../components/link' import {Post} from '../components/post' @@ -21,6 +22,8 @@ if (!uri) { throw new Error('No uri in path') } +initColorMode() + agent .getPostThread({ uri, @@ -55,13 +58,13 @@ function PwiOptOut({thread}: {thread: AppBskyFeedDefs.ThreadViewPost}) { <img src={logo} className="h-6" /> </Link> <div className="w-full py-12 gap-4 flex flex-col items-center"> - <p className="max-w-80 text-center w-full text-textLight"> + <p className="max-w-80 text-center w-full text-textLight dark:text-textDimmed"> The author of this post has requested their posts not be displayed on external sites. </p> <Link href={href} - className="max-w-80 rounded-lg bg-brand text-white color-white text-center py-1 px-4 w-full mx-auto"> + className="max-w-80 rounded-lg bg-brand text-white text-center py-1 px-4 w-full mx-auto"> View on Bluesky </Link> </div> @@ -77,7 +80,7 @@ function ErrorMessage() { className="transition-transform hover:scale-110 absolute top-4 right-4"> <img src={logo} className="h-6" /> </Link> - <p className="my-16 text-center w-full text-textLight"> + <p className="my-16 text-center w-full text-textLight dark:text-textDimmed"> Post not found, it may have been deleted. </p> </Container> |