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

Allow implementing custom user-defined layouts #458

Open
sergeymorkovkin opened this issue Apr 4, 2023 · 8 comments
Open

Allow implementing custom user-defined layouts #458

sergeymorkovkin opened this issue Apr 4, 2023 · 8 comments

Comments

@sergeymorkovkin
Copy link

sergeymorkovkin commented Apr 4, 2023

Is your feature request related to a problem? Please describe.
Tried to integrate storybook in a custom layout, but couldn't.

Describe the solution you'd like
I want to be able to integrate partial components into my custom React Native layout.
For example,

  1. put storybook navigation in a user-defined drawer panel.
  2. render controls in the same ScrollView with a preview.

Describe alternatives you've considered

  1. Patch storybook sources, which is not a trivial task
  2. Rewrite layout from scratch (even then, components are not easily separable)

Are you able to assist bring the feature to reality?
Yes, possibly.

@dannyhw
Copy link
Member

dannyhw commented Apr 4, 2023

@sergeymorkovkin you could probably make something work with the current version. However I do have plans to extract the ui components to a package to make developing them easier which could have the side effect of making this easier.

If you wanted to make something work currently you could turn off the ui and send events from your own UI

import { addons } from '@storybook/addons';
import Events from '@storybook/core-events';
const channel = addons.getChannel();
channel.emit(Events.SET_CURRENT_STORY, { storyId });

getting the storyId can be achieved in a few ways

import { toId } from '@storybook/csf';
toId(kind, storyName)

Just providing this as an alternative but it would definitely be cool to make it more customizable.

@sergeymorkovkin
Copy link
Author

sergeymorkovkin commented Apr 4, 2023 via email

@dannyhw
Copy link
Member

dannyhw commented Apr 4, 2023

@sergeymorkovkin

  1. probably but I'd need to look into it
  2. that might be a little bit more involved, you can make something custom with events but I wouldn't necessarily suggest it https://github.com/storybookjs/react-native/blob/63756fc99113fb856488ba28af77b7739e3331f0/addons/ondevice-controls/src/hooks.ts

@sergeymorkovkin
Copy link
Author

@dannyhw Is there any update on this? Just rendering menu / actions / view separately could easily work, but everything is so tightly coupled in your transformer layout... Maybe, you could recommend some other approach we didn't even think of?

@dannyhw
Copy link
Member

dannyhw commented Jun 6, 2023

@sergeymorkovkin what do you mean by transformer layout?

@sergeymorkovkin
Copy link
Author

@dannyhw By transformer layout I mean animated transition between different representations when view is becoming smaller freeing up space for either menu or actions. I tried to decouple different components from one another, but couldn't achieve any success in 2 days.

@dannyhw
Copy link
Member

dannyhw commented Jun 6, 2023

@sergeymorkovkin well the plan is to refactor the ui into a separate package and that would probably enable extending the ui in custom ways however I just haven't gotten to that yet.

What you're asking is definitely do-able but its just that the UI was not designed to be split up into parts so it would likely be very custom.

Probably if I were to do it now I would set ondeviceUI as false then render the list of stories and the controls panel manually (Or the entire addons panel might be easier).

@sergeymorkovkin
Copy link
Author

@dannyhw Thanks for an advice - we'll look into this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants