Skip to content

Commit

Permalink
feat: add sponsors to announcements banners (#259)
Browse files Browse the repository at this point in the history
* feat: add sponsors to Masthead

* refactor: move Masthead to common folder

* feat: add sponsors to Web3Auth banner

* refactor: component for Masthead footer

* refactor: move dup code to getImageSource

* bump version
  • Loading branch information
DiogoSoaress authored Dec 20, 2023
1 parent 59f6fdf commit a94bfaa
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 64 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "safe-homepage",
"homepage": "https://github.com/safe-global/safe-homepage",
"version": "1.3.7",
"version": "1.3.8",
"scripts": {
"build": "next build && next export",
"lint": "tsc && next lint",
Expand Down
Binary file added public/images/Wallet/Coincover-logo.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 added public/images/Wallet/Sygnum-logo.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 added public/images/Wallet/buoy-logo.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 removed public/images/Wallet/buoy.png
Binary file not shown.
13 changes: 13 additions & 0 deletions public/images/Wallet/web3auth-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 0 additions & 51 deletions src/components/Core/Masthead/styles.module.css

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,57 @@ import layoutCss from '@/components/common/styles.module.css'
import css from './styles.module.css'
import type { BaseBlock } from '@/components/Home/types'
import ButtonsWrapper from '@/components/common/ButtonsWrapper'
import { getImageSource, type ImageObj } from '@/lib/getImageSource'

type FooterProps = {
text: string
logos: [
{
src: string
alt: string
},
]
}

const Footer = ({ logos, text }: FooterProps) => {
if (!logos) return null

return (
<div className={css.footer}>
{text ? (
<Typography variant="caption" mr="-14px">
{text}
</Typography>
) : null}
{logos.map((logo, index) => {
return <img src={logo.src} alt={logo.alt} key={index} />
})}
</div>
)
}

export const Masthead = ({
title,
buttons,
caption,
image,
footer,
backgroundImage,
}: BaseBlock & {
image: {
sm: string
md: string
alt: string
}
backgroundImage: { sm: string; md: string }
image: ImageObj
backgroundImage: ImageObj
footer: FooterProps
}): ReactElement => {
const isSmallScreen = useMediaQuery('(max-width:900px)')

const bgImage = isSmallScreen ? backgroundImage.sm : backgroundImage.md
const imageSrc = image ? (isSmallScreen ? image.sm : image.md) : undefined
const bgImage = getImageSource(isSmallScreen, backgroundImage)
const imageSrc = getImageSource(isSmallScreen, image)

return (
<Container className={layoutCss.containerShort} id="masthead">
<div className={css.container} style={{ backgroundImage: `url(${bgImage})` }}>
<Grid container spacing={{ xs: '90px', sm: '30px' }} justifyContent="space-between">
{!backgroundImage ? <div className={css.spot} /> : null}
<Grid container spacing={{ xs: '90px', sm: '30px' }} justifyContent="space-between" position="relative">
<Grid item xs={12} md={7}>
<Chip
label={
Expand All @@ -51,6 +78,7 @@ export const Masthead = ({
</Grid>
) : null}
</Grid>
<Footer {...footer} />
</div>
</Container>
)
Expand Down
94 changes: 94 additions & 0 deletions src/components/common/Masthead/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
.container {
text-align: center;
background-color: var(--mui-palette-secondary-background);
border-radius: 32px;
padding: 24px 24px 80px;
justify-content: space-between;
margin-bottom: 40px;
background-position: right;
background-size: cover;
position: relative;
}

.spot {
position: absolute;
left: 50%;
transform: translateX(-50%);
bottom: 50px;
width: 50%;
height: 300px;
background-image: radial-gradient(rgba(18, 255, 128, 0.8), rgba(18, 19, 18, 1) 100%);
filter: blur(50px);
}

.text {
margin-bottom: 16px;
}

.button {
color: var(--mui-palette-secondary-main);
}

.chip {
border-color: var(--mui-palette-text-primary);
width: fit-content;
}

.linkButton {
display: none;
}

.footer {
position: absolute;
bottom: 24px;
left: 50%;
transform: translateX(-50%);
display: flex;
align-items: center;
flex-direction: row;
gap: 24px;
width: max-content;
}

.tagline {
color: var(--mui-palette-primary-light);
text-transform: uppercase;
}

@media (min-width: 900px) {
.container {
padding: 90px 104px;
border-bottom: 80px;
text-align: left;
}

.spot {
width: 300px;
right: 10%;
top: 50%;
left: unset;
transform: translateY(-50%);
}

.linkButton {
display: block;
}

.image {
display: flex;
align-items: center;
width: 300px;
}

.footer {
left: unset;
transform: unset;
}
}

@media (min-width: 1440px) {
.container {
margin-left: -104px;
margin-right: -104px;
}
}
11 changes: 10 additions & 1 deletion src/content/core.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@
"sm": "/images/Core/safeauth-bg-sm.png",
"md": "/images/Core/safeauth-bg-md.png"
},
"component": "Core/Masthead"
"footer": {
"logos": [
{
"src": "/images/Wallet/web3auth-logo.svg",
"alt": "web3auth logo"
}
],
"text": "Powered by"
},
"component": "common/Masthead"
},
{
"title": "Our Account Abstraction stack",
Expand Down
20 changes: 18 additions & 2 deletions src/content/wallet.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,24 @@
"variant": "link"
}
],
"backgroundImage": "/images/Wallet/buoy.png",
"component": "common/BannerCta"
"image": {
"sm": "/images/Wallet/buoy-logo.png",
"md": "/images/Wallet/buoy-logo.png",
"alt": "Recovery buoy logo"
},
"footer": {
"logos": [
{
"src": "/images/Wallet/Sygnum-logo.png",
"alt": "Sygnum logo"
},
{
"src": "/images/Wallet/Coincover-logo.png",
"alt": "Coincover logo"
}
]
},
"component": "common/Masthead"
},
{
"variant": "3-columns",
Expand Down
38 changes: 38 additions & 0 deletions src/lib/__test__/getImageSource.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { type ImageObj, getImageSource } from '@/lib/getImageSource'

describe('getImageSource', () => {
it('should return small image URL when image object exists and isSmall is true', () => {
const imageObj: ImageObj = {
sm: 'small-image.jpg',
md: 'medium-image.jpg',
alt: 'Small Image',
}
const isSmall = true

const result = getImageSource(isSmall, imageObj)

expect(result).toBe('small-image.jpg')
})

it('should return medium image URL when image object exists and isSmall is false', () => {
const imageObj: ImageObj = {
sm: 'small-image.jpg',
md: 'medium-image.jpg',
alt: 'Medium Image',
}
const isSmall = false

const result = getImageSource(isSmall, imageObj)

expect(result).toBe('medium-image.jpg')
})

it('should return undefined when image object does not exist', () => {
const imageObj = undefined
const isSmall = true

const result = getImageSource(isSmall, imageObj)

expect(result).toBeUndefined()
})
})
15 changes: 15 additions & 0 deletions src/lib/getImageSource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export type ImageObj = {
sm: string
md: string
alt?: string
}

/**
* Get the source URL for an image based on its size and screen condition.
* @param {ImageObj} imageObj - The object containing URLs for different image sizes.
* @param {boolean} isSmall - A flag indicating whether the small image shall be used.
* @returns {string|undefined} - The source URL for the image, or undefined.
*/
export function getImageSource(isSmall: boolean, imageObj?: ImageObj) {
return imageObj ? (isSmall ? imageObj.sm : imageObj.md) : undefined
}

0 comments on commit a94bfaa

Please sign in to comment.