feat: add mobile css
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
import { Box } from './box';
|
||||
import jsPDF from 'jspdf';
|
||||
import { AbstractElement } from './abstract-element';
|
||||
import { IContext } from './context';
|
||||
|
||||
export class Image extends Box {
|
||||
public imageData: string;
|
||||
|
||||
constructor(x: number, y: number, w: number, h: number, imageData: string) {
|
||||
super(x, y, w, h);
|
||||
constructor(
|
||||
x: number,
|
||||
y: number,
|
||||
w: number,
|
||||
h: number,
|
||||
imageData: string,
|
||||
context: Partial<IContext> = AbstractElement.DEFAULT_CONTEXT
|
||||
) {
|
||||
super(x, y, w, h, context);
|
||||
this.imageData = imageData;
|
||||
}
|
||||
|
||||
@@ -29,18 +37,16 @@ export class Image extends Box {
|
||||
): Document {
|
||||
const img = doc.createElement('img');
|
||||
img.src = this.imageData;
|
||||
const css = `img-${this.w ?? 0}-${this.h ?? 0}`;
|
||||
const css = `img-${this.w ?? 0}`;
|
||||
img.classList.add(`img`);
|
||||
img.classList.add(css);
|
||||
img.classList.add(this.context.name);
|
||||
if (!cssRules.includes(css)) {
|
||||
cssRules.push(css);
|
||||
let rule = '';
|
||||
if (this.w > 0) {
|
||||
rule += `width: ${this.w}px;`;
|
||||
}
|
||||
if (this.h > 0) {
|
||||
rule += `height: ${this.h}px;`;
|
||||
}
|
||||
if (rule.length > 0) {
|
||||
sheet.innerHTML += ` .${css} { ${rule} }`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user