UX: Adjust styles for long words

This commit is contained in:
Jordan Vidrine 2025-01-14 11:30:13 -06:00
parent 2398ab4fe6
commit ff72e3ed37
3 changed files with 20 additions and 2 deletions

View File

@ -7,7 +7,7 @@ module DiscourseRewind
{ word: "what", score: 100 }, { word: "what", score: 100 },
{ word: "have", score: 90 }, { word: "have", score: 90 },
{ word: "you", score: 80 }, { word: "you", score: 80 },
{ word: "achieved", score: 70 }, { word: "overachieved", score: 70 },
{ word: "this", score: 60 }, { word: "this", score: 60 },
{ word: "week", score: 50 }, { word: "week", score: 50 },
], ],

View File

@ -3,6 +3,7 @@ import { on } from "@ember/modifier";
import { action } from "@ember/object"; import { action } from "@ember/object";
import didInsert from "@ember/render-modifiers/modifiers/did-insert"; import didInsert from "@ember/render-modifiers/modifiers/did-insert";
import { htmlSafe } from "@ember/template"; import { htmlSafe } from "@ember/template";
import concatClass from "discourse/helpers/concat-class";
import emoji from "discourse/helpers/emoji"; import emoji from "discourse/helpers/emoji";
import discourseLater from "discourse-common/lib/later"; import discourseLater from "discourse-common/lib/later";
@ -45,6 +46,10 @@ export default class WordCard extends Component {
}; };
} }
get longWord() {
return this.args.word.length >= 7;
}
get cardStyle() { get cardStyle() {
return htmlSafe(`${this.randomStyle}; ${this.mysteryData.color};`); return htmlSafe(`${this.randomStyle}; ${this.mysteryData.color};`);
} }
@ -72,7 +77,10 @@ export default class WordCard extends Component {
<div <div
{{on "click" this.handleClick}} {{on "click" this.handleClick}}
{{on "mouseleave" this.handleLeave}} {{on "mouseleave" this.handleLeave}}
class="rewind-card__wrapper" class={{concatClass
"rewind-card__wrapper"
(if this.longWord "-long-word")
}}
style={{this.cardStyle}} style={{this.cardStyle}}
{{didInsert this.registerCardContainer}} {{didInsert this.registerCardContainer}}
role="button" role="button"

View File

@ -137,6 +137,16 @@
0 0 / 6px 6px, 0 0 / 6px 6px,
var(--secondary-low); var(--secondary-low);
} }
&.-long-word .rewind-card__title {
font-size: var(--font-0);
}
&.-long-word .rewind-card {
padding: 2px;
}
.rewind-card__title {
overflow-wrap: anywhere;
hyphens: auto;
}
.rewind-card__image { .rewind-card__image {
image-rendering: pixelated; image-rendering: pixelated;
} }