diff --git a/app/assets/javascripts/discourse/app/static/wizard/components/fields/dropdown.gjs b/app/assets/javascripts/discourse/app/static/wizard/components/fields/dropdown.gjs new file mode 100644 index 00000000000..4a6f16d4c66 --- /dev/null +++ b/app/assets/javascripts/discourse/app/static/wizard/components/fields/dropdown.gjs @@ -0,0 +1,73 @@ +import Component from "@glimmer/component"; +import { hash } from "@ember/helper"; +import { action, set } from "@ember/object"; +import ColorPalettes from "select-kit/components/color-palettes"; +import ComboBox from "select-kit/components/combo-box"; +import FontSelector from "select-kit/components/font-selector"; +import HomepageStyleSelector from "select-kit/components/homepage-style-selector"; + +export default class Dropdown extends Component { + constructor() { + super(...arguments); + + if (this.args.field.id === "color_scheme") { + for (let choice of this.args.field.choices) { + if (choice?.data?.colors) { + set(choice, "colors", choice.data.colors); + } + } + } + + if (this.args.field.id === "body_font") { + for (let choice of this.args.field.choices) { + set(choice, "classNames", `body-font-${choice.id.replace(/_/g, "-")}`); + } + } + + if (this.args.field.id === "heading_font") { + for (let choice of this.args.field.choices) { + set( + choice, + "classNames", + `heading-font-${choice.id.replace(/_/g, "-")}` + ); + } + } + } + + get component() { + switch (this.args.field.id) { + case "color_scheme": + return ColorPalettes; + case "body_font": + case "heading_font": + return FontSelector; + case "homepage_style": + return HomepageStyleSelector; + default: + return ComboBox; + } + } + + keyPress(event) { + event.stopPropagation(); + } + + @action + onChangeValue(value) { + this.set("field.value", value); + } + + +} diff --git a/app/assets/javascripts/discourse/app/static/wizard/components/fields/dropdown.hbs b/app/assets/javascripts/discourse/app/static/wizard/components/fields/dropdown.hbs deleted file mode 100644 index 3fbeeb98de5..00000000000 --- a/app/assets/javascripts/discourse/app/static/wizard/components/fields/dropdown.hbs +++ /dev/null @@ -1,10 +0,0 @@ -{{component - this.component - class="wizard-container__dropdown" - value=this.field.value - content=this.field.choices - nameProperty="label" - tabindex="9" - onChange=(action "onChangeValue") - options=(hash translatedNone=false) -}} \ No newline at end of file diff --git a/app/assets/javascripts/discourse/app/static/wizard/components/fields/dropdown.js b/app/assets/javascripts/discourse/app/static/wizard/components/fields/dropdown.js deleted file mode 100644 index 9f720578228..00000000000 --- a/app/assets/javascripts/discourse/app/static/wizard/components/fields/dropdown.js +++ /dev/null @@ -1,33 +0,0 @@ -import Component from "@ember/component"; -import { action, set } from "@ember/object"; -import discourseComputed from "discourse-common/utils/decorators"; -import ColorPalettes from "select-kit/components/color-palettes"; -import ComboBox from "select-kit/components/combo-box"; - -export default class Dropdown extends Component { - init() { - super.init(...arguments); - - if (this.field.id === "color_scheme") { - for (let choice of this.field.choices) { - if (choice?.data?.colors) { - set(choice, "colors", choice.data.colors); - } - } - } - } - - @discourseComputed("field.id") - component(id) { - return id === "color_scheme" ? ColorPalettes : ComboBox; - } - - keyPress(e) { - e.stopPropagation(); - } - - @action - onChangeValue(value) { - this.set("field.value", value); - } -} diff --git a/app/assets/javascripts/discourse/app/static/wizard/components/fields/image-previews/logo-small.js b/app/assets/javascripts/discourse/app/static/wizard/components/fields/image-previews/logo-small.js index a91680360f2..537835a85b4 100644 --- a/app/assets/javascripts/discourse/app/static/wizard/components/fields/image-previews/logo-small.js +++ b/app/assets/javascripts/discourse/app/static/wizard/components/fields/image-previews/logo-small.js @@ -1,5 +1,6 @@ import { action } from "@ember/object"; -import { drawHeader, LOREM } from "../../../lib/preview"; +import { i18n } from "discourse-i18n"; +import { drawHeader } from "../../../lib/preview"; import PreviewBaseComponent from "../styling-preview/-preview-base"; export default class LogoSmall extends PreviewBaseComponent { @@ -34,10 +35,10 @@ export default class LogoSmall extends PreviewBaseComponent { const image = this.image; const headerMargin = headerHeight * 0.2; - const maxWidth = headerHeight - headerMargin * 2.0; let imageWidth = image.width; let ratio = 1.0; + if (imageWidth > maxWidth) { ratio = maxWidth / imageWidth; imageWidth = maxWidth; @@ -52,38 +53,42 @@ export default class LogoSmall extends PreviewBaseComponent { ); const afterLogo = headerMargin * 1.7 + imageWidth; - const fontSize = Math.round(headerHeight * 0.4); + const fontSize = Math.round(headerHeight * 0.3); ctx.font = `Bold ${fontSize}px '${headingFont}'`; ctx.fillStyle = colors.primary; - const title = LOREM.substring(0, 27); + const title = i18n("wizard.homepage_preview.topic_titles.what_books"); ctx.fillText( title, - headerMargin + imageWidth, - headerHeight - fontSize * 1.1 + headerMargin + imageWidth + 10, + headerHeight - fontSize * 1.8 ); const category = this.categories()[0]; const badgeSize = height / 13.0; ctx.beginPath(); ctx.fillStyle = category.color; - ctx.rect(afterLogo, headerHeight * 0.7, badgeSize, badgeSize); + ctx.rect(afterLogo + 2, headerHeight * 0.6, badgeSize, badgeSize); ctx.fill(); ctx.font = `Bold ${badgeSize * 1.2}px '${font}'`; ctx.fillStyle = colors.primary; ctx.fillText( - category.displayName, + category.name, afterLogo + badgeSize * 1.5, - headerHeight * 0.7 + badgeSize * 0.9 + headerHeight * 0.6 + badgeSize * 0.9 ); const LINE_HEIGHT = 12; ctx.font = `${LINE_HEIGHT}px '${font}'`; - const lines = LOREM.split("\n"); - for (let i = 0; i < 10; i++) { - const line = height * 0.55 + i * (LINE_HEIGHT * 1.5); - ctx.fillText(lines[i], afterLogo, line); + const opFirstSentenceLines = i18n( + "wizard.homepage_preview.topic_ops.what_books" + ) + .split(".")[0] + .split("\n"); + for (let i = 0; i < 2; i++) { + const line = height * 0.7 + i * (LINE_HEIGHT * 1.5); + ctx.fillText(opFirstSentenceLines[i], afterLogo, line); } } } diff --git a/app/assets/javascripts/discourse/app/static/wizard/components/fields/image.hbs b/app/assets/javascripts/discourse/app/static/wizard/components/fields/image.hbs index 88aa13d801f..de3591c9827 100644 --- a/app/assets/javascripts/discourse/app/static/wizard/components/fields/image.hbs +++ b/app/assets/javascripts/discourse/app/static/wizard/components/fields/image.hbs @@ -1,6 +1,9 @@