-
-
Notifications
You must be signed in to change notification settings - Fork 49
fix: added the possibility of skipping lines for discord-embed titles #426
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adding the possibility of skipping lines if you use a textarea to insert text and problems of not giving more than one space
This property was making the content of the message go beyond the body of the embed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few pointers @eumarciel404, in case you make future contributions
Overall please make sure to follow the contribution guidelines: https://github.com/skyra-project/discord-components/blob/main/.github/CONTRIBUTING.md. I had to run the linter over the code which revealed some issues such as w
which is too short for a variable identifier and formatting was off.
@@ -388,18 +398,35 @@ export class DiscordEmbed extends LitElement implements DiscordEmbedProps, Light | |||
private parseTitle(title?: string) { | |||
if (!title) return null; | |||
|
|||
const words = title.split(' '); | |||
const el: (TemplateResult<1> | string)[] = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't strongly typed, hiding a bug at the end of the function (see below)
return el.map((wordOrHtmlTemplate) => { | ||
if (typeof wordOrHtmlTemplate === 'string') { | ||
return html`<span>${wordOrHtmlTemplate}</span>`; | ||
} | ||
|
||
return el; | ||
return wordOrHtmlTemplate; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In your code you typed word
(now wordOrHtmlTemplate
) as string
, I assume this was because it was typed as any
above. This hid a bug however, because in one of the code branches, it is not a string but an HTML TemplateResult with discord-custom-emoji
and in that case, it should not be wrapped with another TemplateResult holding a span
. By strictly typing el
this is revealed more clearly and you can add a typeof
check to ensure that only raw strings get wrapped with a span.
class="discord-embed-author-block" | ||
> | ||
<span class="discord-embed-author-block">${emojiParsedAuthorName}</span> | ||
</a>`, | ||
() => html`${emojiParsedAuthorName}` | ||
() => html`<span class="discord-embed-author-block">${emojiParsedAuthorName}</span>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You added inline styles here. That makes it harder for end-user customizability and we try to avoid them unless strictly necessary. I moved the styles to a class.
Ok, sorry, I'll follow the guide next time and I really forgot some details, I'll be on the lookout for future commits |
Adding the possibility of skipping lines if you use a textarea to insert text and problems of not giving more than one space