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

Create banner component #77

Merged
merged 4 commits into from
Nov 4, 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
62 changes: 62 additions & 0 deletions src/components/Banner/Banner.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.pds-wds-react-banner {

color: var(--pds-primary-white);
padding: 10px 0px;
text-align: left;

span.title {
white-space: nowrap;
}

a {

display: flex;
direction: column;
gap: 4px;
align-items: center;
color: var(--pds-primary-white);
border-radius: 8px;
white-space: nowrap;

&:hover {
text-decoration: underline;
text-decoration-style: dashed;
text-underline-offset: .3em;
}

span.icon {

display: flex;
justify-content: center;
align-items: center;
background-color: var(--pds-primary-white);
border-radius: 8px;
height: 16px;
width: 16px;

&.info {
color: var(--pds-secondary-blue-s1);
}

&.alert {
color: var(--pds-secondary-red-s1);
}

& svg {
height: 10px;
width: 10px;
}

}

}

&.info {
background-color: var(--pds-secondary-blue-s1);
}

&.alert {
background-color: var(--pds-secondary-red-s1);
}

}
60 changes: 60 additions & 0 deletions src/components/Banner/Banner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from "react";
import {
Grid as MuiGrid,
Box as MuiBox,
Container as MuiContainer,
Stack as MuiStack
} from "@mui/material";
import {
IconArrowDiagonal,
IconArrowRight,
} from "../Icons";
import { Typography } from "../Typography";
import { Link } from "react-router-dom";

type Link = {
href:string;
title:string;
type:"internal" | "external";
}

export type BannerProps = {
link?:Link;
message:string;
title:string;
variant?:"info" | "alert"
}

export const Banner = (
{
link,
message,
title,
variant = "info"
}:BannerProps
) => {

return <React.Fragment>
<MuiBox className={'pds-wds-react-banner ' + variant}>
<MuiContainer maxWidth={"xl"}>
<MuiGrid container>
<MuiGrid xs={12} lg={8}>
<MuiStack direction={{xs: "column", sm: "row"}} gap={{xs: "8px", sm:"32px"}} alignItems={{xs: "flex-start", sm:"center"}} justifyContent={"flex-start"}>
<MuiStack direction={{xs: "column", sm: "row"}} gap={"8px"} alignItems={{xs: "flex-start", sm: "center"}} justifyContent={"flex-start"}>
<Typography variant="h5" weight="semibold" component="span" className="title">{title}</Typography>
<Typography variant="h6" weight="regular" component="span">{message}</Typography>
</MuiStack>
{ link &&
<Link to={link.href}>
<Typography variant="h6" weight="semibold" component={"span"}>{link.title}</Typography>
<span className={"icon " + variant}>{link.type ? <IconArrowRight /> : <IconArrowDiagonal />}</span>
</Link>
}
</MuiStack>
</MuiGrid>
</MuiGrid>
</MuiContainer>
</MuiBox>
</React.Fragment>

}
1 change: 1 addition & 0 deletions src/components/Banner/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Banner";
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "./styles/styles.scss";
export * from "./components/Banner";
export * from "./components/Breadcrumbs";
export * from "./components/Button";
export * from "./components/Card";
Expand Down
1 change: 1 addition & 0 deletions src/styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@import "_animations";

// Components
@import "../components/Banner/Banner.scss";
@import "../components/Button/Button.scss";
@import "../components/Chip/Chip.scss";
@import "../components/HelloWorld/HelloWorld.scss";
Expand Down
Loading