2022-08-01 16:20:29 +00:00
|
|
|
import { Comic, ComicBubble, ComicPage } from '@prisma/client';
|
|
|
|
import Image from 'next/image';
|
|
|
|
import { percentify, randomColour } from '../src/utils';
|
2022-08-01 16:18:55 +00:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
page: ComicPage & {
|
|
|
|
bubbles: ComicBubble[];
|
|
|
|
comic: Comic;
|
|
|
|
};
|
|
|
|
highlightedBubbles: number[] | null;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function HighlightComic(props: Props) {
|
2022-08-01 16:20:29 +00:00
|
|
|
return (
|
|
|
|
<div className='relative box-border inline-block select-none'>
|
|
|
|
<div className='box-border max-w-full'>
|
|
|
|
<Image
|
|
|
|
src={props.page.imageUrl}
|
|
|
|
width={props.page.width}
|
|
|
|
height={props.page.height}
|
2022-08-01 16:24:10 +00:00
|
|
|
alt={props.page.title}
|
2022-08-01 16:20:29 +00:00
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
top: 0,
|
|
|
|
left: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
{props.highlightedBubbles &&
|
|
|
|
props.highlightedBubbles.map((bubble) => {
|
|
|
|
return (
|
|
|
|
<div
|
2022-08-01 16:24:10 +00:00
|
|
|
key={bubble}
|
2022-08-01 16:20:29 +00:00
|
|
|
className='box-border'
|
2022-08-01 16:24:50 +00:00
|
|
|
aria-hidden
|
2022-08-01 16:20:29 +00:00
|
|
|
style={{
|
|
|
|
border: `1.5px dashed ${randomColour(
|
|
|
|
props.page.id,
|
|
|
|
0.9,
|
|
|
|
0.49,
|
|
|
|
0.5
|
|
|
|
)}`,
|
|
|
|
backgroundColor: randomColour(
|
|
|
|
props.page.id,
|
|
|
|
0.9,
|
|
|
|
undefined,
|
|
|
|
0.5
|
|
|
|
),
|
|
|
|
position: 'absolute',
|
|
|
|
left: `${percentify(
|
|
|
|
props.page.width,
|
|
|
|
props.page.bubbles[bubble].areaX
|
|
|
|
)}%`,
|
|
|
|
top: `${percentify(
|
|
|
|
props.page.height,
|
|
|
|
props.page.bubbles[bubble].areaY
|
|
|
|
)}%`,
|
|
|
|
width: `${percentify(
|
|
|
|
props.page.width,
|
|
|
|
props.page.bubbles[bubble].areaWidth
|
|
|
|
)}%`,
|
|
|
|
height: `${percentify(
|
|
|
|
props.page.height,
|
|
|
|
props.page.bubbles[bubble].areaHeight
|
|
|
|
)}%`,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
);
|
2022-08-01 16:18:55 +00:00
|
|
|
}
|