Skip to content

Commit

Permalink
fix: 🐛 fixing image usage in the application
Browse files Browse the repository at this point in the history
  • Loading branch information
emiliosheinz committed Feb 10, 2023
1 parent 5ba9773 commit 29c8acd
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 11 deletions.
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion src/components/deck-card-list/deck-card-list.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Error } from './error.component'
import { Loading } from './loading.component'

export function DeckCardList({ decks }: DeckCardListProps) {
if (decks.length === 0)
if (decks.length === 0 || true)
return (
<Feedback
shouldHideButton
Expand Down
6 changes: 3 additions & 3 deletions src/components/feedback/feedback.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useRouter } from 'next/router'

import { Button } from '~/components/button'
import { Image } from '~/components/image'
import PettingImage from '~/images/petting.svg'
import { routes } from '~/utils/navigation'

import type { FeedbackProps } from './feedback.types'
Expand All @@ -16,7 +15,7 @@ export function Feedback(props: FeedbackProps) {
buttonLabel,
onButtonClick,
shouldHideButton,
CustomImage,
customImageSrc,
} = props

const router = useRouter()
Expand Down Expand Up @@ -52,8 +51,9 @@ export function Feedback(props: FeedbackProps) {
</div>
<Image
width={300}
src={CustomImage || PettingImage}
height={300}
alt={`${subtitle} illustration`}
src={customImageSrc || '/images/petting.svg'}
/>
</div>
{renderButton()}
Expand Down
4 changes: 1 addition & 3 deletions src/components/feedback/feedback.types.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import type { StaticImageData } from 'next/image'

export type FeedbackProps = {
title: (() => JSX.Element) | string
subtitle: (() => JSX.Element) | string
buttonLabel?: string
onButtonClick?: () => void
shouldHideButton?: boolean
CustomImage?: StaticImageData
customImageSrc?: string
}
7 changes: 6 additions & 1 deletion src/components/image/image.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const shimmer = `
const MINIMUM_IMAGE_SIZE_WITH_BLUE = 40

function BaseImage(props: ImageProps) {
const { width, height, ...otherProps } = props
const { width, height, style, ...otherProps } = props

const blurProps: Pick<ImageProps, 'placeholder' | 'blurDataURL'> =
useMemo(() => {
Expand All @@ -32,6 +32,11 @@ function BaseImage(props: ImageProps) {
width={width}
height={height}
data-testid='image-component'
style={{
width: width,
height: height,
...style,
}}
{...blurProps}
{...otherProps}
/>
Expand Down
5 changes: 2 additions & 3 deletions src/pages/decks/review/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Feedback } from '~/components/feedback'
import { Loader } from '~/components/loader'
import { TextArea } from '~/components/text-area'
import { Tooltip } from '~/components/tooltip'
import SwingingImage from '~/images/swinging.svg'
import { useDeckReview } from '~/modules/decks/review/hooks/use-deck-review.hook'
import type { WithAuthentication } from '~/types/auth'
import { classNames } from '~/utils/css'
Expand Down Expand Up @@ -143,7 +142,7 @@ const ReviewDeck: WithAuthentication<
return (
<Feedback
title='🎉 Parabéns!!!'
CustomImage={SwingingImage}
customImageSrc='/images/swinging.svg'
subtitle='Você revisou todos os Cards pendentes. Volte novamente na sua próxima revisão.'
{...okButton}
/>
Expand All @@ -154,7 +153,7 @@ const ReviewDeck: WithAuthentication<
return (
<Feedback
title='🎉 Woohooo!!!'
CustomImage={SwingingImage}
customImageSrc='/images/swinging.svg'
subtitle={() => (
<>
No momento nenhum Card precisa ser revisado. Por favor, volte mais
Expand Down

0 comments on commit 29c8acd

Please sign in to comment.