2016-09-02 11:42:14 -04:00
|
|
|
import { observes } from 'ember-addons/ember-computed-decorators';
|
|
|
|
|
2016-09-16 16:12:56 -04:00
|
|
|
import {
|
|
|
|
createPreviewComponent,
|
|
|
|
loadImage,
|
|
|
|
darkLightDiff,
|
|
|
|
chooseBrighter,
|
2016-09-16 16:39:12 -04:00
|
|
|
drawHeader,
|
|
|
|
LOREM
|
2016-09-16 16:12:56 -04:00
|
|
|
} from 'wizard/lib/preview';
|
|
|
|
|
2016-09-02 11:42:14 -04:00
|
|
|
const LINE_HEIGHT = 12.0;
|
|
|
|
|
2016-09-16 16:39:12 -04:00
|
|
|
export default createPreviewComponent(375, 220, {
|
2016-09-02 11:42:14 -04:00
|
|
|
logo: null,
|
2016-09-16 16:12:56 -04:00
|
|
|
avatar: null,
|
2016-09-02 11:42:14 -04:00
|
|
|
|
2016-09-16 16:12:56 -04:00
|
|
|
@observes('step.fieldsById.theme_id.value')
|
|
|
|
themeChanged() {
|
|
|
|
this.triggerRepaint();
|
|
|
|
},
|
2016-09-02 11:42:14 -04:00
|
|
|
|
2016-09-16 16:12:56 -04:00
|
|
|
load() {
|
|
|
|
return Ember.RSVP.Promise.all([loadImage('/images/wizard/discourse-small.png'),
|
2016-09-02 11:42:14 -04:00
|
|
|
loadImage('/images/wizard/trout.png')]).then(result => {
|
|
|
|
this.logo = result[0];
|
|
|
|
this.avatar = result[1];
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-09-16 16:12:56 -04:00
|
|
|
paint(ctx, colors, width, height) {
|
|
|
|
const headerHeight = height * 0.15;
|
2016-09-02 11:42:14 -04:00
|
|
|
|
2016-09-16 16:12:56 -04:00
|
|
|
drawHeader(ctx, colors, width, headerHeight);
|
2016-09-02 11:42:14 -04:00
|
|
|
|
2016-09-16 16:12:56 -04:00
|
|
|
const margin = width * 0.02;
|
|
|
|
const avatarSize = height * 0.1;
|
2016-09-02 11:42:14 -04:00
|
|
|
|
|
|
|
// Logo
|
|
|
|
const headerMargin = headerHeight * 0.2;
|
|
|
|
const logoHeight = headerHeight - (headerMargin * 2);
|
|
|
|
const logoWidth = (logoHeight / this.logo.height) * this.logo.width;
|
|
|
|
ctx.drawImage(this.logo, headerMargin, headerMargin, logoWidth, logoHeight);
|
|
|
|
|
|
|
|
// Top right menu
|
2016-09-16 16:12:56 -04:00
|
|
|
ctx.drawImage(this.avatar, width - avatarSize - headerMargin, headerMargin, avatarSize, avatarSize);
|
2016-09-02 11:42:14 -04:00
|
|
|
ctx.fillStyle = darkLightDiff(colors.primary, colors.secondary, 45, 55);
|
|
|
|
ctx.font = "0.75em FontAwesome";
|
2016-09-16 16:12:56 -04:00
|
|
|
ctx.fillText("\uf0c9", width - (avatarSize * 2) - (headerMargin * 0.5), avatarSize);
|
|
|
|
ctx.fillText("\uf002", width - (avatarSize * 3) - (headerMargin * 0.5), avatarSize);
|
2016-09-02 11:42:14 -04:00
|
|
|
|
|
|
|
// Draw a fake topic
|
2016-09-16 16:12:56 -04:00
|
|
|
ctx.drawImage(this.avatar, margin, headerHeight + (height * 0.17), avatarSize, avatarSize);
|
2016-09-02 11:42:14 -04:00
|
|
|
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.fillStyle = colors.primary;
|
|
|
|
ctx.font = "bold 0.75em 'Arial'";
|
2016-09-16 16:12:56 -04:00
|
|
|
ctx.fillText("Welcome to Discourse", margin, (height * 0.25));
|
2016-09-02 11:42:14 -04:00
|
|
|
|
|
|
|
ctx.font = "0.5em 'Arial'";
|
|
|
|
|
|
|
|
let line = 0;
|
|
|
|
|
|
|
|
const lines = LOREM.split("\n");
|
|
|
|
for (let i=0; i<10; i++) {
|
2016-09-16 16:12:56 -04:00
|
|
|
line = (height * 0.3) + (i * LINE_HEIGHT);
|
2016-09-02 11:42:14 -04:00
|
|
|
ctx.fillText(lines[i], margin + avatarSize + margin, line);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reply Button
|
|
|
|
ctx.beginPath();
|
2016-09-16 16:12:56 -04:00
|
|
|
ctx.rect(width * 0.57, line + LINE_HEIGHT, width * 0.1, height * 0.07);
|
2016-09-02 11:42:14 -04:00
|
|
|
ctx.fillStyle = colors.tertiary;
|
|
|
|
ctx.fill();
|
|
|
|
ctx.fillStyle = chooseBrighter(colors.primary, colors.secondary);
|
|
|
|
ctx.font = "8px 'Arial'";
|
2016-09-16 16:12:56 -04:00
|
|
|
ctx.fillText("Reply", width * 0.595, line + (LINE_HEIGHT * 1.8));
|
2016-09-02 11:42:14 -04:00
|
|
|
|
|
|
|
// Icons
|
|
|
|
ctx.font = "0.5em FontAwesome";
|
|
|
|
ctx.fillStyle = colors.love;
|
2016-09-16 16:12:56 -04:00
|
|
|
ctx.fillText("\uf004", width * 0.48, line + (LINE_HEIGHT * 1.8));
|
2016-09-02 11:42:14 -04:00
|
|
|
ctx.fillStyle = darkLightDiff(colors.primary, colors.secondary, 65, 55);
|
2016-09-16 16:12:56 -04:00
|
|
|
ctx.fillText("\uf040", width * 0.525, line + (LINE_HEIGHT * 1.8));
|
2016-09-02 11:42:14 -04:00
|
|
|
|
|
|
|
// Draw Timeline
|
2016-09-16 16:12:56 -04:00
|
|
|
const timelineX = width * 0.8;
|
2016-09-02 11:42:14 -04:00
|
|
|
ctx.beginPath();
|
|
|
|
ctx.strokeStyle = colors.tertiary;
|
|
|
|
ctx.lineWidth = 0.5;
|
2016-09-16 16:12:56 -04:00
|
|
|
ctx.moveTo(timelineX, height * 0.3);
|
|
|
|
ctx.lineTo(timelineX, height * 0.6);
|
2016-09-02 11:42:14 -04:00
|
|
|
ctx.stroke();
|
|
|
|
|
|
|
|
// Timeline
|
|
|
|
ctx.beginPath();
|
|
|
|
ctx.strokeStyle = colors.tertiary;
|
|
|
|
ctx.lineWidth = 2;
|
2016-09-16 16:12:56 -04:00
|
|
|
ctx.moveTo(timelineX, height * 0.3);
|
|
|
|
ctx.lineTo(timelineX, height * 0.4);
|
2016-09-02 11:42:14 -04:00
|
|
|
ctx.stroke();
|
|
|
|
|
|
|
|
ctx.font = "Bold 0.5em Arial";
|
|
|
|
ctx.fillStyle = colors.primary;
|
2016-09-16 16:12:56 -04:00
|
|
|
ctx.fillText("1 / 20", timelineX + margin, (height * 0.3) + (margin * 1.5));
|
2016-09-02 11:42:14 -04:00
|
|
|
}
|
|
|
|
});
|