PepeElToro41 / ui-labs

UI Labs is a storybook plugin for Roblox
https://pepeeltoro41.github.io/ui-labs/
68 stars 9 forks source link

UI Labs does not support controls functional stories #12

Closed imkylecat closed 4 months ago

imkylecat commented 4 months ago

Hello! I want to add controls to my codebase, which does not use a UI library like React or Roact. I use Horacekat as stories at the moment and want to move over, however functional stories with controls only error. Example:

local controls = {
    text = "Functional Story",
}

return {
    summary = "This story uses a function with a cleanup callback to create and mount the gui elements. This works similarly to Hoarcekat stories but also supports controls and other metadata. Check out the source to learn more",
    controls = controls,
    story = function(parent, props)
        local label = Instance.new("TextLabel")
        label.Text = props and props.controls and props.controls.text or "Text unknown"
        label.Font = Enum.Font.Gotham
        label.TextColor3 = Color3.fromRGB(0, 0, 0)
        label.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
        label.TextSize = 16
        label.AutomaticSize = Enum.AutomaticSize.XY

        local padding = Instance.new("UIPadding")
        padding.PaddingTop = UDim.new(0, 8)
        padding.PaddingRight = padding.PaddingTop
        padding.PaddingBottom = padding.PaddingTop
        padding.PaddingLeft = padding.PaddingTop
        padding.Parent = label

        label.Parent = parent

        return function()
            label:Destroy()
        end
    end,
}
PepeElToro41 commented 4 months ago

Hello!.

Controls are currently only supported for React/Roact stories.

However Fusion Stories, Iris Stories and Generic Stories (No library) are comming in the next update!