Skip to content

Commit 6bc4f7b

Browse files
committed
Fix undo toast rendering
When a long text is provided for the undo toast, the text gets mixed with the button. It was fiine for the close button as 'padding-right: 34px;' was just right for it. This PR moves to flex layout to make the toast more responsive. + Add 'display: flex' to the toast and to the undo button container + Remove the 'position: absolute' for the close and undo buttons so they get placed by the flex algo + add some margin-right to the undo button because it was to close of the text + Change the padding to '0px 12px' as 12px top and bottom is too much when the close and undo button are not placed absolutely Signed-off-by: Louis Chemineau <[email protected]>
1 parent 3ca4519 commit 6bc4f7b

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

l10n/messages.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ msgid ""
22
msgstr ""
33
"Content-Type: text/plain; charset=UTF-8\n"
44

5-
#: lib/toast.ts:192
5+
#: lib/toast.ts:193
66
msgid "Undo"
77
msgstr ""

lib/toast.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ export function showUndo(text: string, onUndo: Function, options?: ToastOptions)
188188
// Generate undo layout
189189
const undoContent = document.createElement('span')
190190
const undoButton = document.createElement('button')
191+
undoContent.classList.add('toast-undo-container')
191192
undoButton.classList.add('toast-undo-button')
192193
undoButton.innerText = t('Undo')
193194
undoContent.innerText = text

styles/toast.scss

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,22 @@
2828
background-color: var(--color-main-background);
2929
color: var(--color-main-text);
3030
box-shadow: 0 0 6px 0 var(--color-box-shadow);
31-
padding: 12px;
32-
padding-right: 34px;
31+
padding: 0px 12px;
3332
margin-top: 45px;
3433
position: fixed;
3534
z-index: 10100;
3635
border-radius: var(--border-radius);
36+
display: flex;
37+
align-items: center;
38+
39+
.toast-undo-container {
40+
display: flex;
41+
align-items: center;
42+
}
3743

3844
.toast-undo-button,
3945
.toast-close {
40-
position: absolute;
41-
top: 0;
42-
right: 0;
46+
position: static;
4347
overflow: hidden;
4448
box-sizing: border-box;
4549
min-width: 44px;
@@ -62,6 +66,7 @@
6266
$margin: 3px;
6367
margin: $margin;
6468
height: calc(100% - 2 * #{$margin});
69+
margin-left: 12px;
6570
}
6671

6772
&:hover, &:focus, &:active {

0 commit comments

Comments
 (0)