-
Notifications
You must be signed in to change notification settings - Fork 1
Trustlab: Showcase block #1181
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
base: main
Are you sure you want to change the base?
Trustlab: Showcase block #1181
Changes from all commits
b6583e4
a977d51
38d2228
2607bba
fcbe3e9
31634f4
417730d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
import { Section } from "@commons-ui/core"; | ||
import { Figure, Link } from "@commons-ui/next"; | ||
import { LexicalRichText } from "@commons-ui/payload"; | ||
import { Box, Button } from "@mui/material"; | ||
import React from "react"; | ||
|
||
function ShowCase({ | ||
direction = "rtl", | ||
images, | ||
title, | ||
description, | ||
label, | ||
href, | ||
}) { | ||
if (!images || images.length < 4) { | ||
return null; | ||
} | ||
const [image1, image2, image3, image4] = images; | ||
return ( | ||
<Section | ||
sx={{ | ||
maxWidth: { md: "100%", xs: "100%" }, | ||
bgcolor: "common.black", | ||
color: "common.white", | ||
py: 8, | ||
}} | ||
fixed={false} | ||
> | ||
<Box | ||
Comment on lines
+20
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my comment here. |
||
sx={(theme) => ({ | ||
display: "flex", | ||
flexDirection: { | ||
xs: "column", | ||
md: direction === "ltr" ? "row" : "row-reverse", | ||
}, | ||
justifyContent: "flex-end", | ||
width: "100%", | ||
color: "white", | ||
overflow: "hidden", | ||
maxWidth: theme.contentWidths.values, | ||
m: "0 auto", | ||
gap: 2, | ||
})} | ||
> | ||
<Box | ||
sx={{ | ||
position: "relative", | ||
height: { sm: "600px", xs: "360px" }, | ||
width: { xs: "390px", sm: "572px" }, | ||
maxWidth: "572px", | ||
margin: "0 auto", | ||
}} | ||
> | ||
<Figure | ||
ImageProps={{ | ||
src: image1.image.src, | ||
alt: image1.image.alt || "Showcase Image 1", | ||
}} | ||
sx={{ | ||
display: { | ||
sm: "block", | ||
}, | ||
height: { sm: "253px", xs: "153px" }, | ||
width: { sm: "203px", xs: 121 }, | ||
position: "absolute", | ||
top: 0, | ||
left: 80, | ||
}} | ||
/> | ||
<Figure | ||
ImageProps={{ | ||
src: image2.image.src, | ||
alt: image2.image.alt || "Showcase Image 2", | ||
}} | ||
sx={{ | ||
display: { | ||
sm: "block", | ||
}, | ||
height: { sm: "253px", xs: "157px" }, | ||
width: { sm: "260px", xs: "157px" }, | ||
position: "absolute", | ||
right: 20, | ||
bottom: { sm: "276px", xs: "unset" }, | ||
top: { sm: "unset", xs: "16px" }, | ||
}} | ||
/> | ||
<Figure | ||
ImageProps={{ | ||
src: image3.image.src, | ||
alt: image3.image.alt || "Showcase Image 3", | ||
}} | ||
sx={{ | ||
display: { | ||
sm: "block", | ||
}, | ||
height: { sm: "260px", xs: "157px" }, | ||
width: { sm: "260px", xs: "157px" }, | ||
position: "absolute", | ||
top: { sm: "276px", xs: "160px" }, | ||
left: { sm: 0, xs: "32px" }, | ||
}} | ||
/> | ||
|
||
<Figure | ||
ImageProps={{ | ||
src: image4.image.src, | ||
alt: image4.image.alt || "Showcase Image 4", | ||
}} | ||
sx={{ | ||
display: { | ||
sm: "block", | ||
}, | ||
height: { sm: "260px", xs: "157px" }, | ||
width: { sm: "200px", xs: "121px" }, | ||
position: "absolute", | ||
bottom: { xs: "unset", sm: "0" }, | ||
top: { xs: "176px", sm: "unset" }, | ||
left: { sm: "276px", xs: "200px" }, | ||
}} | ||
/> | ||
</Box> | ||
|
||
<Box | ||
flex={1} | ||
alignItems="center" | ||
justifyContent="center" | ||
display="flex" | ||
sx={{ | ||
px: { xs: 2.5, sm: 0 }, | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
flex: 1, | ||
bgcolor: "white", | ||
color: "black", | ||
p: { xs: 3, md: 6 }, | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "center", | ||
ml: { xs: 0, md: direction === "ltr" ? -10 : 0 }, | ||
mr: { xs: 0, md: direction === "ltr" ? 0 : -10 }, | ||
zIndex: 1, | ||
}} | ||
> | ||
<LexicalRichText | ||
elements={title} | ||
TypographyProps={{ | ||
variant: "display3", | ||
gutterBottom: true, | ||
}} | ||
/> | ||
<LexicalRichText | ||
elements={description} | ||
TypographyProps={{ | ||
sx: { mb: 3 }, | ||
}} | ||
/> | ||
<Button | ||
variant="contained" | ||
component={href ? Link : undefined} | ||
href={href} | ||
sx={{ | ||
bgcolor: "black", | ||
color: "white", | ||
fontWeight: "bold", | ||
px: 4, | ||
py: 1.5, | ||
"&:hover": { | ||
bgcolor: "#222", | ||
}, | ||
width: "fit-content", | ||
mt: 6, | ||
}} | ||
> | ||
{label} | ||
</Button> | ||
</Box> | ||
</Box> | ||
</Box> | ||
</Section> | ||
); | ||
} | ||
|
||
export default ShowCase; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<ShowCase /> renders unchanged 1`] = `<div />`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { createRender } from "@commons-ui/testing-library"; | ||
import React from "react"; | ||
|
||
import ShowCase from "./ShowCase"; | ||
|
||
import theme from "@/trustlab/theme"; | ||
|
||
const render = createRender({ theme }); | ||
|
||
const defaultProps = {}; | ||
|
||
describe("<ShowCase />", () => { | ||
it("renders unchanged", () => { | ||
const { container } = render(<ShowCase {...defaultProps} />); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ShowCase from "./ShowCase"; | ||
|
||
export default ShowCase; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { richText, image, link } from "@commons-ui/payload"; | ||
|
||
const ShowCase = { | ||
slug: "showcase", | ||
labels: { | ||
singular: "Showcase Block", | ||
plural: "Showcase Blocks", | ||
}, | ||
imageURL: "/images/cms/blocks/showcase.png", | ||
imageAltText: "Showcases images and content.", | ||
fields: [ | ||
richText({ | ||
name: "title", | ||
required: true, | ||
}), | ||
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are titles actually rich text? |
||
richText({ | ||
name: "description", | ||
required: true, | ||
admin: { | ||
description: "A brief description of the slide content.", | ||
}, | ||
}), | ||
{ | ||
name: "direction", | ||
type: "select", | ||
options: [ | ||
{ label: "Left to Right", value: "ltr" }, | ||
{ label: "Right to Left", value: "rtl" }, | ||
], | ||
defaultValue: "ltr", | ||
Comment on lines
+26
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
admin: { | ||
description: | ||
"Direction of images -> content card the showcase block. This is used to determine the layout of the showcase block.", | ||
}, | ||
}, | ||
link({ | ||
name: "action", | ||
label: "Action Link", | ||
required: true, | ||
}), | ||
{ | ||
name: "images", | ||
type: "array", | ||
label: { en: "Images" }, | ||
minRows: 4, | ||
maxRows: 4, | ||
fields: [ | ||
image({ | ||
overrides: { | ||
name: "image", | ||
required: true, | ||
admin: { | ||
description: "Image to display in the showcase block.", | ||
}, | ||
}, | ||
}), | ||
], | ||
}, | ||
], | ||
}; | ||
|
||
export default ShowCase; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is Showcase (one word) component... The goal isn't to showcase the images and content. I think it's more of a call to action i.e. calling attention to the incubator or security course on academy.AFRICA.