Better mobile UI

next
neobooru 2023-02-10 18:42:42 +01:00
parent cb25101b0b
commit 7aa65edd91
4 changed files with 16 additions and 6 deletions

View File

@ -118,7 +118,7 @@ async function uploadPost(data: PostUploadCommandData) {
} }
async function messageHandler(cmd: BrowserCommand): Promise<any> { async function messageHandler(cmd: BrowserCommand): Promise<any> {
console.log("Received message"); console.log("Background received message:");
console.dir(cmd); console.dir(cmd);
switch (cmd.name) { switch (cmd.name) {

View File

@ -12,4 +12,7 @@ export function isForbiddenUrl(url: string): boolean {
} }
export const isFirefox = navigator.userAgent.includes("Firefox"); export const isFirefox = navigator.userAgent.includes("Firefox");
export const isChrome = navigator.userAgent.match(/chrome|chromium|crios/i); export const isChrome = navigator.userAgent.match(/Chrome|Chromium/i);
// Based on https://stackoverflow.com/a/25394023
export const isMobile = navigator.userAgent.match(/Android/i);

View File

@ -16,7 +16,7 @@ import {
} from "~/models"; } from "~/models";
import SzuruWrapper from "~/api"; import SzuruWrapper from "~/api";
import { ImageSearchResult } from "~/api/models"; import { ImageSearchResult } from "~/api/models";
import { isChrome } from "~/env"; import { isChrome, isMobile } from "~/env";
import { Runtime, WebRequest } from "webextension-polyfill"; import { Runtime, WebRequest } from "webextension-polyfill";
import { Config } from "~/config"; import { Config } from "~/config";
@ -356,6 +356,9 @@ onMounted(async () => {
selectedSiteId.value = config.selectedSiteId; selectedSiteId.value = config.selectedSiteId;
browser.runtime.onMessage.addListener((cmd: BrowserCommand, _sender: Runtime.MessageSender) => { browser.runtime.onMessage.addListener((cmd: BrowserCommand, _sender: Runtime.MessageSender) => {
console.log("Popup received message:");
console.dir(cmd);
switch (cmd.name) { switch (cmd.name) {
case "set_post_upload_info": case "set_post_upload_info":
{ {
@ -500,7 +503,7 @@ useDark();
</ul> </ul>
</div> </div>
<div v-if="selectedPost" class="popup-columns"> <div v-if="selectedPost" class="popup-columns" :class="{ mobile: isMobile }">
<div class="popup-left"> <div class="popup-left">
<div class="popup-section"> <div class="popup-section">
<div class="section-header"> <div class="section-header">
@ -666,6 +669,10 @@ label {
.popup-columns { .popup-columns {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
&.mobile {
flex-direction: column-reverse;
}
} }
.popup-left { .popup-left {

View File

@ -1,11 +1,11 @@
import { createApp } from "vue"; import { createApp } from "vue";
import App from "./App.vue"; import App from "./App.vue";
import { setupApp } from "~/logic/common-setup"; import { setupApp } from "~/logic/common-setup";
import { isChrome } from "~/env"; import { isChrome, isMobile } from "~/env";
// Firefox automatically makes the popup as large as can be, Chrome doesn't. // Firefox automatically makes the popup as large as can be, Chrome doesn't.
// However setting the width to 780px gives us horizontal scrollbars on Firefox. // However setting the width to 780px gives us horizontal scrollbars on Firefox.
if (isChrome) { if (isChrome && !isMobile) {
document.documentElement.style.width = "780px"; document.documentElement.style.width = "780px";
} }