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

Addon-docs: Fix fixed-position inline stories #11350

Merged
merged 13 commits into from
Sep 11, 2020
Merged

Conversation

frassinier
Copy link
Contributor

@frassinier frassinier commented Jun 29, 2020

Issue #8011

What I did

If you provide height to the story component it might want to deal with some fixed-positioned elements so we reset the position context.

How to test

  • Is this testable with Jest or Chromatic screenshots? yes, chromatic screenshots will be updated
  • Does this need a new example in the kitchen sink apps?
  • Does this need an update to the documentation? yes

@@ -34,12 +35,16 @@ type IFrameStoryProps = CommonProps;

type StoryProps = InlineStoryProps | IFrameStoryProps;

const InlineStory: FunctionComponent<InlineStoryProps> = ({ storyFn, height, id }) => (
const InlineStory: FunctionComponent<InlineStoryProps> = ({ storyFn, height, id = uuidv4() }) => (
Copy link
Contributor

Choose a reason for hiding this comment

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

Can id be undefined ? Seems weird ?

Appart from this, I don't think you need uuid for this. This adds another dependency for something simple. Interesting reading about it
Math.round(Math.random() * 1e5) will be enough, unless someone plans to have that many story, we can take the risk of having the same id twice :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it can be undefined, using InlineStory directly, that's why!
Really interesting reading and I'm not against removing this extra dependency (even if it's already used in other packages)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the explanation ;)
I'm sure we can apply the same logic for other use of uuid.

lib/components/src/blocks/Story.tsx Outdated Show resolved Hide resolved
Comment on lines 43 to 47
<div className={`story--${id}`}>
<Fragment>
{storyFn ? createElement(storyFn) : <EmptyBlock>{MISSING_STORY(id)}</EmptyBlock>}
</Fragment>
</div>
Copy link
Member

Choose a reason for hiding this comment

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

There's no way to do this without the extra <div>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see how actually but this Fragment is not necessary anymore if we keep this extra div 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ndelangen Can it fit as it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ndelangen any concerns?

Copy link
Member

Choose a reason for hiding this comment

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

WDYT @shilman, any concerns?

@ndelangen
Copy link
Member

I do fear the extra div is a change that will bite us later..
@shilman got an opinion on this? Do we have another plan to address this issue of height & width for previews in docs?

@shilman shilman added this to the 6.1 docs milestone Aug 17, 2020
@tooppaaa
Copy link
Contributor

tooppaaa commented Aug 17, 2020

What about an absolute div before the story with the given constraints ?

I assume setting the parent of stories relative is no-impact or at least something we can explain.

<>
<div style={{ minHeight, position: "absolute", top: 0, left: 0 }} />
{storyFn()}
</>

@stale
Copy link

stale bot commented Sep 7, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Sep 7, 2020
@tooppaaa
Copy link
Contributor

tooppaaa commented Sep 7, 2020

@ndelangen @frassinier any opinion on my potential solution ?

@stale stale bot removed the inactive label Sep 7, 2020
@frassinier
Copy link
Contributor Author

@tooppaaa I'm personally against using absolute position when it's not necessary but thank you for the proposal. I can rework it for resetting the z-index context for each story instead...

@frassinier frassinier force-pushed the fix/addon-docs/fixed-position branch from 1f5e1b3 to afd88b4 Compare September 10, 2020 15:44
Copy link
Contributor

@tooppaaa tooppaaa left a comment

Choose a reason for hiding this comment

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

Looks good ! ✔️

@frassinier
Copy link
Contributor Author

Wait Clément still in progress 🤞

@frassinier frassinier requested a review from usulpro as a code owner September 10, 2020 23:56
@frassinier
Copy link
Contributor Author

@tooppaaa, @ndelangen, and @shilman 👋 I hope it will fit this time, I can't do it simpler!

@frassinier
Copy link
Contributor Author

@shilman shilman changed the title fix(addon-docs): stories with min-height Addon-docs: Fix fixed-position inline stories Sep 11, 2020
Copy link
Member

@shilman shilman left a comment

Choose a reason for hiding this comment

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

LGTM -- great work!!

@shilman shilman merged commit 6015f51 into next Sep 11, 2020
@shilman shilman deleted the fix/addon-docs/fixed-position branch September 11, 2020 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants