Skip to main content

Hoarcekat

Hoarcekat is a popular storybook plugin like Flipbook. Because of its popularity, its story format is supported by Flipbook so that you have an easier time migrating.

note

This guide assumes you are using Rojo to manage your source code. If you are not, the same steps apply; create the Storybook as a ModuleScript directly in Studio instead of as a file.

Creating the Storybook​

The main difference in how Flipbook and Hoarcekat handle stories is that Flipbook requires a Storybook file to know where your stories live. Create a new ProjectName.storybook.luau file at the root of your project:

Hoarcekat.storybook.luau
local Roact = require("@pkg/Roact")

return {
name = "Hoarcekat",
storyRoots = {
script.Parent,
},
packages = {
Roact = Roact,
},
}

The packages key tells Flipbook which UI library to use when rendering stories in this Storybook. Once this file is in place, the Storybook appears in Flipbook's sidebar and you can open your stories.

tip

If you have an older Storybook that uses roact = Roact instead of packages, that still works, since it maps to packages.Roact for backwards compatibility. Prefer packages for new Storybooks.

Migrating Stories​

A Hoarcekat story is a module that returns a bare function. The function receives the container Instance and returns an optional cleanup callback:

HelloWorldLabelBefore.story.luau
local Roact = require("@pkg/Roact")

local HelloWorldLabel = require("./HelloWorldLabel")

return function(target: Instance)
local element = Roact.createElement(HelloWorldLabel, {
name = "Flipbook",
})

local handle = Roact.mount(element, target)

return function()
Roact.unmount(handle)
end
end

Flipbook still runs this shape without changes, since the legacy format is automatically detected and handled. But to use Flipbook's controls and other story features, migrate to the standard format: a module returning a table with a story function. Because the Storybook already supplies packages.Roact, the story no longer needs to mount and unmount the component itself:

HelloWorldLabel.story.luau
local Roact = require("@pkg/Roact")

local HelloWorldLabel = require("./HelloWorldLabel")

return {
story = function()
return Roact.createElement(HelloWorldLabel, {
name = "Flipbook",
})
end,
}

From here you can add a summary, controls, and anything else from the Story Format.