-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Banner image placeholder and fallback
- Loading branch information
Showing
9 changed files
with
142 additions
and
45 deletions.
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
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
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
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
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
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,29 +1,44 @@ | ||
import { makeStyles, Theme } from '@material-ui/core/styles'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import NoSsr from '@material-ui/core/NoSsr'; | ||
|
||
import DynamicImage from './DynamicImage'; | ||
import { imageServiceUrl } from '../config'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => ({ | ||
const useStyles = makeStyles((theme) => ({ | ||
dynamic: { | ||
height: '100vh', | ||
transition: 'opacity 1s ease-in-out', | ||
backgroundColor: theme.palette.primary.main, | ||
opacity: 0.9, | ||
[theme.breakpoints.down(1024)]: { | ||
height: 'calc(100vh - 64px)', | ||
}, | ||
[theme.breakpoints.down('xs')]: { | ||
height: 'calc(100vh - 56px)', | ||
}, | ||
backgroundSize: 'cover', | ||
backgroundPosition: '50% 0', | ||
backgroundImage: | ||
'linear-gradient(to right bottom, #51f2e4, #00cbea, #00a0ee, #0071e0, #0c39b7);', | ||
}, | ||
})); | ||
|
||
const BannerDynamicText = () => { | ||
// the placeholder and the main image must refer to the same source | ||
// we use this to request a consistent image vs a random one | ||
const index = Math.floor(Math.random() * 999); | ||
|
||
type BannerImageProps = { | ||
visible?: boolean; | ||
}; | ||
|
||
const BannerDynamicItems = ({ visible = true }: BannerImageProps) => { | ||
const classes = useStyles(); | ||
|
||
const imageURL = `${imageServiceUrl}/${index}/`; | ||
const placeholderURL = `${imageURL}?w=40`; | ||
|
||
return ( | ||
<div className={classes.dynamic}> | ||
<DynamicImage /> | ||
{/** prevent server-side rendering of the random banner images, which won't match with the client */} | ||
<NoSsr> | ||
<DynamicImage imageURL={imageURL} placeholderURL={placeholderURL} visible={visible} /> | ||
</NoSsr> | ||
</div> | ||
); | ||
}; | ||
|
||
export default BannerDynamicText; | ||
export default BannerDynamicItems; |
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
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
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