Skip to content

Commit

Permalink
feat: clean up FeedCard component by removing unnecessary whitespace …
Browse files Browse the repository at this point in the history
…and ensuring conditional rendering of images
  • Loading branch information
BumpyClock committed Sep 23, 2024
1 parent f4581f9 commit 5230187
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions src/components/FeedCard/FeedCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import DropShadow from "../DropShadow/DropShadow.js";
import ReaderView from "../ReaderView/ReaderView.js";
import SlRelativeTime from "@shoelace-style/shoelace/dist/react/relative-time";


const useImageLoader = (src) => {
const [isLoaded, setIsLoaded] = useState(false);
const [isError, setIsError] = useState(false);
Expand Down Expand Up @@ -79,8 +78,6 @@ const FeedCard = ({ item, apiUrl }) => {
return 16;
}, [mouseDown, hover]);



if (!isLoaded) {
return <FeedCardLoader id={item.id} />;
}
Expand Down Expand Up @@ -120,7 +117,9 @@ const FeedCard = ({ item, apiUrl }) => {
>
<div className="card-bg">
<div className="noise"></div>
<img src={loadedImage.src} alt={item.siteTitle} />
{loadedImage && (
<img src={loadedImage.src} alt={item.siteTitle} />
)}
</div>
{!isLoaded && (
<SlAnimation name="pulse" duration={250} repeat>
Expand All @@ -130,19 +129,15 @@ const FeedCard = ({ item, apiUrl }) => {

{loadedImage && !isError && (
<>
<motion.div
layoutId={`image-${item.id}`}


>
<div className="image-container">
<img
src={loadedImage.src}
alt={item.siteTitle}
style={{ width: "100%", height: "100%" }}
/>
</div></motion.div>

<motion.div layoutId={`image-${item.id}`}>
<div className="image-container">
<img
src={loadedImage.src}
alt={item.siteTitle}
style={{ width: "100%", height: "100%" }}
/>
</div>
</motion.div>
</>
)}

Expand Down Expand Up @@ -182,4 +177,4 @@ const FeedCard = ({ item, apiUrl }) => {
);
};

export default React.memo(FeedCard);
export default React.memo(FeedCard);

0 comments on commit 5230187

Please sign in to comment.