GithubHelp home page GithubHelp logo

synthphonic / ooui Goto Github PK

View Code? Open in Web Editor NEW

This project forked from praeclarum/ooui

0.0 1.0 0.0 1.81 MB

A small cross-platform UI library that brings the simplicity of native UI development to the web

License: MIT License

C# 95.51% JavaScript 2.43% CSS 0.99% HTML 1.07%

ooui's Introduction

Ooui Web Framework Build Status

Version Package Description
NuGet Package Ooui Core library with HTML elements and a server.
NuGet Package Ooui.Forms Xamarin.Forms backend using Ooui
NuGet Package Ooui.AspNetCore Integration with ASP.NET Core MVC

Ooui (pronounced weeee!) is a small cross-platform UI library for .NET that uses web technologies.

It presents a classic object-oriented UI API that controls a dumb browser. With Ooui, you get the full power of your favorite .NET programming language plus the ability to interact with your app using any device.

Try it Online

Head on over to http://ooui.mecha.parts to tryout the samples.

Try the Samples Locally

git clone [email protected]:praeclarum/Ooui.git
cd Ooui

dotnet restore
msbuild
dotnet run --project Samples/Samples.csproj --no-build

(There is currently an issue with Xamarin.Forms and building from the dotnet cli, so for now we use the msbuild command and then set the --no-build flag on dotnet run but this will eventually change when the issue is resolved.)

This will open the default starting page for the Samples. Now point your browser at http://localhost:8080/shared-button

You should see a button that tracks the number of times it was clicked. The source code for that button is shown in the example below.

Example Use

Here is the complete source code to a fully collaborative button clicking app.

using System;
using Ooui;

class Program
{
    static void Main(string[] args)
    {
        // Create the UI
        var button = new Button("Click me!");

        // Add some logic to it
        var count = 0;
        button.Click += (s, e) => {
            count++;
            button.Text = $"Clicked {count} times";
        };

        // Publishing makes an object available at a given URL
        // The user should be directed to http://localhost:8080/button
        UI.Publish ("/shared-button", button);

        // Don't exit the app until someone hits return
        Console.ReadLine ();
    }
}

Make sure to add a reference to Ooui before you try running!

dotnet add package Ooui

With just that code, the user will be presented with a silly counting button.

In fact, any number of users can hit that URL and start interacting with the same button. That's right, automatic collaboration!

If you want each user to get their own button, then you will instead Publish a function to create it:

Button MakeButton()
{
    var button = new Button("Click me!");
    var count = 0;
    button.Click += (s, e) => {
        count++;
        button.Text = $"Clicked {count} times";
    };
    return button;
}

UI.Publish("/button", MakeButton);

Now every user (well, every load of the page) will get their own button.

How it works

When the user requests a page, Ooui will connect to the client using a Web Socket. This socket is used to keep an in-memory model of the UI (the one you work with as a programmer) in sync with the actual UI shown to the user in their browser. This is done using a simple messaging protocol with JSON packets.

When the user clicks or otherwise interacts with the UI, those events are sent back over the web socket so that your code can deal with them.

Comparison

UI LibraryOouiXamarin.FormsASP.NET MVC
How big is it? 80 KB 850 KB 1,300 KB
Where does it run? Everywhere iOS, Android, Mac, Windows Everywhere
How do I make a button?
new Button()
new Button()
<button />
Does it use native controls? No, HTML5 controls Yes! HTML5 controls
What controls are available? All of those in HTML5 Xamarin.Forms controls All of those in HTML5
Which architecture will you force me to use? None, you're free MVVM MVC/MVVM
What's the templating language? C# XAML Razor
How do I style things? CSS baby! XAML resources CSS
Is there databinding? No :-( Yes! Debatable
Do I need to run a server? Nope Heck no Yes
Is it web scale? Yes? What's the web? Yes!

ooui's People

Contributors

jamesmontemagno avatar jsuarezruiz avatar lucecarter avatar praeclarum avatar samilamti 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.