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

Commit 0c0c83a

Browse files
committed
Add mediaLeft option
1 parent 6d8284a commit 0c0c83a

File tree

3 files changed

+72
-28
lines changed

3 files changed

+72
-28
lines changed

components/organisms/MediaText/MediaText.js

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,42 @@ import styles from './MediaText.module.css'
88
/**
99
* Render the MediaText component.
1010
*
11-
* @param {object} props MediaText 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 MediaText component.
11+
* @param {object} props MediaText 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 {boolean} props.mediaLeft Whether to show media on the left of the text.
17+
* @param {string} props.title The title.
18+
* @return {Element} The MediaText component.
1819
*/
19-
export default function MediaText({body, className, cta, image, title}) {
20+
export default function MediaText({
21+
body,
22+
className,
23+
cta,
24+
image,
25+
mediaLeft,
26+
title
27+
}) {
2028
return (
2129
<Container>
22-
<section className={cn(styles.mediaText, className)}>
23-
<div className={styles.content}>
30+
<section
31+
className={cn(
32+
styles.mediaText,
33+
mediaLeft ? styles.mediaLeft : null,
34+
className
35+
)}
36+
>
37+
<div className={styles.text}>
2438
<h1 className={styles.title}>{title}</h1>
2539
{body && <p className={styles.body}>{body}</p>}
2640
{cta && (
2741
<Button
2842
className={styles.button}
2943
url={cta.url ? cta.url : null}
3044
text={cta.text ? cta.text : null}
45+
icon={cta.icon ? cta.icon : null}
46+
iconPosition="right"
3147
type="primary"
3248
size="md"
3349
/>
@@ -50,26 +66,17 @@ MediaText.propTypes = {
5066
className: PropTypes.string,
5167
cta: PropTypes.shape({
5268
text: PropTypes.string,
53-
url: PropTypes.string
69+
url: PropTypes.string,
70+
icon: PropTypes.string
5471
}),
5572
image: PropTypes.shape({
5673
url: PropTypes.string,
5774
alt: PropTypes.string
5875
}),
76+
mediaLeft: PropTypes.bool,
5977
title: PropTypes.string
6078
}
6179

6280
MediaText.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-
}
81+
mediaLeft: false
7582
}

components/organisms/MediaText/MediaText.module.css

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
.mediaText {
22
@apply desktop:grid desktop:grid-cols-12 desktop:gap-16;
33

4-
& .content,
4+
& .text,
55
& .media {
66
@apply col-span-6 p-16 flex flex-col items-start justify-center;
77
}
88

9-
& .content {
9+
& .text {
1010
& .title {
1111
@apply mb-8 text-h2 font-secondary;
1212
}
@@ -27,4 +27,18 @@
2727
@apply absolute top-0 left-0 w-full h-full object-cover rounded-largest;
2828
}
2929
}
30+
31+
&.mediaLeft {
32+
& .media {
33+
grid-row-start: 1;
34+
}
35+
36+
& .text {
37+
@apply items-end;
38+
39+
& .body {
40+
@apply text-right;
41+
}
42+
}
43+
}
3044
}

components/organisms/MediaText/MediaText.stories.mdx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,39 @@ import MediaText from './'
55

66
# Component
77

8-
Use this to display a large CTA, usually at the top of a page.
8+
Use this to display media and text in a 50/50 layout.
99

1010
<Canvas>
1111
<Story name="Component">
1212
<MediaText
13-
subtitle="Check it out"
1413
title="New Designs"
1514
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"
15+
image={{
16+
url:
17+
'https://images.unsplash.com/photo-1610991149688-c1321006bcc1?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1110&q=60',
18+
alt: 'Some alt text'
19+
}}
1720
cta={{icon: 'arrowRight', text: 'Take a look'}}
1821
/>
1922
</Story>
2023
</Canvas>
24+
25+
## Media Left
26+
27+
Media will display on the right on large screens by default. Use the `mediaLeft` prop to display the media on the left side.
28+
29+
<Canvas>
30+
<Story name="MediaLeft">
31+
<MediaText
32+
title="New Designs"
33+
body="Our amazing new design is here! Get it while it's hot, it won't be hot for long... uh oh, already cooling."
34+
image={{
35+
url:
36+
'https://images.unsplash.com/photo-1610991149688-c1321006bcc1?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1110&q=60',
37+
alt: 'Some alt text'
38+
}}
39+
cta={{icon: 'arrowRight', text: 'Take a look'}}
40+
mediaLeft
41+
/>
42+
</Story>
43+
</Canvas>

0 commit comments

Comments
 (0)