feat: reduce max tablet MQ size (#10669)
* feat: reduce max tablet MQ size * replace UIOptions.formFactor with getFormFactor
This commit is contained in:
@@ -16,7 +16,6 @@ export type EditorInterface = Readonly<{
|
|||||||
const DESKTOP_UI_MODE_STORAGE_KEY = "excalidraw.desktopUIMode";
|
const DESKTOP_UI_MODE_STORAGE_KEY = "excalidraw.desktopUIMode";
|
||||||
|
|
||||||
// breakpoints
|
// breakpoints
|
||||||
// mobile: up to 699px
|
|
||||||
export const MQ_MAX_MOBILE = 599;
|
export const MQ_MAX_MOBILE = 599;
|
||||||
|
|
||||||
export const MQ_MAX_WIDTH_LANDSCAPE = 1000;
|
export const MQ_MAX_WIDTH_LANDSCAPE = 1000;
|
||||||
@@ -24,9 +23,9 @@ export const MQ_MAX_HEIGHT_LANDSCAPE = 500;
|
|||||||
|
|
||||||
// tablets
|
// tablets
|
||||||
export const MQ_MIN_TABLET = MQ_MAX_MOBILE + 1; // lower bound (excludes phones)
|
export const MQ_MIN_TABLET = MQ_MAX_MOBILE + 1; // lower bound (excludes phones)
|
||||||
export const MQ_MAX_TABLET = 1400; // upper bound (excludes laptops/desktops)
|
export const MQ_MAX_TABLET = 1180; // ipad air
|
||||||
|
|
||||||
// desktop/laptop
|
// desktop/laptop (NOTE: not used for form factor detection)
|
||||||
export const MQ_MIN_WIDTH_DESKTOP = 1440;
|
export const MQ_MIN_WIDTH_DESKTOP = 1440;
|
||||||
|
|
||||||
// sidebar
|
// sidebar
|
||||||
|
|||||||
@@ -2780,7 +2780,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
|
|
||||||
private getFormFactor = (editorWidth: number, editorHeight: number) => {
|
private getFormFactor = (editorWidth: number, editorHeight: number) => {
|
||||||
return (
|
return (
|
||||||
this.props.UIOptions.formFactor ??
|
this.props.UIOptions.getFormFactor?.(editorWidth, editorHeight) ??
|
||||||
getFormFactor(editorWidth, editorHeight)
|
getFormFactor(editorWidth, editorHeight)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -2804,10 +2804,7 @@ class App extends React.Component<AppProps, AppState> {
|
|||||||
? this.props.UIOptions.dockedSidebarBreakpoint
|
? this.props.UIOptions.dockedSidebarBreakpoint
|
||||||
: MQ_RIGHT_SIDEBAR_MIN_WIDTH;
|
: MQ_RIGHT_SIDEBAR_MIN_WIDTH;
|
||||||
const nextEditorInterface = updateObject(this.editorInterface, {
|
const nextEditorInterface = updateObject(this.editorInterface, {
|
||||||
desktopUIMode:
|
desktopUIMode: storedDesktopUIMode ?? this.editorInterface.desktopUIMode,
|
||||||
this.props.UIOptions.desktopUIMode ??
|
|
||||||
storedDesktopUIMode ??
|
|
||||||
this.editorInterface.desktopUIMode,
|
|
||||||
formFactor: this.getFormFactor(editorWidth, editorHeight),
|
formFactor: this.getFormFactor(editorWidth, editorHeight),
|
||||||
userAgent: userAgentDescriptor,
|
userAgent: userAgentDescriptor,
|
||||||
canFitSidebar: editorWidth > sidebarBreakpoint,
|
canFitSidebar: editorWidth > sidebarBreakpoint,
|
||||||
|
|||||||
@@ -187,6 +187,9 @@ const areEqual = (prevProps: ExcalidrawProps, nextProps: ExcalidrawProps) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isUIOptionsSame = prevUIOptionsKeys.every((key) => {
|
const isUIOptionsSame = prevUIOptionsKeys.every((key) => {
|
||||||
|
if (key === "getFormFactor") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (key === "canvasActions") {
|
if (key === "canvasActions") {
|
||||||
const canvasOptionKeys = Object.keys(
|
const canvasOptionKeys = Object.keys(
|
||||||
prevUIOptions.canvasActions!,
|
prevUIOptions.canvasActions!,
|
||||||
|
|||||||
@@ -682,8 +682,10 @@ export type UIOptions = Partial<{
|
|||||||
* Optionally control the editor form factor and desktop UI mode from the host app.
|
* Optionally control the editor form factor and desktop UI mode from the host app.
|
||||||
* If not provided, we will take care of it internally.
|
* If not provided, we will take care of it internally.
|
||||||
*/
|
*/
|
||||||
formFactor?: EditorInterface["formFactor"];
|
getFormFactor?: (
|
||||||
desktopUIMode?: EditorInterface["desktopUIMode"];
|
editorWidth: number,
|
||||||
|
editorHeight: number,
|
||||||
|
) => EditorInterface["formFactor"];
|
||||||
/** @deprecated does nothing. Will be removed in 0.15 */
|
/** @deprecated does nothing. Will be removed in 0.15 */
|
||||||
welcomeScreen?: boolean;
|
welcomeScreen?: boolean;
|
||||||
}>;
|
}>;
|
||||||
|
|||||||
Reference in New Issue
Block a user