Skip to content

Commit

Permalink
feat(pie-toast): DSW-2121 refactor getMessageMaxWidth for better read…
Browse files Browse the repository at this point in the history
…ability
  • Loading branch information
thejfreitas committed Jul 9, 2024
1 parent b172efc commit 6c81c95
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/components/pie-toast/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ export class PieToast extends RtlMixin(LitElement) implements ToastProps {
*
* @returns {number} - The width of the message in pixels.
*/
private getMessageMaxWidth (hasIcon: boolean, isMultiline: boolean, hasActionButton: boolean, hasCloseIcon: boolean): number {
private getMessageMaxWidth (
hasIcon: boolean,
isMultiline: boolean,
hasActionButton: boolean,
hasCloseIcon: boolean,
): number {
const iconOffset = 20;
const closeIconOffset = 32;
const gap = 8;
Expand All @@ -76,15 +81,15 @@ export class PieToast extends RtlMixin(LitElement) implements ToastProps {
let offset = 0;

if (hasIcon) {
offset = iconOffset + gap;
offset += iconOffset + gap;
}

if (!isMultiline && hasActionButton) {
offset = offset + this._actionButtonOffset + gap;
offset += this._actionButtonOffset + gap;
}

if (hasCloseIcon) {
offset = offset + closeIconOffset + gap;
offset += closeIconOffset + gap;
}

return toastMaxWidthWithoutPadding - offset;
Expand Down

0 comments on commit 6c81c95

Please sign in to comment.