UX: Show fewer toolbar icons in mobile composer (#14621)

This commit is contained in:
Penar Musaraj 2021-10-18 10:16:10 -04:00 committed by GitHub
parent 70634198a4
commit 7a4a1744a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 23 deletions

View File

@ -64,7 +64,7 @@ let _createCallbacks = [];
class Toolbar {
constructor(opts) {
const { siteSettings } = opts;
const { site, siteSettings } = opts;
this.shortcuts = {};
this.context = null;
@ -129,29 +129,31 @@ class Toolbar {
action: (...args) => this.context.send("formatCode", args),
});
this.addButton({
id: "bullet",
group: "extras",
icon: "list-ul",
shortcut: "Shift+8",
title: "composer.ulist_title",
preventFocus: true,
perform: (e) => e.applyList("* ", "list_item"),
});
if (!site.mobileView) {
this.addButton({
id: "bullet",
group: "extras",
icon: "list-ul",
shortcut: "Shift+8",
title: "composer.ulist_title",
preventFocus: true,
perform: (e) => e.applyList("* ", "list_item"),
});
this.addButton({
id: "list",
group: "extras",
icon: "list-ol",
shortcut: "Shift+7",
title: "composer.olist_title",
preventFocus: true,
perform: (e) =>
e.applyList(
(i) => (!i ? "1. " : `${parseInt(i, 10) + 1}. `),
"list_item"
),
});
this.addButton({
id: "list",
group: "extras",
icon: "list-ol",
shortcut: "Shift+7",
title: "composer.olist_title",
preventFocus: true,
perform: (e) =>
e.applyList(
(i) => (!i ? "1. " : `${parseInt(i, 10) + 1}. `),
"list_item"
),
});
}
if (siteSettings.support_mixed_text_direction) {
this.addButton({

View File

@ -318,6 +318,28 @@ export default Controller.extend({
})
);
if (this.site.mobileView) {
options.push(
this._setupPopupMenuOption(() => {
return {
action: "applyUnorderedList",
icon: "list-ul",
label: "composer.ulist_title",
};
})
);
options.push(
this._setupPopupMenuOption(() => {
return {
action: "applyOrderedList",
icon: "list-ol",
label: "composer.olist_title",
};
})
);
}
options.push(
this._setupPopupMenuOption(() => {
return {
@ -679,6 +701,17 @@ export default Controller.extend({
});
});
},
applyUnorderedList() {
this.toolbarEvent.applyList("* ", "list_item");
},
applyOrderedList() {
this.toolbarEvent.applyList(
(i) => (!i ? "1. " : `${parseInt(i, 10) + 1}. `),
"list_item"
);
},
},
disableSubmit: or("model.loading", "isUploading", "isProcessingUpload"),

View File

@ -230,6 +230,9 @@
display: inline-block;
border-left: 1px solid var(--primary-low-mid);
margin: 0 0.25em;
.mobile-view & {
display: none;
}
}
.btn:focus {