| 1 | import type React from "react"; |
| 2 | |
| 3 | import { type ImageCropSettings } from "../../utils/types"; |
| 4 | |
| 5 | export const presentationImageAlignmentClasses = { |
| 6 | center: "mx-auto", |
| 7 | left: "mr-auto", |
| 8 | right: "ml-auto", |
| 9 | } as const; |
| 10 | |
| 11 | export function getPresentationImageCropStyles( |
| 12 | cropSettings?: ImageCropSettings, |
| 13 | ): React.CSSProperties { |
| 14 | const objectPosition = cropSettings |
| 15 | ? `${cropSettings.objectPosition.x}% ${cropSettings.objectPosition.y}%` |
| 16 | : "50% 50%"; |
| 17 | |
| 18 | return { |
| 19 | objectFit: cropSettings?.objectFit ?? "cover", |
| 20 | objectPosition, |
| 21 | transform: `scale(${cropSettings?.zoom ?? 1})`, |
| 22 | transformOrigin: objectPosition, |
| 23 | }; |
| 24 | } |
| 25 | |
| 26 | export function getPresentationImageFrameStyles( |
| 27 | cropSettings?: ImageCropSettings, |
| 28 | ): React.CSSProperties { |
| 29 | return { |
| 30 | ...getPresentationImageCropStyles(cropSettings), |
| 31 | borderRadius: "var(--presentation-border-radius, 0.5rem)", |
| 32 | boxShadow: "var(--presentation-card-shadow, 0 1px 3px rgba(0,0,0,0.12))", |
| 33 | }; |
| 34 | } |
| 35 |