mirror of
https://github.com/discourse/discourse.git
synced 2025-01-16 05:02:41 +08:00
FIX: Wizard improvements post-merge part 1 (#30612)
* FIX: Wizard improvements post-merge part 1
Followup 3135f472e2
Fixes the following:
* On mobile, the Styling step was very narrow
* When clicking Next on the Styling step after previously
selecting Hot, we got an error
Also makes the following UX improvements for the preview:
* Use different topic titles for Latest and Hot
* Also make Hot view and reply numbers higher
This helps differentiate the two previews.
* DEV: Review fixes
This commit is contained in:
parent
8185770d63
commit
c1a46995a7
|
@ -28,7 +28,14 @@ export default class HomepagePreview extends PreviewBaseComponent {
|
||||||
|
|
||||||
if (homepageStyle === "latest" || homepageStyle === "hot") {
|
if (homepageStyle === "latest" || homepageStyle === "hot") {
|
||||||
this.drawPills(colors, font, height * 0.15, { homepageStyle });
|
this.drawPills(colors, font, height * 0.15, { homepageStyle });
|
||||||
this.renderNonCategoryHomepage(ctx, colors, font, width, height);
|
this.renderNonCategoryHomepage(
|
||||||
|
ctx,
|
||||||
|
colors,
|
||||||
|
font,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
homepageStyle
|
||||||
|
);
|
||||||
} else if (
|
} else if (
|
||||||
["categories_only", "categories_with_featured_topics"].includes(
|
["categories_only", "categories_with_featured_topics"].includes(
|
||||||
homepageStyle
|
homepageStyle
|
||||||
|
@ -352,6 +359,15 @@ export default class HomepagePreview extends PreviewBaseComponent {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHotTitles() {
|
||||||
|
return [
|
||||||
|
i18n("wizard.homepage_preview.topic_titles.what_hobbies"),
|
||||||
|
i18n("wizard.homepage_preview.topic_titles.what_music"),
|
||||||
|
i18n("wizard.homepage_preview.topic_titles.funniest_thing"),
|
||||||
|
i18n("wizard.homepage_preview.topic_titles.share_art"),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
getDescriptions() {
|
getDescriptions() {
|
||||||
return [
|
return [
|
||||||
i18n("wizard.homepage_preview.category_descriptions.icebreakers"),
|
i18n("wizard.homepage_preview.category_descriptions.icebreakers"),
|
||||||
|
@ -360,7 +376,7 @@ export default class HomepagePreview extends PreviewBaseComponent {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
renderNonCategoryHomepage(ctx, colors, font, width, height) {
|
renderNonCategoryHomepage(ctx, colors, font, width, height, homepageStyle) {
|
||||||
const rowHeight = height / 6.6;
|
const rowHeight = height / 6.6;
|
||||||
// accounts for hard-set color variables in solarized themes
|
// accounts for hard-set color variables in solarized themes
|
||||||
const textColor =
|
const textColor =
|
||||||
|
@ -418,7 +434,10 @@ export default class HomepagePreview extends PreviewBaseComponent {
|
||||||
|
|
||||||
ctx.font = `${bodyFontSize}em '${font}'`;
|
ctx.font = `${bodyFontSize}em '${font}'`;
|
||||||
ctx.lineWidth = 1;
|
ctx.lineWidth = 1;
|
||||||
this.getTitles().forEach((title) => {
|
|
||||||
|
const titles =
|
||||||
|
homepageStyle === "hot" ? this.getHotTitles() : this.getTitles();
|
||||||
|
titles.forEach((title) => {
|
||||||
const textPos = y + rowHeight * 0.4;
|
const textPos = y + rowHeight * 0.4;
|
||||||
ctx.fillStyle = colors.primary;
|
ctx.fillStyle = colors.primary;
|
||||||
ctx.fillText(title, cols[0], textPos);
|
ctx.fillText(title, cols[0], textPos);
|
||||||
|
@ -448,10 +467,18 @@ export default class HomepagePreview extends PreviewBaseComponent {
|
||||||
|
|
||||||
ctx.fillStyle = textColor;
|
ctx.fillStyle = textColor;
|
||||||
ctx.font = `${bodyFontSize}em '${font}'`;
|
ctx.font = `${bodyFontSize}em '${font}'`;
|
||||||
for (let j = 2; j <= 4; j++) {
|
for (let colIndex = 2; colIndex <= 4; colIndex++) {
|
||||||
|
// Give Hot a higher range of random values to make it look like
|
||||||
|
// more activity is happening.
|
||||||
|
const randomValue =
|
||||||
|
homepageStyle === "hot"
|
||||||
|
? Math.floor(Math.random() * (660 - 220) + 220) + 10
|
||||||
|
: Math.floor(Math.random() * 90) + 10;
|
||||||
|
|
||||||
ctx.fillText(
|
ctx.fillText(
|
||||||
j === 4 ? "1h" : Math.floor(Math.random() * 90) + 10,
|
// Last column is relative activity time, others are random numbers.
|
||||||
cols[j] + margin,
|
colIndex === 4 ? "1h" : randomValue,
|
||||||
|
cols[colIndex] + margin,
|
||||||
y + rowHeight * 0.6
|
y + rowHeight * 0.6
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,10 @@ body.wizard {
|
||||||
&.styling {
|
&.styling {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
width: auto;
|
width: auto;
|
||||||
|
|
||||||
|
@include breakpoint("mobile-extra-large") {
|
||||||
|
width: 95%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +205,7 @@ body.wizard {
|
||||||
margin-right: 1em;
|
margin-right: 1em;
|
||||||
|
|
||||||
@media only screen and (max-width: 925px) {
|
@media only screen and (max-width: 925px) {
|
||||||
width: 80%;
|
width: 100%;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
@ -297,6 +301,10 @@ body.wizard {
|
||||||
&__step-contents {
|
&__step-contents {
|
||||||
min-height: 37em;
|
min-height: 37em;
|
||||||
margin-bottom: 2em;
|
margin-bottom: 2em;
|
||||||
|
|
||||||
|
@include breakpoint("mobile-extra-large") {
|
||||||
|
min-height: 30em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__step-form {
|
&__step-form {
|
||||||
|
|
|
@ -7515,6 +7515,10 @@ en:
|
||||||
what_movies: "What movies have you seen recently?"
|
what_movies: "What movies have you seen recently?"
|
||||||
random_fact: "Random fact of the day"
|
random_fact: "Random fact of the day"
|
||||||
tv_show: "Recommend a TV show"
|
tv_show: "Recommend a TV show"
|
||||||
|
what_hobbies: "What are your hobbies?"
|
||||||
|
what_music: "What are you listening to right now?"
|
||||||
|
funniest_thing: "Funniest thing you've seen today"
|
||||||
|
share_art: "Share your art!"
|
||||||
topic_ops:
|
topic_ops:
|
||||||
what_books: |
|
what_books: |
|
||||||
We all love to read, let's use this topic to share our
|
We all love to read, let's use this topic to share our
|
||||||
|
|
|
@ -219,10 +219,11 @@ class Wizard
|
||||||
updater.update_setting(:heading_font, updater.fields[:heading_font])
|
updater.update_setting(:heading_font, updater.fields[:heading_font])
|
||||||
|
|
||||||
top_menu = SiteSetting.top_menu_map
|
top_menu = SiteSetting.top_menu_map
|
||||||
if %w[latest hot].include?(updater.fields[:homepage_style]) &&
|
if %w[latest hot].include?(updater.fields[:homepage_style])
|
||||||
top_menu.first != updater.fields[:homepage_style]
|
if top_menu.first != updater.fields[:homepage_style]
|
||||||
top_menu.delete(updater.fields[:homepage_style])
|
top_menu.delete(updater.fields[:homepage_style])
|
||||||
top_menu.insert(0, updater.fields[:homepage_style])
|
top_menu.insert(0, updater.fields[:homepage_style])
|
||||||
|
end
|
||||||
elsif updater.fields[:homepage_style] != "latest"
|
elsif updater.fields[:homepage_style] != "latest"
|
||||||
top_menu.delete("categories")
|
top_menu.delete("categories")
|
||||||
top_menu.insert(0, "categories")
|
top_menu.insert(0, "categories")
|
||||||
|
|
|
@ -299,6 +299,43 @@ RSpec.describe Wizard::StepUpdater do
|
||||||
expect(SiteSetting.desktop_category_page_style).to eq("subcategories_with_featured_topics")
|
expect(SiteSetting.desktop_category_page_style).to eq("subcategories_with_featured_topics")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "updates top_menu if it doesn't match the new homepage_style and does nothing if it matches" do
|
||||||
|
SiteSetting.top_menu = "categories|new|latest"
|
||||||
|
|
||||||
|
updater =
|
||||||
|
wizard.create_updater(
|
||||||
|
"styling",
|
||||||
|
body_font: "arial",
|
||||||
|
heading_font: "arial",
|
||||||
|
homepage_style: "hot",
|
||||||
|
)
|
||||||
|
updater.update
|
||||||
|
expect(updater).to be_success
|
||||||
|
expect(SiteSetting.top_menu).to eq("hot|categories|new|latest")
|
||||||
|
|
||||||
|
updater =
|
||||||
|
wizard.create_updater(
|
||||||
|
"styling",
|
||||||
|
body_font: "arial",
|
||||||
|
heading_font: "arial",
|
||||||
|
homepage_style: "hot",
|
||||||
|
)
|
||||||
|
updater.update
|
||||||
|
expect(updater).to be_success
|
||||||
|
expect(SiteSetting.top_menu).to eq("hot|categories|new|latest")
|
||||||
|
|
||||||
|
updater =
|
||||||
|
wizard.create_updater(
|
||||||
|
"styling",
|
||||||
|
body_font: "arial",
|
||||||
|
heading_font: "arial",
|
||||||
|
homepage_style: "latest",
|
||||||
|
)
|
||||||
|
updater.update
|
||||||
|
expect(updater).to be_success
|
||||||
|
expect(SiteSetting.top_menu).to eq("latest|hot|categories|new")
|
||||||
|
end
|
||||||
|
|
||||||
it "does not overwrite top_menu site setting" do
|
it "does not overwrite top_menu site setting" do
|
||||||
SiteSetting.top_menu = "latest|unread|unseen|categories"
|
SiteSetting.top_menu = "latest|unread|unseen|categories"
|
||||||
updater =
|
updater =
|
||||||
|
|
Loading…
Reference in New Issue
Block a user