Skip to content

Commit

Permalink
[F] Callout layouts when no image
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake Mason authored and blnkt committed Mar 26, 2024
1 parent 73f1f57 commit fe8ccd7
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 14 deletions.
8 changes: 6 additions & 2 deletions components/content-blocks/Callout/CalloutEntry/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function CalloutEntry({ callout }) {

return (
<Styled.Section $bgColor={backgroundColor} $width="full" $overlay={false}>
<Styled.Inner href={url} aria-labelledby={titleId}>
<Styled.Inner $isImage={!!calloutImage}>
{calloutImage && (
<Styled.ImageWrapper>
<Image role="presentation" ratio="4:3" image={calloutImage} />
Expand All @@ -88,7 +88,11 @@ export default function CalloutEntry({ callout }) {
/>
)}
<Styled.Footer>
<Styled.FooterButton className={`c-buttonish c-buttonish--inert`}>
<Styled.FooterButton
href={url}
aria-labelledby={titleId}
className={`c-buttonish c-buttonish--inert`}
>
{t("read-more")}
</Styled.FooterButton>
</Styled.Footer>
Expand Down
34 changes: 24 additions & 10 deletions components/content-blocks/Callout/CalloutEntry/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ export const Section = styled(CalloutSection)`
position: relative;
`;

export const Inner = styled(MixedLink)`
export const Inner = styled.div`
${containerRegular()}
position: ${(p) => p.$position};
display: grid;
grid-template-areas:
"image title"
Expand All @@ -50,6 +49,20 @@ export const Inner = styled(MixedLink)`
text-decoration: none;
transition: color 0.2s, background-color 0.2s;
${({ $isImage }) =>
!$isImage &&
`
grid-template-areas:
"image image"
"title title"
"subtitle subtitle"
"text text"
"footer footer";
gap: 0;
justify-content: center;
text-align: center;
`}
${respond(
`
grid-template-areas:
Expand Down Expand Up @@ -174,18 +187,19 @@ export const Footer = styled.div`
grid-area: footer;
grid-template-columns: max-content 1fr;
place-items: end;
margin-top: 15px;
margin: 15px 0 0;
${({ $isImage }) =>
!$isImage &&
`
margin: 15px auto 0;
grid-template-columns: 1fr;
`}
${respond(`grid-template-columns: 1fr;`)}
`;

export const FooterButton = styled.div`
${Inner}:hover &,
${Inner}:focus-visible & {
outline: 3px solid var(--button-border-color);
outline-offset: 1px;
}
export const FooterButton = styled(MixedLink)`
${respond(
`
display: block;
Expand Down
1 change: 1 addition & 0 deletions components/content-blocks/Callout/CalloutMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function CalloutMain({ callout }) {
<Wrapper
{...wrapperProps}
height={dynamicComponent === "alertStream" ? "slim" : ""}
isImage={!!calloutImage}
>
<Header>
<h2>{header}</h2>
Expand Down
7 changes: 6 additions & 1 deletion components/content-blocks/Callout/CalloutTwoTone.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ export default function CalloutTwoTone({ callout }) {

return (
<>
<Wrapper backgroundColor={backgroundColor} order="image" stack="top">
<Wrapper
backgroundColor={backgroundColor}
order="image"
stack="top"
isImage={!!image?.[0]}
>
<Header>
<h2>{header}</h2>
{text && (
Expand Down
10 changes: 9 additions & 1 deletion components/content-blocks/Callout/Wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ export default function CalloutWrapper({
ratio = "50",
stack,
width = "full",
isImage,
}) {
return (
<Section $bgColor={backgroundColor} $width={width} $overlay={overlay}>
<Inner $order={order} $ratio={ratio} $height={height} $stack={stack}>
<Inner
$isImage={isImage}
$order={order}
$ratio={ratio}
$height={height}
$stack={stack}
>
{children}
</Inner>
</Section>
Expand All @@ -31,4 +38,5 @@ CalloutWrapper.propTypes = {
ratio: PropTypes.string,
stack: PropTypes.string,
width: PropTypes.string,
isImage: PropTypes.bool,
};
10 changes: 10 additions & 0 deletions components/content-blocks/Callout/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ export const Inner = styled.div`
padding-top: ${fluidScale("50px", "30px")};
padding-bottom: ${fluidScale("50px", "40px")};
${(p) =>
!p.$isImage &&
`
grid-template:
"text" auto / 100%;
gap: ${gap};
justify-content: center;
text-align: center;
`}
${respond(
`
grid-template:
Expand Down

0 comments on commit fe8ccd7

Please sign in to comment.