Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sheet] build sheet component #1250

Merged
merged 1 commit into from
May 6, 2019
Merged

[Sheet] build sheet component #1250

merged 1 commit into from
May 6, 2019

Conversation

danrosenthal
Copy link
Contributor

@danrosenthal danrosenthal commented Mar 26, 2019

Reviewers

⚠️ This PR is now ready for review. The only outstanding work needed is improving the existing example, which will be done before merging. Reviewers should not wait on that example to provide review.

Sheet

A sheet is a large container that enters from the edge of the screen when triggered by the merchant. It’s used to provide merchants with actions and information contextual to the page. It doesn’t interrupt their flow like a modal.

implementation in web playground desktop playground mobile
sheet-web sheet-playground sheet-playground-mobile

Approach

While I previously planned on allowing this component to be used with an embedded application by delegating rendering to the App Bridge, we have decided to wait on implementing that functionality. So, for now this component is for use only within a standalone application, and will not return markup and will throw a warning if it is not rendered inside the Frame component.

This results in a simpler implementation, and allows us to give more thought to whether and how we want to enable use in an embedded context.

Playground

import * as React from 'react';
import {
  Page,
  Sheet,
  Button,
  Frame,
  AppProvider,
  TopBar,
  Card,
  TextField,
} from '../src';

interface State {
  sheetActive: boolean;
  value: string;
}

export default class Playground extends React.Component<{}, State> {
  state: State = {
    sheetActive: false,
    value: '',
  };

  render() {
    const theme = {
      colors: {
        topBar: {
          background: '#357997',
        },
      },
      logo: {
        width: 124,
        topBarSource:
          'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-color.svg?6215648040070010999',
        contextualSaveBarSource:
          'https://cdn.shopify.com/s/files/1/0446/6937/files/jaded-pixel-logo-gray.svg?6215648040070010999',
        url: 'http://jadedpixel.com',
        accessibilityLabel: 'Jaded Pixel',
      },
    };

    const {sheetActive, value} = this.state;
    return (
      <AppProvider theme={theme}>
        <Frame topBar={<TopBar />}>
          <Page title="Sheet">
            <Card sectioned>
              <Button onClick={this.handleToggleSheet}>
                {sheetActive ? 'Close sheet' : 'Open sheet'}
              </Button>
            </Card>
            <Sheet open={sheetActive} onClose={this.handleCloseSheet}>
              <TextField
                label="form"
                onChange={this.handleTextChange}
                value={value}
              />
            </Sheet>
          </Page>
        </Frame>
      </AppProvider>
    );
  }

  handleOpenSheet = () => {
    this.setState({sheetActive: true});
  };

  handleCloseSheet = () => {
    this.setState({sheetActive: false});
  };

  handleTextChange = (value: string) => {
    return this.setState({value});
  };

  handleToggleSheet = () => {
    const {sheetActive} = this.state;

    if (sheetActive) {
      this.handleCloseSheet();
    } else {
      this.handleOpenSheet();
    }
  };
}

@danrosenthal danrosenthal changed the title [Sheet] build sheet component [WIP][Sheet] build sheet component Mar 26, 2019
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 26, 2019 12:59 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 26, 2019 13:02 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 26, 2019 14:09 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 26, 2019 14:17 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 26, 2019 14:21 Inactive
@danrosenthal
Copy link
Contributor Author

danrosenthal commented Mar 26, 2019

@gf3 @Shopify/app-bridge @tmlayton

I plan on making this new component available shortly. The plan is to also make it available through the AppBridge in an implementation similar to Modal, using a src prop that takes an iframe. Reason being is this component covers the application frame, so its rendering will need to be a concern of the Frame component.

I'm pinging you to let you know my intent, and to get eyes on the plan I've outlined in the original comment at the top of this PR. If you wouldn't mind taking a look at the plan and calling out anything I've missed, I would hugely appreciate it. Also, as I've never added any new features to the AppBridge codebase before, if there's anything I need to look out for, I'd appreciate a heads up.

Thanks in advance!

@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 26, 2019 15:33 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 26, 2019 17:34 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 26, 2019 17:44 Inactive
@danrosenthal danrosenthal force-pushed the sheet branch 2 times, most recently from a625cc8 to cc58c3e Compare March 26, 2019 17:49
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 26, 2019 17:49 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 26, 2019 17:52 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 26, 2019 21:06 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 27, 2019 13:09 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 27, 2019 13:12 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 27, 2019 13:14 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 March 28, 2019 16:31 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 April 1, 2019 19:55 Inactive
Copy link
Contributor

@keyfer keyfer left a comment

Choose a reason for hiding this comment

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

Couple small things but this looks great.

@BPScott BPScott temporarily deployed to polaris-react-pr-1250 May 3, 2019 15:19 Inactive
@danrosenthal
Copy link
Contributor Author

danrosenthal commented May 3, 2019

I've added an updated example that I feel a lot better about:

Example
Screen Shot 2019-05-03 at 11 20 46 AM

@BPScott BPScott temporarily deployed to polaris-react-pr-1250 May 3, 2019 15:22 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 May 3, 2019 15:31 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 May 3, 2019 15:32 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 May 3, 2019 15:59 Inactive
@BPScott BPScott temporarily deployed to polaris-react-pr-1250 May 3, 2019 17:10 Inactive
@danrosenthal
Copy link
Contributor Author

up to date docs screenshot
screencapture-polaris-myshopify-io-components-overlays-sheet-2019-05-03-15_15_57

Copy link
Contributor

@ry5n ry5n left a comment

Choose a reason for hiding this comment

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

Tophatted on Web and iOS simulator. I noticed some issues that stem from Storybook, but are not present when this component is tophatted in Web. So, looks good to me. I opened a separate issue to look into the issues stemming from Storybook.

Copy link
Contributor

@yourpalsonja yourpalsonja left a comment

Choose a reason for hiding this comment

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

Hey Dan, nothing blocking, just some thoughts!

@BPScott BPScott requested a deployment to polaris-react-pr-1250 May 6, 2019 18:07 Abandoned
@BPScott BPScott requested a deployment to polaris-react-pr-1250 May 6, 2019 18:10 Abandoned
@danrosenthal danrosenthal merged commit 091a2fb into master May 6, 2019
@danrosenthal danrosenthal deleted the sheet branch May 6, 2019 18:16
@chloerice chloerice temporarily deployed to production May 8, 2019 19:57 Inactive
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.

9 participants