-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add configuration options for full screen mode breakpoints
- Loading branch information
1 parent
ef785d3
commit 8caf29d
Showing
14 changed files
with
129 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
$base-size: 16; | ||
$px: (1 / $base-size) * 1em; | ||
$mobile-width-max: 750px; // Use real pixels here | ||
$mobile-width-min: $mobile-width-max + 1px; // Use real pixels here | ||
$mobile-height-max: 420px; // Use real pixels here | ||
$mobile-height-min: $mobile-height-max + 1px; // Use real pixels here | ||
$desktop-short-height: 700px; // Use real pixels here | ||
$short-mode-height-max: 700px; // Use real pixels here | ||
$modal-bg-z-index: 1; | ||
$file-gutter: 5; | ||
$controls-padding: 15; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...onents/widgets/widgetBase/WidgetBase.scss → ...onents/internal/UploadWidgetInternal.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
lib/src/components/widgets/uploadWidget/components/internal/UploadWidgetInternal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { ReactNode } from "@bytescale/upload-widget/modules/common/React"; | ||
import { JSX } from "preact"; | ||
import cn from "classnames"; | ||
import "./UploadWidgetInternal.scss"; | ||
import { UploadWidgetLayout } from "@bytescale/upload-widget/config/UploadWidgetLayout"; | ||
import { UploadWidgetInternalBorder } from "@bytescale/upload-widget/components/widgets/uploadWidget/components/internal/border/UploadWidgetInternalBorder"; | ||
import { modalCloseButtonPadding, modalCloseButtonSize } from "@bytescale/upload-widget/components/modal/Modal"; | ||
import { getElementDimensionsOnResize } from "@bytescale/upload-widget/modules/common/UseDimensionsFromElement"; | ||
|
||
interface Props { | ||
children: ReactNode; | ||
htmlProps?: any; | ||
isDraggable?: boolean; | ||
isDragging?: boolean; | ||
layout: UploadWidgetLayout; | ||
multi: boolean; | ||
} | ||
|
||
export const UploadWidgetInternal = ({ children, htmlProps, isDraggable, isDragging, layout }: Props): JSX.Element => { | ||
const [dimensions, containerRef] = getElementDimensionsOnResize(true, []); | ||
|
||
// Size is relative to the internal dimensions of the upload widget, as opposed to the screen. This caters for the | ||
// widget entering "full screen" mode when being shrunk, which causes the internal dimensions of the widget to become | ||
// larger. Hence, we measure these breakpoints based off the internal widget size, rather than the screen size. | ||
const internalBreakpoints = [ | ||
{ width: 650, value: "md" }, | ||
{ width: 930, value: "lg" } | ||
]; | ||
|
||
const lastBreakpoint = "xl"; | ||
const breakpoint = | ||
(dimensions === undefined ? undefined : internalBreakpoints.find(x => dimensions.width <= x.width)?.value) ?? | ||
lastBreakpoint; | ||
|
||
return ( | ||
<div | ||
ref={containerRef} | ||
className={cn("upload-widget__internal", `upload-widget__internal--${breakpoint}`, { | ||
"upload-widget__internal--draggable": isDraggable === true && layout !== "modal", | ||
"upload-widget__internal--dragging": isDragging === true && layout !== "modal" | ||
})} | ||
{...htmlProps}> | ||
{isDraggable === true && layout === "modal" && ( | ||
<UploadWidgetInternalBorder | ||
isDragging={isDragging === true} | ||
dimensions={dimensions} | ||
closeButtonSize={modalCloseButtonSize + modalCloseButtonPadding} | ||
/> | ||
)} | ||
<div | ||
className={cn("upload-widget__internal__children", { | ||
"upload-widget__internal__children--is-modal": layout === "modal" | ||
})}> | ||
{children} | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export interface UploadWidgetBreakpoints { | ||
fullScreenHeight?: number; | ||
fullScreenWidth?: number; | ||
} | ||
|
||
export interface UploadWidgetBreakpointsRequired { | ||
fullScreenHeight: number; | ||
fullScreenWidth: number; | ||
} | ||
|
||
export namespace UploadWidgetBreakpointsRequired { | ||
export function from(options: UploadWidgetBreakpoints | undefined): UploadWidgetBreakpointsRequired { | ||
return { | ||
fullScreenWidth: options?.fullScreenWidth ?? 750, | ||
fullScreenHeight: options?.fullScreenHeight ?? 420 | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters