Code Monkey home page Code Monkey logo

ng's Introduction

NG

Widget based renderer for web application.

This project is written using pure typescript with no third party.

Tree shake is supported by default

Why use ng?

These are the reasons you should use ng for your next project

Write views using javascript only, I hate HTML

    import { Widget, Column } from "@ng";

    import { Scaffold, MaterialApp } from "@ng/material";

    export class HomeView extends Widget {
        build(context){
            return new Scaffold({
                body: MaterialApp({
                    appBar: new AppBar(),
                    home: new Column({
                        children: [],
                    }),
                }),
            });
        }
    }

Reactive Widgets with pure javascript

NG support reactive widget states

ValueNotifier

Listen to value change and rerender a widget. Make sure ValueListener is used for the deep child to prevent expensive rerendering

    import { ValueNotifier, ValueListener } from "@ng";

    export class HomeView extends Widget {
        /// Only the Text widget is rerendered

        counter = new ValueNotifier(0);

        build(context){
            return new Column({
                children: [
                    new ValueListener(this.counter, {
                        build: (context, value) => {
                            return new Text(value);
                        }
                    }),
                    new Button({
                        child: new Text("Click me"),
                        onClick: () => {
                            this.counter.value += 1;
                        }
                    })
                ]
            })
        }
    }

Observables

Observable use observables with list view

    import { Observable, ObservableWidget } from "@ng/reactive";

    const users = new Observable <User[]>([]);

    new ListView.reactive({
        observable: users,
        itemBuilder: (user) => {
            return new GestureDetector(new Text(user.username), {
                onClick: (event) => {
                    this.model.remove(user);
                },
            });
        },
    });

    new Button(new Text("Add new user"), {
        onClick: () => {
            this.users.add({ username: "Caleb is a genius" })
        }
    })

Styling made easier with js

    new Text("Hello world in NG", {
        style: {
            color: "red"
        },
    });

Theming

Provide theme information to child or parent widgets. Parent widgets are used as default for child predecessors

    import { ThemeData } from "@ng/widgets";

    new ThemeData(new Column({}), {
        theme: new Theme({
            iconTheme: new IconTheme({
                size: new Size(24, 24),
            }),
            textTheme: new TextTheme({
                largeText: new TextThemeData({
                    fontSize: 24,
                    fontFamily: 32,
                }),
            }),
        }),
    });

Development

Library still in development, join our open source community now or raise suggestions in the discussion tab

Project structures might change later in future Or restart project with more concise structure

ng's People

Contributors

oasismystre avatar

Stargazers

Lucky Victory avatar

Watchers

 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.