Giter Club home page Giter Club logo

purescript-halogen-vdom's Introduction

Halogen

Latest release CI

Halogen is a type-safe library for building user interfaces in PureScript.

  • Declarative Write simple views for each state in your application, and Halogen will efficiently and intelligently update the right components and re-render your user interface.
  • Component Architecture Write encapsulated components which manage their own state, and compose them together to build complex user interfaces. Or, use a single component to implement an Elm-like architecture.
  • Entirely PureScript Halogen and its virtual DOM implementation are written in PureScript. Halogen's performance and bundle sizes are roughly equivalent to popular JavaScript UI libraries like React and Angular.

Read the documentation to learn how to use Halogen in your own projects.

Installation

Install Halogen with Spago:

spago install halogen

Or create a new Halogen app from a template.

Documentation

You can find the Halogen documentation on the documentation site or in the docs folder. Documentation is divided into several categories:

We also recommend these community resources for learning how to use Halogen in your applications:

There are several ways to get help if you get stuck using Halogen:

Examples

This repository contains several self-contained examples, ranging from a basic button to controlling external components.

You may also want to review the Real World Halogen example application, which demonstrates routing, state management, authentication, making requests, and other real world examples with commented explanations.

Contributing

The main purpose of this repository is to continue evolving Halogen, making it faster and easier to use. Halogen is developed in the open on GitHub and we're grateful for community-contributed bugfixes and improvements.

You can take part in improving Halogen by opening or participating in issues, opening pull requests to add new features, documentation, or tests, and by helping other Halogen users on Discord and Discourse.

License & Credits

Halogen is licensed under the Apache License 2.0. The Halogen logo was designed by Matthew Park.

purescript-halogen-vdom's People

Contributors

beckyconning avatar garyb avatar jordanmartinez avatar kritzcreek avatar natefaubion avatar rnons avatar thomashoneyman 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

purescript-halogen-vdom's Issues

Comparison between keyed node implementation and issues with iframes

I have an application that involves a list of embedded videos (in iframes) where the user can choose to hide any of them individually. I noticed that when I hid one of them, all the iframes after it in the list would get reloaded. Naturally I reached for a keyed node to solve this problem, but low and behold, it did not change anything. After talking with Nate Faubion on discord, it turns out that the current keyed node diffing algorithm still moves things around more than I expected it to, and when an iframe is moved, it gets reloaded. I learned functional UI in Elm originally, so this behavior surprised me. I checked if Elm behaved the way I expected it to, and it did. Nate said that the current algorithm was made not to minimize DOM manipulation, but to satisfy other design goals. I'm curious if getting this diffing on par with Elm, or at least fixing the iframe issue is something the project would currently be open to.

Comparisons

  • Elm
    • Removal: no reloads
    • Reorder: 1/3 reloaded
  • Halogen (the videos don't load but it doesn't matter for the demo, the black screens still flash white when they get reloaded)
    • Removal: All beneath are reloaded
    • Reorder: 2/3 reloaded

DOMException thrown when switching between file/text input types

I need to come up with a small reproduction case for this, but as an example of the error:

Uncaught DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.
    at ./output/Halogen.VDom.Util/foreign.js.exports.unsafeSetAny (http://localhost:3000/index.js:87081:14)
    at http://localhost:3000/index.js:86101:21
    at Object../output/Halogen.VDom.Util/foreign.js.exports.diffWithKeyAndIxE (http://localhost:3000/index.js:87156:15)
    at Step.patchProp [as value2] (http://localhost:3000/index.js:86133:40)
    at Object.step (http://localhost:3000/index.js:86664:14)
    at Step.patchElem [as value2] (http://localhost:3000/index.js:86273:43)
    at Object.step (http://localhost:3000/index.js:86664:14)
    at onThese (http://localhost:3000/index.js:86288:43)
    at Object../output/Halogen.VDom.Util/foreign.js.exports.diffWithIxE (http://localhost:3000/index.js:87124:17)
    at Step.patchElem [as value2] (http://localhost:3000/index.js:86297:36)

This is from a form where we have a switchable section, and so patching is reusing an input as both a password input and as a file input. Entering a value in the password field then switching back and forth resulted in the error.

I fixed it by keying the inputs so they would definitely not be shared, but it seems like something we should perhaps handle during patching rather than allowing it to explode at runtime.

why diffProp function gets most recent property value on "value" update?

here

_, "value" โ†’ do
let elVal = Fn.runFn2 unsafeGetProperty "value" el
if Fn.runFn2 Util.refEq elVal val2
then pure v2
else do
EFn.runEffectFn3 setProperty prop2 val2 el
pure v2

well, I kind of understand why, but still want to know the explanation

the other question is should we update other propNames this way?

for example react calls value, checked, selected the Controlled attributes and handles them differently (diffHydratedProperties)

Hydration

I have mentioned it here purescript-halogen/purescript-halogen#610 (comment)

just like for:

  1. https://reactjs.org/docs/react-dom.html#hydrate
  2. https://github.com/snabbdom/snabbdom/blob/master/src/tovnode.ts

The second link is just for reference. It builds VDOM from DOM node, but our hydrate method should

  1. take DOM element
  2. take VDOM element that contains event handlers
  3. add event handlers to the DOM elements recursively AND throw error if the content of the DOM element is different from the VDOM (for example the text or class property)

how to render and hydrate namespaces elements and attributes

Parse error for compiler version 0.13.x on v3.0.0 tag

Howdy. I was looking into whether the tag at v3.0.0 could run on 0.13.x. Looks like there's one small thing that doesn't parse. It should be a non-breaking change as it parses with both 0.12.x and 0.13.x (unless I'm forgetting something). Would you be willing to accept a PR for the change and push out a v3.0.1? If so, it looks like a branch has to be made starting at v3.0.0, then I should be able to make a PR. If not, no big.

Example is broken?

I tried to run the example, and the browser is complaining about how ENV is not defined. Looking at the FFI javascript:

exports.getData = function () {
  return ENV.generateData().toArray();
};

exports.getTimeout = function () {
  return ENV.timeout
};

exports.pingRenderRate = function () {
  Monitoring.renderRate.ping();
};

exports.requestAnimationFrame = function (f) {
  return function () {
    window.requestAnimationFrame(function () {
      f();
    });
  }
}

It seems that ENV is meant to be provided by the user, but for example generateData() doesn't appear anywhere else in the code. Being a newcomer to the library (and purescript in general), I'm not sure what it's supposed to do.

Externally managed HTML

I, on several occasions use third party libraries that manage HTML themselves (WYSIWYG editors, drag-drop, FontAwesome DOM watcher). I would like to define on the parent element of the elements managed by these libraries that any children should no longer be managed by the Halogen VDOM. So basically a node that is rendered by the VDOM and then never touched again. How can this be done with thunks/lazy, etc. or will it need a separate implementation?

Thanks!

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.