Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/components/DropZone/DropZone.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ $dropzone-overlay-background-error: color('red', 'lighter');

.Container {
flex: 1;
display: flex;
justify-content: center;
align-items: center;

&.centerAlignChildren {
display: flex;
justify-content: center;
align-items: center;
}
}

.Overlay {
Expand Down
13 changes: 12 additions & 1 deletion src/components/DropZone/DropZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ export interface Props {
disabled?: boolean;
/** The child elements to render in the dropzone. */
children?: string | React.ReactNode;
/**
* Align child elements to the center of the dropzone.
* @default true
*/
centerAlignChildren?: boolean;
/** Allows a file to be dropped anywhere on the page */
dropOnPage?: boolean;
/** Sets the default file dialog state */
Expand Down Expand Up @@ -213,6 +218,7 @@ export class DropZone extends React.Component<CombinedProps, State> {
active,
overlay,
allowMultiple,
centerAlignChildren = true,
} = this.props;

const inputAttributes: object = {
Expand Down Expand Up @@ -286,6 +292,11 @@ export class DropZone extends React.Component<CombinedProps, State> {
</div>
) : null;

const containerClassnames = classNames(
styles.Container,
centerAlignChildren && styles.centerAlignChildren,
);

const dropZoneMarkup = (
<div ref={this.setNode} className={styles.DropZoneWrapper}>
<div
Expand All @@ -296,7 +307,7 @@ export class DropZone extends React.Component<CombinedProps, State> {
>
{dragOverlay}
{dragErrorOverlay}
<div className={styles.Container}>{children}</div>
<div className={containerClassnames}>{children}</div>
<VisuallyHidden>
<input {...inputAttributes} />
</VisuallyHidden>
Expand Down