fix: More robust mobile and tablet detection

Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
Mark Tolmacs
2025-12-08 09:45:26 +00:00
parent 8d18078f5c
commit bfa4941ad1
3 changed files with 13 additions and 4 deletions
+7 -4
View File
@@ -1,3 +1,5 @@
import mobile from "is-mobile";
export type StylesPanelMode = "compact" | "full" | "mobile";
export type EditorInterface = Readonly<{
@@ -139,12 +141,13 @@ export const getFormFactor = (
editorWidth: number,
editorHeight: number,
): EditorInterface["formFactor"] => {
if (isMobileBreakpoint(editorWidth, editorHeight)) {
if (mobile()) {
return "phone";
}
if (isTabletBreakpoint(editorWidth, editorHeight)) {
} else if (mobile({ tablet: true })) {
return "tablet";
} else if (isMobileBreakpoint(editorWidth, editorHeight)) {
// NOTE: Very small editor sizes should be treated as phone
return "phone";
}
return "desktop";