Giter Site home page Giter Site logo

purplekingdomgames / tyrian Goto Github PK

View Code? Open in Web Editor NEW
315.0 9.0 23.0 18.21 MB

Elm-inspired Scala UI library.

Home Page: https://tyrian.indigoengine.io/

License: MIT License

Scala 97.98% Shell 0.49% HTML 0.55% JavaScript 0.49% Nix 0.49%
scala scalajs front-end-development scala-js ui tyrian elm-architecture

tyrian's People

Contributors

angel-o avatar armanbilge avatar battermann avatar chuwy avatar corem avatar daniel-ciocirlan avatar davesmith00000 avatar diesalbla avatar dlakomy avatar francosang avatar gitter-badger avatar gvolpe avatar hobnob avatar jmcclell avatar jonasackermann avatar jponte avatar julienrf avatar kristianan avatar ngbinh avatar salc2 avatar stevechy avatar toniogela avatar vdnhi avatar zetashift avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tyrian's Issues

Launch mechanism

When Indigo starts, instead of using main, you embed the game and invoke a launch method. The advantage of this is that you can supply (crude) flags (like command line args) during start up, as well as the ID of the element to hook onto.

Should Tyrian do a similar thing?

Add basic support for SSR

Should just be a case of providing a method you can call that performs the presentation work based on a given model. Then you could use the same codebase for SPA's or SSR.

Remove Cats

Cats core is currently a dependency, but unless I'm mistaken it is only there to provide some simple and wholly optional monoid syntax that is:

  1. Easily mimicked
  2. Literally not as nice as NOT using monoid operators in most cases.

So I'd prefer to ditch it and make Tyrian a zero dependancy lib for now. That doesn't rule out bringing it back if some future need arises. The home-grown Task implementation springs to mind.

Notice of intention to change licence type from BSD 3 to MIT (Scalm)

Dear former contributors to Scalm!

(According to github, that's: @julienrf, @salc2, and @battermann.)

As mentioned on the Scalm gitter account, I've forked the excellent (but seemingly abandoned) Scalm as I hope to use it in conjunction with Indigo. I've brought it up to date, converted it to Scala 3, and I've started changing the apis and internals in to suit my own purposes. I do plan to release it (why not?).

The current licence agreement specifically mentions Julien Richard-Foy and EPFL, and I'd like to switch across to an MIT licence and change the named people to be consistent with Indigo's licence agreement and representative of who is looking after this version of the project (the original will remain as-is).

I would appreciate it if you could respond with your approval, or indeed your objections.

I realise most of you haven't looked at Scalm for 3 years or so (which is part of the reason for the fork!) so if I don't hear from you within 30 days, I'll go ahead and assume I have your consent.

Thank you for building the project in the first place!

All the best,

Dave

HTML input value is not reflected on the view

It seems the value attribute of an input field is not correctly reflected on the view when the model changes.

case class Model(input: String)

input(`type` := "text", attribute("value", model.input))

The input field is updated either on Msg.SymbolChanged or reset (input = "") on Msg.Subscribe.

// view
input(`type` := "text", attribute("value", model.input), onInput(s => Msg.SymbolChanged(s)))

// update
case Msg.SymbolChanged(in) =>
  model.copy(input = in) -> Cmd.Empty

case Msg.Subscribe =>
  val nm  = model.copy(input = "")
  val cmd = model.ws.map(ws => Cmd.Batch(ws.publish(WsIn.Subscribe.asJson.noSpaces), refocusInput))
  nm -> cmd.getOrElse(Cmd.Empty)

Everytime the model is updated in the first message, I can see the HTML input value is updated (seeing this by inspecting the element in the browser). However, when the Subscribe message is handled and the input in the model is reset, the value attribute is properly reset as well, but the view remains with the previous value.

Here's an example from the trading application, right after clicking subscribe, where I first noticed the issue.

issue

The value attribute is reset but the view still shows the previously entered value "CHFEUR". I'd expect the input field to be cleared up as well.

Create a `TyrianApp` trait

Like Indigo, you can choose to just inherit a trait and it tells you when to do while implementing the initialisation for you in the background.

Support Anchor URL changes

window.onhashchange seems to be the mechanism, so I guess (and you could do this right now) you would subscribe the event (Sub) and send a Msg on change with the details, update your model, and render different contents.

Deprecate Hooks?

They're very Snabbdom specific, it's exposing a lot about the engines internals to allow it.

Allow 'no value' attributes to accept a predicate

In Elm, a field like hidden can be expressed as hidden(true|false) so that you can decide whether to use the hidden attribute in-line.

My also require the production of the notion of an empty attribute.

Indigo integration

Should direct support for Indigo be added so that Tyrian and easily embed and interact with Indigo games?

It's entirely possible to integrate Indigo games now but the experience is not slick, and there is no specialist machinery on either side to offer smooth communications from one to the other.

Since they are both Scala.js, could Tyrian invoke Indigo directly?

WebSockets / TyrianIndigoBride terminology change

Currently they have a send and a subscribe method. Should either be send and receive or publish and subscribe. I'm going with the latter because I can't spell receive without thinking about it excessively hard.

No way to declare doctype

I don't think we have a way to write:

<!DOCTYPE HTML>

On the off chance we want to generate whole pages via SSR.

Generate common styles

It would be nice to generate things like:

Style("font-family" -> "Arial, Helvetica, sans-serif")

..to help avoid the typos.

Review: Component/Child Code

There is the beginnings of a component pattern in Tyrian (inherited) that is not connected to anything, nor is it featured in the examples - not even the sub component example.

Suspect it's heading towards halogen style component nesting. It isn't needed for anything but we should decide what to do with it. Keep it and make it work, or remove it.

Replace Snabbdom

Snabbdom is the JS Virtual DOM implementation that powers Tyrian's rendering at the moment.

I'd like to investigate replacing it with a pure Scala.js Incremental DOM (or something).

The point of this is to make the SPA and SSR rendering happen via the same process.

Step one is to do the naive thing and just re-render on-change, and replace the innerHtml of the top level element completely. That will work (probably), but will be slow (probably, but is cheap memory-wise), everything after that is an optimisation.

  • We'll need a way to run tests in the browser so we can talk to a real DOM - there is a Scala.js selenium thing for that.
  • We could also do with figuring out a way to benchmark this compared a) to Snabbdom and b) to other solutions, like Elm and React. Don't need to be the fastest on the market but can't be appallingly slow either.

Improve Http Cmd

Missing request types:
PUT, DELETE, HEAD, OPTIONS

Other low hanging problems:

  1. All requests are missing the ability to supply headers
  2. Currently you have no opportunity to inspect the whole response, only interpret the body.

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.