-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial image card * image card component * Fixed styles and optimized * image first * use ui components * refactor * refactor * add sm
- Loading branch information
1 parent
dce1fb7
commit 158c002
Showing
7 changed files
with
221 additions
and
78 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
interface TextProps { | ||
children: React.ReactNode; | ||
className?: string; | ||
} | ||
|
||
export function Heading({ children, className = '' }: TextProps) { | ||
return ( | ||
<h2 | ||
className={`text-[1.5rem] font-bold text-[#224a58] xl:text-[2rem] ${className}`} | ||
> | ||
{children} | ||
</h2> | ||
); | ||
} | ||
|
||
export function Paragraph({ children, className = '' }: TextProps) { | ||
return ( | ||
<p | ||
className={`text-base font-normal leading-relaxed text-[#224a58] ${className}`} | ||
> | ||
{children} | ||
</p> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.imageCard { | ||
background: var(--card-background); | ||
@media (min-width: 1280px) { | ||
border-radius: 2.5rem 0rem 2.5rem 0rem; | ||
} | ||
box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.1); | ||
|
||
.imageContainer { | ||
@media (min-width: 1280px) { | ||
border-radius: 2.5rem 0rem 0rem 0rem; | ||
img { | ||
border-radius: 2.5rem 0rem 0rem 0rem; | ||
} | ||
} | ||
@media (max-width: 1279px) { | ||
margin-top: 2rem; | ||
} | ||
} | ||
|
||
.textBox { | ||
padding: 2.5rem; | ||
} | ||
|
||
.imageContainerReverse { | ||
@media (min-width: 1280px) { | ||
border-radius: 0rem 0rem 2.5rem 0rem; | ||
img { | ||
border-radius: 0rem 0rem 2.5rem 0rem; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Image from 'next/image'; | ||
import { type CSSProperties } from 'react'; | ||
import { Container, ImageContainer, TextContainer } from './_ui'; | ||
|
||
interface ImageCardProps { | ||
imageUrl: string; | ||
imageAlt: string; | ||
children: React.ReactNode; | ||
imageFirst?: boolean; | ||
imageStyle?: CSSProperties; | ||
} | ||
|
||
export const ImageCard = ({ | ||
imageUrl, | ||
imageAlt, | ||
children, | ||
imageFirst = true, | ||
imageStyle = {}, | ||
}: ImageCardProps) => ( | ||
<Container imageFirst={imageFirst}> | ||
<ImageContainer imageFirst={imageFirst}> | ||
<Image | ||
className="h-full w-full object-cover" | ||
src={imageUrl} | ||
width={0} | ||
height={0} | ||
alt={imageAlt} | ||
style={imageStyle} | ||
priority={true} | ||
/> | ||
</ImageContainer> | ||
<TextContainer imageFirst={imageFirst}>{children}</TextContainer> | ||
</Container> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import classNames from 'classnames'; | ||
import styles from '../ImageCard.module.scss'; | ||
|
||
interface ContainerProps { | ||
children: React.ReactNode; | ||
imageFirst?: boolean; | ||
} | ||
|
||
export const Container = ({ children, imageFirst = true }: ContainerProps) => { | ||
const imageFirstClass = imageFirst | ||
? 'xl:grid-cols-[1fr_2fr]' | ||
: 'xl:grid-cols-[2fr_1fr]'; | ||
|
||
return ( | ||
<div | ||
className={classNames( | ||
'grid grid-cols-1 justify-items-center gap-4 xl:justify-items-start xl:gap-14', | ||
imageFirstClass, | ||
styles.imageCard, | ||
)} | ||
> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
interface ChildrenProps { | ||
children: React.ReactNode; | ||
imageFirst: boolean; | ||
} | ||
|
||
export const ImageContainer = ({ children, imageFirst }: ChildrenProps) => ( | ||
<div | ||
className={classNames( | ||
imageFirst ? styles.imageContainer : styles['image-box-reverse'], | ||
'image-box h-full overflow-hidden sm:w-[30rem]', | ||
imageFirst ? 'order-1' : 'order-1 xl:order-2', | ||
)} | ||
> | ||
{children} | ||
</div> | ||
); | ||
|
||
export const TextContainer = ({ children, imageFirst }: ChildrenProps) => ( | ||
<div | ||
className={classNames( | ||
'text-box order-2 flex flex-col gap-5 pb-10 pt-10', | ||
imageFirst ? '' : 'xl:order-1 xl:pl-10', | ||
)} | ||
> | ||
{children} | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters