Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fixed: The respective image should appear in the Recent&Previous Broadcast Cards #1095

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 43 additions & 22 deletions frontend/src/pages/Broadcast/Component/Carousel/Carousel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function Carousel(props) {
toastStatus: false,
toastType: "",
toastMessage: "",
})
});
const [open, setOpen] = useState(false);
const [dataa, setDataa] = useState([]);
const [isLoaded, setLoaded] = useState(false);
Expand Down Expand Up @@ -62,23 +62,31 @@ export function Carousel(props) {
const cardImageArrayLight = dataa.map((item, i) => {
const style = {
height: "13em",
backgroundSize: "cover",
backgroundSize: "23.9em",
//backgroundSize: "cover", // Cover the entire area
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove if not required

margin: "0 auto",
backgroundPosition: "center",
backgroundRepeat: "no-repeat",
backgroundBlendMode: "screen",
clipPath: "polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%)",
backgroundImage: `linear-gradient(45deg,rgba(255, 0, 90, 1) 0%,rgba(10, 24, 61, 1) 90%),url(${item.link})`,
// clipPath: "polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%)",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this?

backgroundImage: `linear-gradient(45deg,rgba(255, 0, 90, 1) 0%,rgba(10, 24, 61, 1) 90%),url(${item.imageUrl[0]})`,
};
return style;
});

const cardImageArrayDark = dataa.map((item, i) => {
const style = {
height: "13em",
backgroundSize: "cover",
backgroundSize: "23.9em",
//backgroundSize: "cover", // Cover the entire area
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove all commented code and i would prefer the image to cover the whole space instead of fixed height

margin: "0 auto",
backgroundPosition: "center",
backgroundRepeat: "no-repeat",
backgroundBlendMode: "screen",
clipPath: "polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%)",
// clipPath: "polygon(0 0, 100% 0, 100% 70%, 50% 100%, 0 70%)",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove, if not required

backgroundImage: `linear-gradient(45deg,
#4e4376 0%,
#2b5876 90%),url(${item.link})`,
#2b5876 90%),url(${item.imageUrl[0]})`,
};
return style;
});
Expand All @@ -88,12 +96,14 @@ export function Carousel(props) {
}, []);
const getData = async () => {
setLoaded(false);
const result = await boardcast(setToast,toast)
const approvedBroadcasts = result.filter(broadcast => broadcast.isApproved);
const result = await boardcast(setToast, toast);
const approvedBroadcasts = result.filter(
(broadcast) => broadcast.isApproved
);
setDataa(approvedBroadcasts);
setLoaded(true);
}
const handleCloseToast = (event,reason) => {
};
const handleCloseToast = (event, reason) => {
if (reason === "clickaway") {
return;
}
Expand All @@ -102,7 +112,7 @@ export function Carousel(props) {

const truncatedContent = (content, maxLength) => {
if (content.length > maxLength) {
return content.substring(0, maxLength) + '...';
return content.substring(0, maxLength) + "...";
}
return content;
};
Expand Down Expand Up @@ -146,27 +156,38 @@ export function Carousel(props) {
: `${style["slide-card-light"]} ${style["slide-card"]}`
}
onClick={() =>
handleOpen(item.content, item.title, item.imageUrl[0], item?.link)
handleOpen(
item.content,
item.title,
item.imageUrl[0],
item?.link
)
}
>
<div
style={dark ? cardImageArrayDark[i] : cardImageArrayLight[i]}
></div>

<h3 className={style["card-head"]}>{item.title}</h3>
<div className={style["card-text"]}
dangerouslySetInnerHTML={{__html: DOMPurify.sanitize(truncatedContent(item.content, 250)),}} />
<div
className={style["card-text"]}
dangerouslySetInnerHTML={{
__html: DOMPurify.sanitize(
truncatedContent(item.content, 170)
),
}}
/>
</div>
))}
</OwlCarousel>
{toast.toastStatus && (
<SimpleToast
open={toast.toastStatus}
message={toast.toastMessage}
handleCloseToast={handleCloseToast}
severity={toast.toastType}
/>
)}
<SimpleToast
open={toast.toastStatus}
message={toast.toastMessage}
handleCloseToast={handleCloseToast}
severity={toast.toastType}
/>
)}
</div>
</React.Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

.slide-card {
position: relative;
min-height: 31em;
height: 31em;
min-width: 20em;
border-radius: 15px;
margin: 30px;
Expand Down Expand Up @@ -65,7 +65,6 @@
.card-text {
line-height: 1.4;
padding: 1em;
padding-top: 2em;
text-align: justify;
text-justify: distribute-all-lines;
font-size: 14px;
Expand Down
Loading