mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
show placeholders for loading img tags, this allows the entry to have its final height immediately
This commit is contained in:
@@ -1,19 +1,13 @@
|
||||
import { createStyles } from "@mantine/core"
|
||||
|
||||
const useStyles = createStyles(() => ({
|
||||
enclosureImage: {
|
||||
maxWidth: "100%",
|
||||
height: "auto",
|
||||
},
|
||||
}))
|
||||
import { TypographyStylesProvider } from "@mantine/core"
|
||||
import { ImageWithPlaceholderWhileLoading } from "components/ImageWithPlaceholderWhileLoading"
|
||||
|
||||
export function Enclosure(props: { enclosureType?: string; enclosureUrl?: string }) {
|
||||
const { classes } = useStyles()
|
||||
const hasVideo = props.enclosureType && props.enclosureType.indexOf("video") === 0
|
||||
const hasAudio = props.enclosureType && props.enclosureType.indexOf("audio") === 0
|
||||
const hasImage = props.enclosureType && props.enclosureType.indexOf("image") === 0
|
||||
|
||||
return (
|
||||
<>
|
||||
<TypographyStylesProvider>
|
||||
{hasVideo && (
|
||||
// eslint-disable-next-line jsx-a11y/media-has-caption
|
||||
<video controls>
|
||||
@@ -26,7 +20,7 @@ export function Enclosure(props: { enclosureType?: string; enclosureUrl?: string
|
||||
<source src={props.enclosureUrl} type={props.enclosureType} />
|
||||
</audio>
|
||||
)}
|
||||
{hasImage && <img src={props.enclosureUrl} alt="enclosure" className={classes.enclosureImage} />}
|
||||
</>
|
||||
{hasImage && <ImageWithPlaceholderWhileLoading src={props.enclosureUrl} alt="enclosure" />}
|
||||
</TypographyStylesProvider>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user