Skip to content

Commit

Permalink
fix: preview image width
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Oct 18, 2024
1 parent e8b16e7 commit 7847da8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion apps/renderer/src/components/ui/media/preview-media.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useTranslation } from "react-i18next"
import { Keyboard, Mousewheel } from "swiper/modules"
import type { SwiperRef } from "swiper/react"
import { Swiper, SwiperSlide } from "swiper/react"
import { useWindowSize } from "usehooks-ts"

import { m } from "~/components/common/Motion"
import { COPY_MAP } from "~/constants"
Expand Down Expand Up @@ -293,10 +294,20 @@ const FallbackableImage: FC<

const height = Number.parseInt(props.height as string)
const width = Number.parseInt(props.width as string)

const { height: windowHeight, width: windowWidth } = useWindowSize()

return (
<div className={cn("center flex size-full flex-col", containerClassName)}>
{!isAllError && (
<div className={cn("relative", width > height ? "w-full" : "h-full")}>
<div
className={cn("relative", width < height && "h-full")}
style={{
// px-20 pb-8 pt-10
width: width > height ? (windowHeight - 32 - 40) * (width / height) : undefined,
maxWidth: width > height ? windowWidth - 80 - 80 - 400 : undefined,
}}
>
<img
data-blurhash={blurhash}
src={currentSrc}
Expand Down

0 comments on commit 7847da8

Please sign in to comment.