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

Storybook middleware #95

Open
qromp opened this issue May 12, 2022 · 2 comments
Open

Storybook middleware #95

qromp opened this issue May 12, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@qromp
Copy link

qromp commented May 12, 2022

It would be nice to have a storybook map stories if desired so developers don't have to wrap stories with context providers or something everytime they write stories.

Storybooks with a middleware would look like:

local function contextMiddleware(story)
	return function(controls)
		return Roact.createElement(Theme.Provider, {
			theme = ...,
		}, {
			Story = Roact.createElement(story, controls),
		})
	end
end

return {
	roact = Roact,
	middleware = contextMiddleware,
	storyRoots = {
		script.Parent,
	},
}

Stories:

return {
	story = function()
		return Roact.createElement(Theme.Consumer, {
			render = function(theme)
				return Roact.createElement("Frame", {
					BackgroundColor3 = theme.primary,
				})
			end,
		})
	end,
}
@passhley
Copy link
Collaborator

I actually really like this idea, I'm not sure how useful it would be outside of just this use case. But can definitely look into it.

@vocksel
Copy link
Collaborator

vocksel commented Jun 5, 2022

Yep I'm very into this. Probably won't be in a v1 but this is something that's very helpful when using RoactRodux since it allows you to implicitly wrap all of your stories in a StoreProvider

@vocksel vocksel added the enhancement New feature or request label Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants