discourse/app/assets/javascripts/wizard/components/image-preview-logo.js
Bianca Nenciu f2e14a3946
FEATURE: Add site setting and wizard step to set base font (#10250)
Co-authored-by: Neil Lalonde <neillalonde@gmail.com>
2020-08-31 13:14:09 +03:00

37 lines
832 B
JavaScript

import { observes } from "discourse-common/utils/decorators";
import { createPreviewComponent, drawHeader } from "wizard/lib/preview";
export default createPreviewComponent(400, 100, {
image: null,
@observes("field.value")
imageChanged() {
this.reload();
},
images() {
return { image: this.get("field.value") };
},
paint(ctx, colors, font, width, height) {
const headerHeight = height / 2;
drawHeader(ctx, colors, width, headerHeight);
const image = this.image;
const headerMargin = headerHeight * 0.2;
const imageHeight = headerHeight - headerMargin * 2;
const ratio = imageHeight / image.height;
this.scaleImage(
image,
headerMargin,
headerMargin,
image.width * ratio,
imageHeight
);
this.drawPills(colors, font, height / 2);
}
});