first step toward Interactive UI

This commit is contained in:
Yann Esposito (Yogsototh) 2019-10-28 13:41:05 +01:00
parent 4791944568
commit 0880b6f04e
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
9 changed files with 280 additions and 0 deletions

1
ui/.envrc Normal file
View file

@ -0,0 +1 @@
use nix

10
ui/.gitignore vendored Normal file
View file

@ -0,0 +1,10 @@
/bower_components/
/node_modules/
/.pulp-cache/
/output/
/generated-docs/
/.psc-package/
/.psc*
/.purs*
/.psa*
/.spago

30
ui/index.js Normal file
View file

@ -0,0 +1,30 @@
// Generated by purs bundle 0.13.4
var PS = {};
(function(exports) {
"use strict";
exports.log = function (s) {
return function () {
console.log(s);
return {};
};
};
})(PS["Effect.Console"] = PS["Effect.Console"] || {});
(function($PS) {
// Generated by purs version 0.13.4
"use strict";
$PS["Effect.Console"] = $PS["Effect.Console"] || {};
var exports = $PS["Effect.Console"];
var $foreign = $PS["Effect.Console"];
exports["log"] = $foreign.log;
})(PS);
(function($PS) {
// Generated by purs version 0.13.4
"use strict";
$PS["Main"] = $PS["Main"] || {};
var exports = $PS["Main"];
var Effect_Console = $PS["Effect.Console"];
var main = Effect_Console.log("\ud83c\udf5d");
exports["main"] = main;
})(PS);
PS["Main"].main();

139
ui/packages.dhall Normal file
View file

@ -0,0 +1,139 @@
{-
Welcome to your new Dhall package-set!
Below are instructions for how to edit this file for most use
cases, so that you don't need to know Dhall to use it.
## Warning: Don't Move This Top-Level Comment!
Due to how `dhall format` currently works, this comment's
instructions cannot appear near corresponding sections below
because `dhall format` will delete the comment. However,
it will not delete a top-level comment like this one.
## Use Cases
Most will want to do one or both of these options:
1. Override/Patch a package's dependency
2. Add a package not already in the default package set
This file will continue to work whether you use one or both options.
Instructions for each option are explained below.
### Overriding/Patching a package
Purpose:
- Change a package's dependency to a newer/older release than the
default package set's release
- Use your own modified version of some dependency that may
include new API, changed API, removed API by
using your custom git repo of the library rather than
the package set's repo
Syntax:
Replace the overrides' "{=}" (an empty record) with the following idea
The "//" or "⫽" means "merge these two records and
when they have the same value, use the one on the right:"
-------------------------------
let override =
{ packageName =
upstream.packageName // { updateEntity1 = "new value", updateEntity2 = "new value" }
, packageName =
upstream.packageName // { version = "v4.0.0" }
, packageName =
upstream.packageName // { repo = "https://www.example.com/path/to/new/repo.git" }
}
-------------------------------
Example:
-------------------------------
let overrides =
{ halogen =
upstream.halogen // { version = "master" }
, halogen-vdom =
upstream.halogen-vdom // { version = "v4.0.0" }
}
-------------------------------
### Additions
Purpose:
- Add packages that aren't already included in the default package set
Syntax:
Replace the additions' "{=}" (an empty record) with the following idea:
-------------------------------
let additions =
{ package-name =
{ dependencies =
[ "dependency1"
, "dependency2"
]
, repo =
"https://example.com/path/to/git/repo.git"
, version =
"tag ('v4.0.0') or branch ('master')"
}
, package-name =
{ dependencies =
[ "dependency1"
, "dependency2"
]
, repo =
"https://example.com/path/to/git/repo.git"
, version =
"tag ('v4.0.0') or branch ('master')"
}
, etc.
}
-------------------------------
Example:
-------------------------------
let additions =
{ benchotron =
{ dependencies =
[ "arrays"
, "exists"
, "profunctor"
, "strings"
, "quickcheck"
, "lcg"
, "transformers"
, "foldable-traversable"
, "exceptions"
, "node-fs"
, "node-buffer"
, "node-readline"
, "datetime"
, "now"
]
, repo =
"https://github.com/hdgarrood/purescript-benchotron.git"
, version =
"v7.0.0"
}
}
-------------------------------
-}
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.13.4-20191025/packages.dhall sha256:f9eb600e5c2a439c3ac9543b1f36590696342baedab2d54ae0aa03c9447ce7d4
let overrides =
{ halogen =
upstream.halogen ⫽ { version = "v4.0.0" }
, colors =
upstream.colors ⫽ { version = "v5.0.0" }
, maybe =
upstream.maybe ⫽ { version = "v4.0.1" }
, aff =
upstream.aff ⫽ { version = "v5.1.2" }
, profunctor-lenses =
upstream.profunctor-lenses ⫽ { version = "v6.2.0" }
}
let additions = {=}
in upstream ⫽ overrides ⫽ additions

15
ui/shell.nix Normal file
View file

@ -0,0 +1,15 @@
{ pkgs ? import (fetchTarball https://github.com/NixOS/nixpkgs/archive/19.09-beta.tar.gz) {} }:
let
easy-ps = import (pkgs.fetchFromGitHub {
owner = "justinwoo";
repo = "easy-purescript-nix";
rev = "b2efbe30c55ffa16dd6f85cb7c71f77ac3136aa0";
sha256 = "0mmjvqpkns964sjkbw0waqb47vfhg9r0fp9y0b5pizpikmw3fbp2";
}) { inherit pkgs; };
in pkgs.mkShell {
buildInputs = [ easy-ps.purs
easy-ps.spago
pkgs.nodePackages.parcel-bundler
pkgs.nodejs
];
}

20
ui/spago.dhall Normal file
View file

@ -0,0 +1,20 @@
{-
Welcome to a Spago project!
You can edit this file as you like.
-}
{ name =
"solaryzed"
, dependencies =
[ "aff"
, "console"
, "effect"
, "halogen"
, "profunctor-lenses"
, "maybe"
, "psci-support"
]
, packages =
./packages.dhall
, sources =
[ "src/**/*.purs", "test/**/*.purs" ]
}

40
ui/src/Button.purs Normal file
View file

@ -0,0 +1,40 @@
module Button (component) where
import Prelude
import Data.Maybe (Maybe(..))
import Halogen as H
import Halogen.HTML as HH
import Halogen.HTML.Events as HE
import Halogen.HTML.Properties as HP
type State = { enabled :: Boolean }
data Action = Toggle
component :: forall q i o m. H.Component HH.HTML q i o m
component =
H.mkComponent
{ initialState
, render
, eval: H.mkEval $ H.defaultEval { handleAction = handleAction }
}
initialState :: forall i. i -> State
initialState _ = { enabled: false }
render :: forall m. State -> H.ComponentHTML Action () m
render state =
let
label = if state.enabled then "On" else "Off"
in
HH.button
[ HP.title label
, HE.onClick \_ -> Just Toggle
]
[ HH.text label ]
handleAction ∷ forall o m. Action → H.HalogenM State Action () o m Unit
handleAction = case _ of
Toggle ->
H.modify_ \st -> st { enabled = not st.enabled }

14
ui/src/Main.purs Normal file
View file

@ -0,0 +1,14 @@
module Main where
import Prelude
import Effect (Effect)
import Halogen.Aff as HA
import Halogen.VDom.Driver (runUI)
import Button as Button
main :: Effect Unit
main = HA.runHalogenAff do
body <- HA.awaitBody
runUI Button.component unit body

11
ui/test/Main.purs Normal file
View file

@ -0,0 +1,11 @@
module Test.Main where
import Prelude
import Effect (Effect)
import Effect.Class.Console (log)
main :: Effect Unit
main = do
log "🍝"
log "You should add some tests."