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

feat: update backpagehero component with additional "actions" to the CTA button (#207) #208

Merged
merged 1 commit into from
Sep 27, 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from "@emotion/styled";
import { Stack } from "@mui/material";
import { TABLET } from "../../../../../../theme/common/breakpoints";
import { mediaTabletUp } from "../../../../../../styles/common/mixins/breakpoints";
import { CallToActionButton as CTAButton } from "../../../../../common/Button/components/CallToActionButton/callToActionButton";

export const BackPageHeroHeadline = styled.div`
Expand All @@ -10,7 +10,7 @@ export const BackPageHeroHeadline = styled.div`
grid-column: 1 / -1; // Title and breadcrumbs consume full width of available grid.
}

${({ theme }) => theme.breakpoints.up(TABLET)} {
${mediaTabletUp} {
display: flex;
flex: 1;
gap: 88px;
Expand All @@ -29,7 +29,7 @@ export const CallToActionButton = styled(CTAButton)`
align-self: center;
justify-self: flex-start;

${({ theme }) => theme.breakpoints.up(TABLET)} {
${mediaTabletUp} {
justify-self: flex-end;
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { SubTitle } from "./components/SubTitle/subTitle";
*/

export interface BackPageHeroProps {
actions?: ReactNode;
breadcrumbs?: Breadcrumb[];
callToAction?: CallToAction;
children?: ReactNode;
Expand All @@ -25,13 +26,15 @@ export interface BackPageHeroProps {
}

export const BackPageHero = ({
actions,
breadcrumbs,
callToAction,
children,
subTitle,
title,
}: BackPageHeroProps): JSX.Element => {
const HeroHeadline = callToAction ? BackPageHeroHeadline : Fragment;
const HeroHeadline =
actions || callToAction ? BackPageHeroHeadline : Fragment;
return (
<>
{(breadcrumbs || title) && (
Expand All @@ -41,6 +44,7 @@ export const BackPageHero = ({
{title && <Title title={title} />}
<SubTitle subTitle={subTitle} />
</HeroHeader>
{actions}
{callToAction && <CallToActionButton callToAction={callToAction} />}
</HeroHeadline>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import styled from "@emotion/styled";
import { mediaTabletUp } from "../../../../../../../../styles/common/mixins/breakpoints";

export const BackPageHeroActions = styled.div`
align-items: center;
align-self: center;
display: flex;
gap: 16px;
justify-self: flex-start;

${mediaTabletUp} {
justify-self: flex-end;
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { ReactNode } from "react";
import { BackPageHeroActions } from "./actions.styles";

export interface ActionsProps {
children: ReactNode;
className?: string;
}

export const Actions = ({ children, className }: ActionsProps): JSX.Element => {
return (
<BackPageHeroActions className={className}>{children}</BackPageHeroActions>
);
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ButtonProps } from "@mui/material";
import NLink from "next/link";
import React, { ElementType } from "react";
import {
Expand All @@ -15,13 +16,15 @@ export interface CallToAction {

export interface CallToActionButtonProps {
ButtonElType?: ElementType;
buttonProps?: Partial<ButtonProps>;
callToAction: CallToAction;
className?: string;
disabled?: boolean;
}

export const CallToActionButton = ({
ButtonElType: Button = ButtonPrimary,
buttonProps,
callToAction,
className,
disabled = false,
Expand All @@ -36,6 +39,7 @@ export const CallToActionButton = ({
href="passHref"
rel={REL_ATTRIBUTE.NO_OPENER}
target={target || ANCHOR_TARGET.SELF}
{...buttonProps}
>
{label}
</Button>
Expand All @@ -47,6 +51,7 @@ export const CallToActionButton = ({
href={url}
rel={REL_ATTRIBUTE.NO_OPENER_NO_REFERRER}
target={target || ANCHOR_TARGET.BLANK}
{...buttonProps}
>
{label}
</Button>
Expand Down
Loading