Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
use size constant in CSS styles to avoid duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubjanczyk committed Apr 21, 2021
1 parent e6e8687 commit b1fdd01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/components/MessageCard/MessageCard.css.js
Expand Up @@ -7,6 +7,9 @@ import Card from '../Card'
import Button from '../Button'
import Heading from '../Heading'
import Image from '../Image'

export const MAX_IMAGE_SIZE = 278

const fontFamily = makeFontFamily('Barlow')

export const MessageCardUI = styled(Card)`
Expand Down Expand Up @@ -272,7 +275,7 @@ export const ImageUI = styled(Image)`
border-radius: 3px;
height: ${({ height }) => height};
width: ${({ width }) => width};
max-height: 278px;
max-height: ${MAX_IMAGE_SIZE}px;
`

export const ImageContainerUI = styled('div')`
Expand All @@ -281,5 +284,5 @@ export const ImageContainerUI = styled('div')`
width: 100%;
margin-top: 20px;
padding: 0 10px;
max-height: 278px;
max-height: ${MAX_IMAGE_SIZE}px;
`
3 changes: 1 addition & 2 deletions src/components/MessageCard/MessageCard.jsx
Expand Up @@ -10,14 +10,13 @@ import {
BodyUI,
ImageContainerUI,
ImageUI,
MAX_IMAGE_SIZE,
MessageCardUI,
SubtitleUI,
TitleUI,
} from './MessageCard.css'
import Truncate from '../Truncate'

const MAX_IMAGE_SIZE = 278

const sizeWithRatio = (recalculatedSide, otherSide, defaultValue) =>
// Check if other side is smaller than max size to not recalculate unnecessarily this side as it doesn't need any scaling
// other condition checks that the image fits the boundaries
Expand Down

0 comments on commit b1fdd01

Please sign in to comment.