-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the assets for the 2025 sponsors and updated the sponsor section on the landing page. Different assets are now used depending on the theme.
- Loading branch information
Showing
14 changed files
with
156 additions
and
26 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
frontend/src/assets/LandingPage/Sponsors/Dark/Gold/janestreet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+27.4 KB
frontend/src/assets/LandingPage/Sponsors/Dark/Platinum/thetradedesk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.6 KB
frontend/src/assets/LandingPage/Sponsors/Light/Platinum/thetradedesk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
144 changes: 125 additions & 19 deletions
144
frontend/src/pages/LandingPage/SponsorSection/SponsorSection.tsx
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,25 +1,131 @@ | ||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import PageContainer from 'styles/PageContainer'; | ||
import janestreetLogo from 'assets/LandingPage/janestreet.png'; | ||
import tiktokLogo from 'assets/LandingPage/tiktok.svg'; | ||
import { RootState } from 'config/store'; | ||
import S from './styles'; | ||
|
||
type LogoProps = { src: string; href: string }; | ||
|
||
const Logo = ({ src, href }: LogoProps) => ( | ||
<a href={href} target="_blank" rel="noopener noreferrer"> | ||
<S.LogoImg src={src} /> | ||
</a> | ||
); | ||
|
||
const SponsorSection = () => ( | ||
<PageContainer> | ||
<S.SponsorsText>Our sponsors</S.SponsorsText> | ||
<S.LogosWrapper> | ||
<Logo href="https://www.janestreet.com" src={janestreetLogo} /> | ||
<Logo href="https://www.tiktok.com" src={tiktokLogo} /> | ||
</S.LogosWrapper> | ||
</PageContainer> | ||
); | ||
type LogoProps = { | ||
src: string; | ||
href?: string; | ||
size: 'platinum' | 'gold' | 'silver'; | ||
}; | ||
|
||
type LogoModule = { default: string }; | ||
type Files = Record<string, () => Promise<LogoModule>>; | ||
|
||
const URLS = { | ||
janestreet: 'https://www.janestreet.com', | ||
imc: 'https://www.imc.com/ap/', | ||
citadel: 'https://www.citadel.com', | ||
thetradedesk: 'https://www.thetradedesk.com/', | ||
safetyculture: 'https://www.safetyculture.com', | ||
arista: 'https://www.arista.com' | ||
} as const; | ||
|
||
const LOGO_SIZES = { | ||
platinum: '350px', | ||
gold: '250px', | ||
silver: '150px' | ||
} as const; | ||
|
||
const Logo = ({ src, href, size }: LogoProps) => { | ||
const image = <S.LogoImg src={src} size={LOGO_SIZES[size]} />; | ||
|
||
return href ? ( | ||
<a href={href} target="_blank" rel="noopener noreferrer"> | ||
{image} | ||
</a> | ||
) : ( | ||
image | ||
); | ||
}; | ||
|
||
// Necessary to do it this way as vite does not support dynamic imports with globs | ||
// ie needs to be a string literal | ||
const sponsorAssets = { | ||
dark: { | ||
platinum: import.meta.glob( | ||
'/src/assets/LandingPage/Sponsors/Dark/Platinum/*.(png|jpg|jpeg|svg)' | ||
) as Files, | ||
gold: import.meta.glob( | ||
'/src/assets/LandingPage/Sponsors/Dark/Gold/*.(png|jpg|jpeg|svg)' | ||
) as Files, | ||
silver: import.meta.glob( | ||
'/src/assets/LandingPage/Sponsors/Dark/Silver/*.(png|jpg|jpeg|svg)' | ||
) as Files | ||
}, | ||
light: { | ||
platinum: import.meta.glob( | ||
'/src/assets/LandingPage/Sponsors/Light/Platinum/*.(png|jpg|jpeg|svg)' | ||
) as Files, | ||
gold: import.meta.glob( | ||
'/src/assets/LandingPage/Sponsors/Light/Gold/*.(png|jpg|jpeg|svg)' | ||
) as Files, | ||
silver: import.meta.glob( | ||
'/src/assets/LandingPage/Sponsors/Light/Silver/*.(png|jpg|jpeg|svg)' | ||
) as Files | ||
} | ||
}; | ||
|
||
const SponsorSection = () => { | ||
const { theme } = useSelector((state: RootState) => state.settings); | ||
const [logos, setLogos] = React.useState<Record<'platinum' | 'gold' | 'silver', string[]>>({ | ||
platinum: [], | ||
gold: [], | ||
silver: [] | ||
}); | ||
|
||
React.useEffect(() => { | ||
const loadLogos = async () => { | ||
const { platinum, gold, silver } = sponsorAssets[theme]; | ||
|
||
const loadTier = async (files: Files) => { | ||
const paths = Object.keys(files); | ||
const modules = await Promise.all(paths.map((path) => files[path]())); | ||
return paths.map((path, index) => ({ | ||
path, | ||
url: modules[index].default | ||
})); | ||
}; | ||
|
||
const [platinumLogos, goldLogos, silverLogos] = await Promise.all([ | ||
loadTier(platinum), | ||
loadTier(gold), | ||
loadTier(silver) | ||
]); | ||
|
||
setLogos({ | ||
platinum: platinumLogos.map((p) => p.url), | ||
gold: goldLogos.map((g) => g.url), | ||
silver: silverLogos.map((s) => s.url) | ||
}); | ||
}; | ||
|
||
loadLogos(); | ||
}, [theme]); | ||
|
||
const renderLogos = (logoUrls: string[], tier: LogoProps['size']) => | ||
logoUrls.map((url) => { | ||
const fileName = url.split('/').pop()?.split('.')[0] || ''; | ||
return ( | ||
<Logo | ||
key={`${tier}-${url}`} | ||
src={url} | ||
href={URLS[fileName as keyof typeof URLS]} | ||
size={tier} | ||
/> | ||
); | ||
}); | ||
|
||
return ( | ||
<PageContainer> | ||
<S.SponsorsText>Our sponsors</S.SponsorsText> | ||
<S.LogosWrapper> | ||
<S.TierWrapper>{renderLogos(logos.platinum, 'platinum')}</S.TierWrapper> | ||
<S.TierWrapper>{renderLogos(logos.gold, 'gold')}</S.TierWrapper> | ||
</S.LogosWrapper> | ||
</PageContainer> | ||
); | ||
}; | ||
|
||
export default SponsorSection; |
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