npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rbxts/vide

v0.3.5

Published

A reactive Luau library for creating UI

Downloads

431

Readme

Vide is a reactive Luau UI library inspired by Solid.

  • Fully Luau typecheckable
  • Declarative and concise syntax.
  • Reactively driven.

Getting started

Read the crash course for a quick introduction to the library.

Code sample

local create = vide.create
local source = vide.source

local function Counter()
    local count = source(0)

    return create "TextButton" {
        Text = function()
            return "count: " .. count()
        end,

        Activated = function()
            count(count() + 1)
        end
    }
end

JSX

Vide for roblox-ts brings JSX support to the library. As a result, this extension adds a set of components and utilities to improve usage.

[!TIP]

  • Vide JSX adds new components for syntax sugar, including <Show>, <Switch>/<Case>, <For>, and <Index>.
  • Use the ref prop to create a Vide action that gets the reference of the rendered element.
  • switch is a reserved keyword in TypeScript, so the switch() function is exposed under the alias match().

Installation

To use JSX with Vide, you need to configure the jsx option in your tsconfig.json:

"compilerOptions": {
    "jsx": "react",
    "jsxFactory": "Vide.jsx",
    "jsxFragmentFactory": "Vide.Fragment",
}

[!NOTE] Custom JSX factories are available in an unreleased version of roblox-ts. You can install it by running npm install -D roblox-ts@next.

Code sample

function Counter() {
    const count = source(0);

    return (
        <textbutton
            Text={() => `count: ${count()}`}
            TextChanged={(text) => print(text)}
            Activated={() => count(count() + 1)}
        />
    );
}

<Show>

A conditional rendering component that accepts a boolean value and a function that returns the element to render when the condition is true.

const show = source(true);

<Show when={show}>
    {() => <textbutton Text="Hello, world!" />}
</Show>;

<Switch>/<Case>

A conditional rendering component that accepts a value and a list of cases. Each case is denoted by a <Case> component, and if the condition matches the match prop of a case, the corresponding element is rendered.

const value = source("a");

<Switch condition={value}>
    <Case match="a">{() => <textbutton Text="A" />}</Case>
    <Case match="b">{() => <textbutton Text="B" />}</Case>
    <Case match="c">{() => <textbutton Text="C" />}</Case>
</Switch>;

<For>

A referentially keyed loop (rendered nodes are keyed to a table value). The each prop accepts an array or a map, and calls the children function for each element in the array or map.

If an entry is removed or changed, the corresponding node is updated or cleaned up.

const items = source(["a", "b", "c"]);

<For each={items}>
    {(item: string, index: () => number) => <textbutton Text={item} />}
</For>;

<Index>

A referentially keyed loop (rendered nodes are keyed to a table index). The each prop accepts an array or a map, and calls the children function for each element in the array or map.

If an entry is removed or changed, the corresponding node is updated or cleaned up.

const items = source(["a", "b", "c"]);

<Index each={items}>
    {(item: () => string, index: number) => <textbutton Text={() => item()} />}
</Index>;