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

[do not merge] Showcase text over carousel image #156

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
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
60 changes: 59 additions & 1 deletion overrides/home/carousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ export function DesktopCarousel () {
classNames="imagetransition"
>
<div className="carousel--height width-full position-absolute left-0 top-0 shadow-1">
{ (itemInProgress.imageOverlayText1 || itemInProgress.imageOverlayText2) && (
<div
className="position-absolute text-lower-left"
style={{
bottom: '10px',
left: '10px',
}}
>
{itemInProgress.imageOverlayText1 && <TitleOverImage1 text={itemInProgress.imageOverlayText1} fontSize="1.2rem" />}
{itemInProgress.imageOverlayText2 && <TitleOverImage2 text={itemInProgress.imageOverlayText2} fontSize="1.2rem" />}
</div>
)}
<img className="carousel--content-image" src={itemInProgress.image} alt={itemInProgress.imageAlt} />
</div>
</CSSTransition>
Expand Down Expand Up @@ -88,7 +100,19 @@ function TabletCarousel() {
<Grid row className="margin-top-2">
{CarouselItems.map((item) => {
return <Grid col={12} key={item.title} className="margin-bottom-4">
<div>
<div className='position-relative'>
{ (item.imageOverlayText1 || item.imageOverlayText2) && (
<div
className="position-absolute text-lower-left"
style={{
bottom: '10px',
left: '10px',
}}
>
{item.imageOverlayText1 && <TitleOverImage1 text={item.imageOverlayText1} fontSize="3vw" />}
{item.imageOverlayText2 && <TitleOverImage2 text={item.imageOverlayText2} fontSize="3vw" />}
</div>
)}
<img className="carousel--content-image" src={item.image} />
</div>
<h3 className="margin-top-1">{item.title}</h3>
Expand All @@ -99,6 +123,40 @@ function TabletCarousel() {
</GridContainer>
}

export function TitleOverImage1({ text, fontSize }) {
return (
<span
style={{
display: 'block',
color: '#fff',
background: 'rgba(0, 0, 0, 0.5)',
padding: '10px',
borderRadius: '4px',
fontSize: fontSize || '1.2rem',
fontWeight: 'bold',
}}
>
{text}
</span>
);
}

export function TitleOverImage2({ text, fontSize }) {
return (
<span
style={{
display: 'block',
color: '#fff',
background: 'rgba(0, 0, 0, 0.5)',
padding: '10px',
fontSize: fontSize || '1.2rem',
fontWeight: 'bold',
}}
>
{text}
</span>
);
}

export default function Carousel() {
const { isMediumUp } = useMediaQuery();
Expand Down
8 changes: 6 additions & 2 deletions overrides/home/carousel/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ export default [
title: 'U.S. Greenhouse Gas Center',
description: "The U.S. Greenhouse Gas Center (US GHG Center) is a multi-agency effort consolidating greenhouse gas information from observations and models.",
image: new URL('../media/ghgc-v2.jpg', import.meta.url).href,
imageAlt: 'Earth with Greenhouse Gas Emissions shaded in red'
imageAlt: 'Earth with Greenhouse Gas Emissions shaded in red',
imageOverlayText1: 'U.S. Greenhouse Gas Center',
imageOverlayText2: 'Example second line text'
},
{
link: 'https://earth.gov/sealevel',
title: 'Global Sea Level Change Portal',
description: 'The Global Sea Level Change Portal is an international collaboration that offers essential information on current and projected sea level rise to inform coastal communities across the globe.',
image: new URL('../media/global_slr_v2.jpg', import.meta.url).href,
imageAlt: 'Satellite image of coastline'
imageAlt: 'Satellite image of coastline',
imageOverlayText1: 'Global Sea Level Change Portal',
imageOverlayText2: 'Example second line text'
},
{
link: 'https://earth.gov/sealevel/us/',
Expand Down
Loading