-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
feat: create banner for online conf #3312
Merged
asyncapi-bot
merged 10 commits into
asyncapi:master
from
thulieblack:thulieblack-patch-2
Oct 27, 2024
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5a40ab8
Update banners.ts
thulieblack 17b8b0d
correct-text
thulieblack 7639112
correct-text
thulieblack b50bdb7
updated banners conditional render
akshatnema ff8a6bd
Merge branch 'master' into thulieblack-patch-2
thulieblack bef2e01
updated banners conditional render
akshatnema 7ad3ff6
fixed AnnouncementHero component
akshatnema db4009b
fixed AnnouncementHero component
akshatnema e408168
Merge branch 'master' into thulieblack-patch-2
anshgoyalevil 63e6a9c
Merge branch 'master' into thulieblack-patch-2
akshatnema File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import React, { useEffect, useMemo, useState } from 'react'; | ||
|
||
import ArrowLeft from '../icons/ArrowLeft'; | ||
import ArrowRight from '../icons/ArrowRight'; | ||
import Container from '../layout/Container'; | ||
import Banner from './AnnouncementBanner'; | ||
import { banners } from './banners'; | ||
import { banners, shouldShowBanner } from './banners'; | ||
|
||
interface IAnnouncementHeroProps { | ||
className?: string; | ||
|
@@ -21,8 +21,8 @@ interface IAnnouncementHeroProps { | |
export default function AnnouncementHero({ className = '', small = false }: IAnnouncementHeroProps) { | ||
const [activeIndex, setActiveIndex] = useState(0); | ||
|
||
const len = banners.length; | ||
const numberOfVisibleBanners = banners.filter((banner) => banner.show).length; | ||
const visibleBanners = useMemo(() => banners.filter((banner) => shouldShowBanner(banner.cfpDeadline)), [banners]); | ||
const numberOfVisibleBanners = visibleBanners.length; | ||
|
||
const goToPrevious = () => { | ||
setActiveIndex((prevIndex) => (prevIndex === 0 ? len - 1 : prevIndex - 1)); | ||
|
@@ -62,31 +62,28 @@ export default function AnnouncementHero({ className = '', small = false }: IAnn | |
)} | ||
<div className='relative flex w-5/6 flex-col items-center justify-center gap-2'> | ||
<div className='relative flex min-h-72 w-full items-center justify-center overflow-hidden lg:h-[17rem] lg:w-[38rem]'> | ||
{banners.map( | ||
(banner, index) => | ||
banner.show && ( | ||
<Banner | ||
key={index} | ||
title={banner.title} | ||
dateLocation={banner.dateLocation} | ||
cfaText={banner.cfaText} | ||
eventName={banner.eventName} | ||
cfpDeadline={banner.cfpDeadline} | ||
link={banner.link} | ||
city={banner.city} | ||
activeBanner={index === activeIndex % len} | ||
className={className} | ||
small={small} | ||
/> | ||
) | ||
)} | ||
{visibleBanners.map((banner, index) => ( | ||
<Banner | ||
key={index} | ||
title={banner.title} | ||
dateLocation={banner.dateLocation} | ||
cfaText={banner.cfaText} | ||
eventName={banner.eventName} | ||
cfpDeadline={banner.cfpDeadline} | ||
link={banner.link} | ||
city={banner.city} | ||
activeBanner={index === activeIndex % len} | ||
className={className} | ||
small={small} | ||
/> | ||
))} | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix index mismatch between visible banners and navigation. There are several issues with the current implementation:
Here's how to fix these issues: - const len = banners.length;
+ const len = visibleBanners.length;
// ... rest of the code ...
<div className='m-auto flex justify-center'>
- {banners.map((banner, index) => (
+ {visibleBanners.map((banner, index) => (
<div
key={index}
className={`mx-1 size-2 cursor-pointer rounded-full ${
activeIndex % len === index ? 'bg-primary-500' : 'bg-gray-300'
}`}
onClick={() => goToIndex(index)}
/>
))}
</div>
|
||
<div className='m-auto flex justify-center'> | ||
{banners.map((banner, index) => ( | ||
{visibleBanners.map((banner, index) => ( | ||
<div | ||
key={index} | ||
className={`mx-1 size-2 cursor-pointer rounded-full ${ | ||
activeIndex % len === index ? 'bg-primary-500' : 'bg-gray-300' | ||
activeIndex % numberOfVisibleBanners === index ? 'bg-primary-500' : 'bg-gray-300' | ||
}`} | ||
onClick={() => goToIndex(index)} | ||
/> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix undefined variable in activeBanner prop calculation.
The
len
variable is undefined. This should usenumberOfVisibleBanners
instead to correctly calculate the active banner index.📝 Committable suggestion