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

Revamp core components storybook doc(pt. 4) #249

Merged

Conversation

chenesan
Copy link
Contributor

@chenesan chenesan commented Feb 6, 2020

Purpose

Same as #246 but for <List>, <Popover>, <Popup>, <SearchInput>, <Section>.

Some side notes:

  • Anchored <Popover> will show with incorrect top position in new storybook doc. I'll try to look into it in next PR.
  • Rewrite whole <Popup> example since popups as closable and default to closed because they will block the doc.

Changes

  • Update storybook example of List, Popover, Popup, SearchInput, Section.

Risk

None.

TODOs

@chenesan chenesan self-assigned this Feb 6, 2020
@chenesan chenesan added the doc label Feb 6, 2020
>
<Button
basic="Open popover"
onClick={handlePopoverOpen} />
Copy link
Contributor

Choose a reason for hiding this comment

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

我在本機端按 Open popover 沒有打開 popover 耶

Copy link
Contributor Author

Choose a reason for hiding this comment

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

拍謝 PR description 寫不夠清楚 XD" 其實有但它的 top 跑到下面去了。會在下一個 PR 修掉。

Anchored popover is a <Popover> wrapped with two HOCs:
`closable()(anchored()(Popover)`

Before this commit it will form following DOM structure:

```html
<body>
  <div class="gyp-base-layer">
    <div class="gyp-closable>
      <div class="gyp-popover gyp-popover--top">
    </div>
  </div>
</body>
```

`gyp-popover` is absolutely positioned, with `top` value which
is relative to its document top left corner. `gyp-closable` is
`position: fixed` with `width: 100vw` and `height: 100vh`.

It works when document is too short to scroll, such as previous
storybook doc canvas. But when the element triggering popover is
over the screen(i.e. we have to scroll to click it), the position
of anchored popover will be wrong because the `position: absoulte`
of `gyp-popover` is relative to `gyp-closable`, which is
`position: fixed`, so the `top` value is wrong.

The position of `gyp-popover` should always be relative to the
document. So in this fix we change the `closable` HOC code to change
DOM structure as:

```html
<body>
  <div class="gyp-base-layer">
    <div class="gyp-closable" />
    <div class="gyp-popover" />
  </div>
</body>
```

Let the `gyp-popover` be relative to `gyp-base-layer`, which is absolute
to `document.body`.

Note that this bug won't happen on Cloud2 since on Cloud2 the
`document.body` height is always `100vh`, which is not scrollable.
Copy link
Contributor

@zhusee2 zhusee2 left a comment

Choose a reason for hiding this comment

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

LGTM overall 👍

export default {
title: '@ichef/gypcrete|List',
component: List,
subcomponents: { ListRow },
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe also adds Section to props table?

title: '@ichef/gypcrete|Popover',
component: PurePopover,
subcomponents: {
'renderToLayer(closable(anchored(Popover))': Popover,
Copy link
Contributor

Choose a reason for hiding this comment

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

No props found for this component

I think that's because renderToLayer() HOC does not contain any prop type. We might need other ways to get those prop types out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@benny0642 benny0642 left a comment

Choose a reason for hiding this comment

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

LGTM

@chenesan chenesan changed the base branch from feature/core-docs-pt3 to project/update-core-components-storybook-doc February 14, 2020 07:03
@chenesan chenesan merged commit ea8fd9f into project/update-core-components-storybook-doc Feb 14, 2020
@chenesan chenesan deleted the feature/core-docs-pt4 branch February 14, 2020 07:05
@kyoyadmoon kyoyadmoon mentioned this pull request Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants