Skip to content
oprayingPublic

About

A pure-MoonBit UI framework for native and JavaScript, with a separate DOM host.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

opraying/ui

A UI framework for MoonBit, on native and js. The core has no FFI. The browser host is a separate js package that calls opraying/js.

Components, views, queries, and routers follow the same shape as opraying/effect-ui, without a JavaScript UI runtime. Reactivity comes from opraying/reactive. Native windows are opraying/ui-native.

Scripts

./scripts/ui-build.sh is the entry point: check and test. ./scripts/ci.sh is the full gate. ./scripts/new-app.sh scaffolds an example. Commands and invariants are in AGENTS.md.

Design

A view is data. A component updates a model and returns the next view. Signals from opraying/reactive patch a mounted node in place, so a text change does not rebuild the tree. The headless kit draws no pixels. A host, DOM or native, interprets the view.

Example

A component holds a model and returns a view. This fragment is the shape of the HTML tests; it renders without a browser:

struct Counter {
  count : Int32
}

fn hello() -> @Ui.UiComp[Unit, Counter, Unit, @Ui.NoEnv] {
  @UiHtml.component(
    "Counter",
    init=fn(ctx) { ctx.set({ count: 0 }) },
    update=fn(ctx, _) { ctx.set(ctx.model()) },
    view=fn(h, m) { @UiHtml.button(h).text_child("\{m.count}") },
  )
}

let html = @UiHtml.render_to_html_sync(hello(), ()).html()

examples/tasks is a task list with server rendering and a client. That example is the one to read for routes, views, and hydration.

Packages

Ui is the kernel: views, commands, queries, router, and virtualizer. UiHtml is HTML and markdown. UiKit is the headless widgets. UiTesting and UiDevTools run without a browser. UiDom mounts into a document and is js only.

License

Apache-2.0. Copyright the opraying contributors.

About

A pure-MoonBit UI framework for native and JavaScript, with a separate DOM host.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages