mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 10:36:32 +08:00
a4356b99af
Allows site administrators to pick different fonts for headings in the wizard and in their site settings. Also correctly displays the header logos in wizard previews.
38 lines
838 B
JavaScript
38 lines
838 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);
|
|
},
|
|
});
|