Skip to content

Commit

Permalink
Override width for just this toast
Browse files Browse the repository at this point in the history
  • Loading branch information
dbkr committed Jan 16, 2025
1 parent 5bf0d2d commit 2c3896c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion res/css/structures/_ToastContainer.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Please see LICENSE files in the repository root for full details.
}

.mx_Toast_description {
max-width: 366px;
max-width: 272px;
overflow: hidden;
text-overflow: ellipsis;
margin: 4px 0 11px 0;
Expand Down
6 changes: 5 additions & 1 deletion src/components/views/toasts/GenericToast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ interface IPropsExtended extends IProps {
SecondaryIcon?: ComponentType<React.SVGAttributes<SVGElement>>;
destructive?: "primary" | "secondary";
onSecondaryClick(): void;

// If set, this will override the max-width (of the description) making the toast wider or narrower than standard
overrideWidth?: string;
}

const GenericToast: React.FC<XOR<IPropsExtended, IProps>> = ({
Expand All @@ -37,12 +40,13 @@ const GenericToast: React.FC<XOR<IPropsExtended, IProps>> = ({
destructive,
onPrimaryClick,
onSecondaryClick,
overrideWidth,
}) => {
const detailContent = detail ? <div className="mx_Toast_detail">{detail}</div> : null;

return (
<div>
<div className="mx_Toast_description">
<div className="mx_Toast_description" style={{ maxWidth: overrideWidth }}>
{description}
{detailContent}
</div>
Expand Down
1 change: 1 addition & 0 deletions src/toasts/SetupEncryptionToast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export const showToast = (kind: Kind): void => {
onPrimaryClick: onAccept,
secondaryLabel: getSecondaryButtonLabel(kind),
onSecondaryClick: onReject,
overrideWidth: kind === Kind.KEY_STORAGE_OUT_OF_SYNC ? "366px" : undefined,
},
component: GenericToast,
priority: kind === Kind.VERIFY_THIS_SESSION ? 95 : 40,
Expand Down

0 comments on commit 2c3896c

Please sign in to comment.