Skip to content

Commit

Permalink
💄 Show alt text under images (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
foysalit authored Apr 15, 2024
1 parent cad7429 commit 2eaa6a3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions components/common/posts/PostsFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
DocumentMagnifyingGlassIcon,
ExclamationCircleIcon,
LanguageIcon,
InformationCircleIcon,
} from '@heroicons/react/24/outline'
import { LoadMore } from '../LoadMore'
import { isRepost } from '@/lib/types'
Expand Down Expand Up @@ -206,6 +207,16 @@ function PostContent({
const getImageSizeClass = (imageCount: number) =>
imageCount < 3 ? 'w-32 h-32' : 'w-20 h-20'

function ImageAltText({ alt }: { alt: string }) {
if (!alt) return null
return (
<p className="leading-2 text-gray-400 text-xs leading-3 mt-1">
<InformationCircleIcon className="w-4 h-4 inline mr-1" />
{alt}
</p>
)
}

// @TODO record embeds
function PostEmbeds({ item }: { item: AppBskyFeedDefs.FeedViewPost }) {
const embed = AppBskyEmbedRecordWithMedia.isView(item.post.embed)
Expand Down Expand Up @@ -240,6 +251,7 @@ function PostEmbeds({ item }: { item: AppBskyFeedDefs.FeedViewPost }) {
src={image.thumb}
alt={image.alt}
/>
<ImageAltText alt={image.alt} />
</a>
))}
</div>
Expand Down

0 comments on commit 2eaa6a3

Please sign in to comment.