Code Monkey home page Code Monkey logo

kaboom-flex-ui's Introduction

Kaboom Flex UI

A modern UI library for kaboom.

Installation

npm i kaboom-flex-ui

Getting Started

Firstly, import the UI plugin and load it into kaboom.

import flexUIPlugin from "kaboom-flex-ui";

const k = kaboom({
    plugins: [ flexUIPlugin ]
});

Then, to create a UI you will have to call the makeUI function with a function that returns a UI element.

const mainMenu = k.makeUI(() => k.$box(
    {
        width: 500,
        height: 500,
        background: YELLOW
    },
    k.$text("Hello, World!")
));

After defining the UI you will have to add it the current scene using its add method.

mainMenu.add();

After a reload you should now see a yellow rectangle on your screen with the text "Hello, World!".

Docs

๐Ÿงฐ Functions

โš™๏ธ makeUI

Defines a UI function that takes a UI generator and returns an object with an add method.

Function Type
makeUI (generator: UIGenerator) => UIManager

Parameters:

  • generator: The UI generator function.

โš™๏ธ $box

Creates a UI box element with optional attributes and children elements. Creates a UI box element with specified attributes and optional children elements.

Function Type
$box { (...children: UIElement[]): UIBoxElement; (attrs: Partial<UIBoxAttributes>, ...children: UIElement[]): UIBoxElement; }

Parameters:

  • children: The children UI elements.
  • attrs: The attributes for the box element.
  • children: The children UI elements.

โš™๏ธ $box

Creates a UI box element with optional attributes and children elements. Creates a UI box element with specified attributes and optional children elements.

Function Type
$box { (...children: UIElement[]): UIBoxElement; (attrs: Partial<UIBoxAttributes>, ...children: UIElement[]): UIBoxElement; }

Parameters:

  • children: The children UI elements.
  • attrs: The attributes for the box element.
  • children: The children UI elements.

โš™๏ธ $box

Creates a UI box element with optional attributes and children elements. Creates a UI box element with specified attributes and optional children elements.

Function Type
$box { (...children: UIElement[]): UIBoxElement; (attrs: Partial<UIBoxAttributes>, ...children: UIElement[]): UIBoxElement; }

Parameters:

  • children: The children UI elements.
  • attrs: The attributes for the box element.
  • children: The children UI elements.

โš™๏ธ $text

Creates a UI text element with the specified text and optional attributes.

Function Type
$text (text: string, attrs?: Partial<UITextAttributes>) => UITextElement

Parameters:

  • text: The text content.
  • attrs: Optional attributes for the text element.

โš™๏ธ $button

Creates a UI button element with the specified text and attributes.

Function Type
$button (text: string, attrs: UIButtonAttributes) => UIBoxElement

Parameters:

  • text: The text content.
  • attrs: The attributes for the button element.

โš™๏ธ default

Function Type
default (ctx: KaboomCtx) => { readonly makeUI: (generator: UIGenerator) => UIManager; readonly $box: { (...children: UIElement[]): UIBoxElement; (attrs: Partial<...>, ...children: UIElement[]): UIBoxElement; }; readonly $button: (text: string, attrs: UIButtonAttributes) => UIBoxElement; readonly $text: (text: string, attrs?...

kaboom-flex-ui's People

Contributors

neverusedgithub avatar niceeli avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.