Remove "framework"
This commit is contained in:
parent
b45bdb18a0
commit
dc86d30eb2
72 changed files with 359 additions and 333 deletions
24
src/page/basics/image/image.ts
Normal file
24
src/page/basics/image/image.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { PageElement } from '../../page-element';
|
||||
import { createElement } from '../../../helper/create-element';
|
||||
import { generate } from './image.html';
|
||||
import { last } from '../../../helper/last';
|
||||
import { ResponsiveImage } from '../../../types/responsive-image';
|
||||
|
||||
export class Image extends PageElement {
|
||||
private static readonly imageScreenRatio = 0.8;
|
||||
|
||||
public constructor(image: ResponsiveImage, alt: string, container = true) {
|
||||
super(
|
||||
createElement(generate({ image, alt, container, sizes: Image.getSizes(image) }))
|
||||
);
|
||||
}
|
||||
|
||||
private static getSizes(image: ResponsiveImage): string {
|
||||
return (
|
||||
image.images
|
||||
.slice(0, -1)
|
||||
.map(d => `(max-width: ${d.width / Image.imageScreenRatio}px) ${d.width}px,`)
|
||||
.join('\n') + `\n${last(image.images).width}px`
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue