Skip to content

Commit

Permalink
add disabled state to embed
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzius committed Apr 9, 2024
1 parent b2e7bdc commit 3a7af58
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions bskyembed/src/embed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export function Embed({content}: {content: AppBskyFeedDefs.PostView['embed']}) {
)
if (pwiOptOut) {
return (
<GenericBox>
(Contains quoted post)
<br />
<br />
<GenericBox disabled>
<span className="block font-semibold text-xs mb-2 text-textLight">
(Contains quoted post)
</span>
The author of this post has requested their posts not be displayed
on external sites.
</GenericBox>
Expand Down Expand Up @@ -128,15 +128,15 @@ export function Embed({content}: {content: AppBskyFeedDefs.PostView['embed']}) {
// Case 3.5: Post not found
if (AppBskyEmbedRecord.isViewNotFound(record)) {
return (
<GenericBox>
<GenericBox disabled>
Quoted post not found - it may have been deleted
</GenericBox>
)
}

// Case 3.6: Post blocked
if (AppBskyEmbedRecord.isViewBlocked(record)) {
return <GenericBox>The quoted post is blocked</GenericBox>
return <GenericBox disabled>The quoted post is blocked</GenericBox>
}

throw new Error('Unknown embed type')
Expand Down Expand Up @@ -168,9 +168,18 @@ export function Embed({content}: {content: AppBskyFeedDefs.PostView['embed']}) {
}
}

function GenericBox({children}: {children: ComponentChildren}) {
function GenericBox({
children,
disabled,
}: {
children: ComponentChildren
disabled?: boolean
}) {
return (
<div className="w-full rounded-lg border py-2 px-3">
<div
className={`w-full rounded-lg border py-2 px-3 ${
disabled ? 'bg-neutral-50' : ''
}`}>
<p className="text-sm">{children}</p>
</div>
)
Expand Down

0 comments on commit 3a7af58

Please sign in to comment.