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

fix: compose Hero into NewsHero #591

Merged
merged 1 commit into from
Oct 22, 2024
Merged
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
19 changes: 3 additions & 16 deletions components/templates/NewsPage/NewsHero.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import PropTypes from "prop-types";
import imageShape from "@/shapes/image";
import * as Styled from "./styles";
import Hero from "@/components/molecules/Hero";

export default function NewsHero({
data,
Expand All @@ -17,27 +18,13 @@ export default function NewsHero({
if (caption)
return (
<Styled.HeroFigure className={className}>
<Styled.HeroImageContainer data-cy="hero">
<Styled.HeroImage
image={{ ...imageData, priority: true }}
$focalPointX={focalPointX || 50}
$focalPointY={focalPointY || 50}
/>
</Styled.HeroImageContainer>
<Hero {...{ className, data, focalPointX, focalPointY }} />
<Styled.HeroFigCaption dangerouslySetInnerHTML={{ __html: caption }} />
</Styled.HeroFigure>
);

return (
<Styled.Hero className={className} data-cy="hero">
<Styled.HeroImage
role="presentation"
image={{ ...imageData, priority: true }}
$focalPointX={focalPointX || 50}
$focalPointY={focalPointY || 50}
/>
{children}
</Styled.Hero>
<Hero {...{ className, data, focalPointX, focalPointY }}>{children}</Hero>
);
}

Expand Down
28 changes: 1 addition & 27 deletions components/templates/NewsPage/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@ import styled from "styled-components";
import {
containerWide,
containerFullBleed,
fluidScale,
ptToEm,
respond,
tokens,
} from "@/styles/globalStyles";
import { aHidden } from "@/styles/mixins/appearance";
import { IconComposer, Image, token } from "@rubin-epo/epo-react-lib";

export const Hero = styled.div`
${containerFullBleed("CONTAINER_FULL")}
position: relative;
height: var(--Hero-height, ${fluidScale("540px", "400px")});
overflow: auto;
`;
import { IconComposer, token } from "@rubin-epo/epo-react-lib";

export const HeroFigure = styled.figure`
${containerFullBleed("CONTAINER_FULL")}
Expand All @@ -27,13 +19,6 @@ export const HeroFigure = styled.figure`
}
`;

export const HeroImageContainer = styled.div`
${containerFullBleed("CONTAINER_FULL")}
position: relative;
height: var(--Hero-height, ${fluidScale("540px", "400px")});
overflow: auto;
`;

export const HeroFigCaption = styled.figcaption`
${aHidden}
`;
Expand All @@ -45,17 +30,6 @@ export const HeroCaption = styled.div`
line-height: 1.428;
`;

export const HeroImage = styled(Image)`
--Hero-object-position: ${({ $focalPointX, $focalPointY }) =>
`${$focalPointX}% ${$focalPointY}%;`}

width: 100%;
/* stylelint-disable declaration-no-important */
height: 100% !important;
object-fit: cover;
object-position: var(--Hero-object-position, center);
`;

export const Article = styled.article`
z-index: 1;
margin-top: var(--Hero-caption-offset);
Expand Down