Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 6ee2c7d

Browse files
committed
Add FiftyFifty component and story
1 parent 863e5c6 commit 6ee2c7d

File tree

4 files changed

+126
-0
lines changed

4 files changed

+126
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import Button from '@/components/atoms/Button'
2+
import Container from '@/components/atoms/Container'
3+
import cn from 'classnames'
4+
import PropTypes from 'prop-types'
5+
import React from 'react'
6+
import styles from './FiftyFifty.module.css'
7+
8+
/**
9+
* Render the FiftyFifty component.
10+
*
11+
* @param {object} props FiftyFifty component props.
12+
* @param {string} props.body The body text.
13+
* @param {string} props.className The className.
14+
* @param {object} props.cta The cta object with text and url strings.
15+
* @param {object} props.image The image object with url and alt text.
16+
* @param {string} props.title The title.
17+
* @return {Element} The FiftyFifty component.
18+
*/
19+
export default function FiftyFifty({body, className, cta, image, title}) {
20+
return (
21+
<Container>
22+
<section className={cn(styles.fiftyFifty, className)}>
23+
<div className={styles.content}>
24+
<h1 className={styles.title}>{title}</h1>
25+
{body && <p className={styles.body}>{body}</p>}
26+
{cta && (
27+
<Button
28+
className={styles.button}
29+
url={cta.url ? cta.url : null}
30+
text={cta.text ? cta.text : null}
31+
type="primary"
32+
size="md"
33+
/>
34+
)}
35+
</div>
36+
<div className={styles.media}>
37+
{image && image.url && (
38+
<div className={styles.imageWrap}>
39+
<img src={image.url} alt={image.alt} />
40+
</div>
41+
)}
42+
</div>
43+
</section>
44+
</Container>
45+
)
46+
}
47+
48+
FiftyFifty.propTypes = {
49+
body: PropTypes.string,
50+
className: PropTypes.string,
51+
cta: PropTypes.shape({
52+
text: PropTypes.string,
53+
url: PropTypes.string
54+
}),
55+
image: PropTypes.shape({
56+
url: PropTypes.string,
57+
alt: PropTypes.string
58+
}),
59+
title: PropTypes.string
60+
}
61+
62+
FiftyFifty.defaultProps = {
63+
title: 'Here is a H2 headline in a bold font.',
64+
body:
65+
'Let me tell you a little story about how I went sledging in the Australian Alps, and got lost in the process. Oh what a riot that was, and I nearly lost...',
66+
cta: {
67+
text: 'Learn More',
68+
url: '#'
69+
},
70+
image: {
71+
url:
72+
'https://images.unsplash.com/photo-1611458181887-e4a588329222?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60',
73+
alt: 'Bridge over river'
74+
}
75+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
.fiftyFifty {
2+
@apply desktop:grid desktop:grid-cols-12 desktop:gap-16;
3+
4+
& .content,
5+
& .media {
6+
@apply col-span-6 p-16 flex flex-col items-start justify-center;
7+
}
8+
9+
& .content {
10+
& .title {
11+
@apply mb-8 text-h2 font-secondary;
12+
}
13+
14+
& .body {
15+
@apply mb-24 font-primary text-body text-grey-light;
16+
}
17+
}
18+
19+
& .media {
20+
& .imageWrap {
21+
@apply relative h-0 w-full rounded-largest bg-black bg-opacity-20;
22+
23+
padding-top: 67.58%; /* Aspect ratio box - https://css-tricks.com/aspect-ratio-boxes */
24+
}
25+
26+
& img {
27+
@apply absolute top-0 left-0 w-full h-full object-cover rounded-largest;
28+
}
29+
}
30+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {Canvas, Meta, Story} from '@storybook/addon-docs/blocks'
2+
import FiftyFifty from './'
3+
4+
<Meta title="Components/Molecules/FiftyFifty" component={FiftyFifty} />
5+
6+
# Component
7+
8+
Use this to display a large CTA, usually at the top of a page.
9+
10+
<Canvas>
11+
<Story name="Component">
12+
<FiftyFifty
13+
subtitle="Check it out"
14+
title="New Designs"
15+
body="Our amazing new design is here! Get it while it's hot, it won't be hot for long... uh oh, already cooling."
16+
backgroundImage="https://images.unsplash.com/photo-1610991149688-c1321006bcc1?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1110&q=60"
17+
cta={{icon: 'arrowRight', text: 'Take a look'}}
18+
/>
19+
</Story>
20+
</Canvas>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {default} from './FiftyFifty'

0 commit comments

Comments
 (0)