This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(components): ✨ created image card component
- Loading branch information
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
import styled from '@emotion/styled'; | ||
import { useTheme } from 'emotion-theming'; | ||
import Card from './card'; | ||
|
||
const ImageCard = styled(Card)` | ||
width: ${(props) => props.width}; | ||
height: ${(props) => props.height}; | ||
@media (max-width: ${(props) => props.theme.breakpoints['small']}) { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
`; | ||
|
||
const Image = styled.img` | ||
align-self: center; | ||
border-radius: 4px; | ||
`; | ||
|
||
|
||
const Text = styled.p` | ||
margin-top: 15px; | ||
& > p:first-child { | ||
margin-top: 0; | ||
} | ||
& > p:last-child { | ||
margin-bottom: 0; | ||
} | ||
`; | ||
|
||
export default ({ children, width, height, src}) => { | ||
const theme = useTheme(); | ||
const imgWidth = width ? width : '50%'; | ||
const imgHeight = width ? width : '50%'; | ||
return ( | ||
<ImageCard width={imgWidth} height={imgHeight}> | ||
<Image src={src} /> | ||
<Text>{children}</Text> | ||
</ImageCard> | ||
); | ||
}; |
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