PepeElToro41 / ui-labs

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

Vide Support #29

Closed PepeElToro41 closed 2 months ago

PepeElToro41 commented 3 months ago

Native support for Vide

This should be simple as the fusion system is already in place, it should be similar.

Problem:

I have no idea how to use Vide

Edit: I know how to use vide, and Im considering moving to it. So new vide story is coming :))

Olaroll commented 3 months ago

Still quite new to both Vide and UI Labs, but I figured out how to make a story constructor function. Gonna leave it here in case it helps you or anyone else stumbling on this.

Code ```luau local ReplicatedStorage = game:GetService("ReplicatedStorage") local UILabs = require(ReplicatedStorage.UILabs) local Vide = require(ReplicatedStorage.Packages.Vide) local function createVideStory(component: (T) -> Instance, controls: T?) local function render(props) if not controls then controls = {} end local states = UILabs.CreateControlStates( props.converted, props.controls, function(value) return Vide.source(value) end ) props.subscribe(function(values) UILabs.UpdateControlStates( states, props.converted, values, function(state, value) state(value) end ) end) local destroy = Vide.mount(function() local instance = component(states) Vide.cleanup(instance) return instance end, props.target) return destroy end return { controls = controls, render = render, } end ```
PepeElToro41 commented 2 months ago

Vide is now added in version 1.3.0