|
1 | | -import ButtonLink from '@/components/buttons/ButtonLink'; |
2 | | -import TwoColumnStyles from './styles'; |
3 | | - |
4 | | -export default function TwoColumn({ |
5 | | - image, |
6 | | - altTag, |
7 | | - title, |
8 | | - content, |
9 | | - rowOrder, |
10 | | - color, |
11 | | - bgColor, |
12 | | - link, |
13 | | - customBtnClass, |
14 | | - linkText = 'Learn more', |
15 | | - secondTextColumn, |
16 | | - openNewTab, |
17 | | - $contentType, |
18 | | -}) { |
19 | | - //Set Styles based on content type |
20 | | - const S = TwoColumnStyles[$contentType] |
21 | | - ? TwoColumnStyles[$contentType] |
22 | | - : TwoColumnStyles.base; |
23 | | - |
24 | | - // Add rowOrder="row-reverse" prop to the component to reverse its order on desktop |
25 | | - return ( |
26 | | - <S.TwoColumnWrapper $color={color} $bgColor={bgColor}> |
27 | | - <S.InnerContainer |
28 | | - $contentType={$contentType} |
29 | | - styles={{ flexDirection: rowOrder }} |
30 | | - > |
31 | | - <S.InnerContent $contentType={$contentType}> |
32 | | - {title && <S.Title $color={color}>{title}</S.Title>} |
33 | | - <S.Content $contentType={$contentType}>{content}</S.Content> |
34 | | - {link && ( |
35 | | - <ButtonLink |
36 | | - link={link} |
37 | | - customBtnClass={customBtnClass} |
38 | | - openNewTab={openNewTab} |
39 | | - > |
40 | | - {linkText} |
41 | | - </ButtonLink> |
42 | | - )} |
43 | | - </S.InnerContent> |
44 | | - {secondTextColumn && secondTextColumn} |
45 | | - {!secondTextColumn && image && ( |
46 | | - <S.InnerImageWrapper $contentType={$contentType}> |
47 | | - <S.InnerImage |
48 | | - $contentType={$contentType} |
49 | | - src={image} |
50 | | - alt={altTag} |
51 | | - fill |
52 | | - /> |
53 | | - </S.InnerImageWrapper> |
54 | | - )} |
55 | | - </S.InnerContainer> |
56 | | - </S.TwoColumnWrapper> |
57 | | - ); |
58 | | -} |
| 1 | +import styles from './TwoColumn.module.scss'; |
| 2 | +import ButtonLink from '@/components/buttons/ButtonLink'; |
| 3 | +import Container from '@/components/containers/Container'; |
| 4 | +import Image from 'next/image'; |
| 5 | +import { combineClasses } from '@/utils/classnames'; |
| 6 | + |
| 7 | +export default function TwoColumn({ |
| 8 | + image, |
| 9 | + altTag, |
| 10 | + title, |
| 11 | + content, |
| 12 | + rowOrder, |
| 13 | + color, |
| 14 | + bgColor, |
| 15 | + link, |
| 16 | + customBtnClass, |
| 17 | + customInnerClass, |
| 18 | + linkText = 'Learn more', |
| 19 | + secondTextColumn, |
| 20 | + openNewTab, |
| 21 | +}) { |
| 22 | + const styleProps = { |
| 23 | + wrapper: { |
| 24 | + color, |
| 25 | + backgroundColor: bgColor, |
| 26 | + }, |
| 27 | + container: { |
| 28 | + flexDirection: rowOrder, |
| 29 | + }, |
| 30 | + }; |
| 31 | + |
| 32 | + // Add rowOrder="row-reverse" prop to the component to reverse its order on desktop |
| 33 | + return ( |
| 34 | + <section className={styles.wrapper} style={styleProps.wrapper}> |
| 35 | + <Container |
| 36 | + className={combineClasses(styles.inner, customInnerClass, styles)} |
| 37 | + styles={styleProps.container} |
| 38 | + > |
| 39 | + <div className={styles.inner__content}> |
| 40 | + {title && <h2 className={styles.title}>{title}</h2>} |
| 41 | + <div className={styles.content}>{content}</div> |
| 42 | + {link && ( |
| 43 | + <ButtonLink |
| 44 | + link={link} |
| 45 | + customBtnClass={customBtnClass} |
| 46 | + openNewTab={openNewTab} |
| 47 | + > |
| 48 | + {linkText} |
| 49 | + </ButtonLink> |
| 50 | + )} |
| 51 | + </div> |
| 52 | + {secondTextColumn || |
| 53 | + (image && ( |
| 54 | + <div className={styles.inner__image}> |
| 55 | + <Image className={styles.img} src={image} alt={altTag} fill /> |
| 56 | + </div> |
| 57 | + ))} |
| 58 | + </Container> |
| 59 | + </section> |
| 60 | + ); |
| 61 | +} |
0 commit comments