Skip to content

Conversation

@WillsonSmith
Copy link
Contributor

@WillsonSmith WillsonSmith commented Apr 22, 2021

WHY are these changes introduced?

Right now, DropZone has 4 sizes: small, medium, large, and extraLarge. These are calculated based on the width of the DropZone. These sizes determine the min-height of the component. This means you cannot have a DropZone that is narrower than the set height at a given size.

We have a case where we need the height to be narrower than what is automatically set by this component.

I've opened an issue about making this the default behaviour.

WHAT is this pull request doing?

This PR adds a prop variableHeight that skips the size calculation and makes the DropZone's height dependent on its children instead.

image

How to 🎩

🖥 Local development instructions
🗒 General tophatting guidelines
📄 Changelog guidelines

View the new "Drop zone with variable size" story in Storybook.

or

Copy-paste this code in playground/Playground.tsx:
import React from 'react';

import {Page, DropZone, Button, Stack} from '../src';

export function Playground() {
  function handleDrop() {}
  return (
    <Page title="Playground">
      <DropZone onDrop={handleDrop} variableHeight>
        <div
          style={{
            display: 'flex',
            justifyContent: 'center',
            alignItems: 'center',
            width: '100%',
            height: '100%',
          }}
        >
          <Stack vertical>
            <Button>Add file</Button>
            <span>Drop to upload</span>
          </Stack>
        </div>
      </DropZone>
    </Page>
  );
}

🎩 checklist

  • Tested on mobile
  • Tested on multiple browsers
  • Tested for accessibility
  • Updated the component's README.md with documentation changes
  • Tophatted documentation changes in the style guide
  • For visual design changes, pinged one of @ HYPD, @ mirualves, @ sarahill, or @ ry5n to update the Polaris UI kit

@WillsonSmith WillsonSmith changed the title [DropZone] Add prop to allow DropZone children to control its height [DropZone] Add prop to DropZone so children control its height Apr 22, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Apr 22, 2021

🟢 No significant changes to src/**/*.tsx were detected.

@WillsonSmith
Copy link
Contributor Author

cc/ @CarlGranstrom @sjreive @rdott @pt8o

Comment on lines +155 to +158
if (variableHeight) {
setMeasuring(false);
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a quick test we can add for this? Looking good Willson!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added test 👍

Copy link
Member

@kyledurand kyledurand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 Good call Willson, thanks! 🥇

@WillsonSmith WillsonSmith merged commit 0ab8233 into main Apr 23, 2021
@WillsonSmith WillsonSmith deleted the dropzone-variable-height branch April 23, 2021 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants