Fork me on GitHub
#hoplon
<
2016-10-06
>
vigilancetech01:10:16

@jumblerg are buttons supposed to work on ui? Every time I try and add one, like it shows at the bottom of the test file, it just makes my whole page blank

jjttjj03:10:05

@vigilancetech I've used buttons with ui with no issue for what it's worth. Can you provide a sample of the code that's not working?

vigilancetech03:10:44

@jjttjj Well, unless I actually go right in to the ui-test.cljs and edit that, I get this error: adzerk.boot_cljs.util.proxy$java.lang.Throwable$ff19274a: Unsupported binding key: :sh

vigilancetech03:10:42

But there are numerous examples of buttons at the bottom of that file, and I tried incorporating them into very simple elements and even though I could get images and words to render, as soon as I added a button, poof blank page

jjttjj03:10:57

@vigilancetech oh wait my mistake, I was actually using hoplon.ui/submit not button. it seems there is no longer a button element

vigilancetech03:10:07

but let me try and get a (window...) constructor together to illustrate

jjttjj03:10:24

in the test file, the usage of the button is commented out right?

vigilancetech03:10:17

What about including other widgets? Or will it only support those that have been ui "wrapped?"

jjttjj03:10:37

it's probably from an older version. I know they changed a lot of things fast and the api isn't really stable

jjttjj03:10:49

what widgets did you mean?

vigilancetech03:10:05

well, like sliders, gages, etc...?

jjttjj03:10:37

i'm definitely not an expert, just been playing around with ui for a few weeks, but my understanding is you build them all from raw elems

vigilancetech03:10:11

so like using the google closure library widgets will work? Cuz I think "button" is one of those

jjttjj03:10:59

i'm not really familiar with the closure widget stuff

jjttjj03:10:02

UI seems pretty experimental, i think it kind of assumes a full buy in to its philosophy for all user interface stuff. Though there may be no reason you couldn't get it to work with other widget systems

jjttjj03:10:52

so if you need something that looks like a button, you make an elem with the appropriate colors, borders, shadow, etc

vigilancetech03:10:00

do you have a github repo of some ui stuff you've done that works?

vigilancetech03:10:22

so maybe I can get rid of that other error and start from scratch?

vigilancetech03:10:35

just something simple

jjttjj03:10:49

unfortunately nothing public at the moment but maybe soon I'll try to put something out there

jjttjj03:10:24

I randomly found on github some of jumberg's code using it, which was useful to me: https://github.com/jumblerg/computable-law/blob/master/src/human-dynamics/computeable-law.cljs

vigilancetech03:10:43

oh, nice, thanks, I'll check it out!

jjttjj04:10:47

i think i had difficulties getting the page to actually run out of the box, (again, the ui api has changed really fast) but it was useful as code to look at

vigilancetech04:10:25

ok, well, I'll try.

jjttjj04:10:42

the general idea is to forget everything you know about html and css. you're making all your own elements from now, using the attributes UI provides to describe how they should look

jjttjj04:10:23

there are edge cases that ui is forced to deal with. like you can't use :p, :g, :sh, etc to make an image show up on a page. so the library deals with these cases, but there aren't too many

vigilancetech04:10:28

ok, and one should be able to encapsulate many widgets inside that then.

jjttjj04:10:55

yeah exactly

vigilancetech04:10:06

I think I could live with that

vigilancetech04:10:21

you think its pretty robust so far?

vigilancetech04:10:09

I'm thinking if I factor the hell out of everything I shouldn't be in too much trouble if the API changes a bit

jjttjj04:10:20

i think the creator(s?) are pretty open about it being very experimental. after the last question i asked about it here it was recommended i basically hack the ui library itself and make changes there as part of the workflow of using it. A lot of the form stuff was supposedly thrown in to meet some specific needs and not meant to be a complete implementation even at the time. So it's definitely rough around the edges and i don't think anyone is trying to claim it's in a 1.0 state or anything like that

jjttjj04:10:25

personally i really like the idea of it and have found it to make more sense to me than other ui systems, which were all pretty much just CSS frameworks

jjttjj04:10:45

but I've only been playing around with it on a toy project to learn a few things so far

jjttjj04:10:21

basically html has all these semantic elements which all have default styles. you can pick a css framework (bootstrap, etc) and get some probably more sensible defaults. but you're still going to have to write your own CSS too, pretty much from the start

vigilancetech04:10:25

its looks like the button issue was a hangup on his computable-law project too

vigilancetech04:10:40

I thought one of the main gists of this project was to get you away from writing CSS

jjttjj04:10:56

it seems like button is required but not used. and also it almost definitely refers to an older ui library

vigilancetech04:10:19

ok, good, maybe I can just comment it out then and see something

jjttjj04:10:19

and yeah i meant with something like bootstrap you're going to have to write your own css too

jjttjj04:10:25

with ui you don't have to touch it

vigilancetech04:10:43

yes, that was the appeal

jumblerg07:10:32

@vigilancetech: yeah, that repo is old. i removed the button element constructor because we can give any elem button semantics already by adding a click handler (and perhaps setting the mouse to pointer for desktops). (elem :sh 300 :sv 60 :r 5 :b 2 :c :blue :m :pointer :click #(change-state! :home))

dm307:10:54

@jumblerg what are the biggest unsolved problems with Hoplon/UI currently?

jumblerg07:10:24

@dm3: a few that come to mind are: 1. forms. i think these, specifically, are largely solved on another branch, but certain form elements (like dropdowns) are stateful, and therefore depend on... 2. states. we need a general way for children of an elem to change based on the state of their parent. we’ve done this in more concrete cases via macros that set dynamic vars when the page is eval’d, but we need to do this with fns instead. 3. layers. many of the cases for absolute and relative positioning have been eleminated by ensuring that all types of elems take children, including image, video, etc, but there are cases (such as a dropdown list, again) where we need a component to appear in front of others in the layout. i’m also experimenting with the notion of an owner, which is an elem another elem might depend on for state, but is not necessarily the parent. 4. 100% height columns. this was actually solved, at one point, but regressed when experimenting with… 5. scrolling. we want to maintain the left right top bottom flow without introducing fixed, relative, absolute positioning schemes. so rather than making an entire page scrollable and then designating a menu as “fixed”, we should instead lay out the menu(s) and body lrtb and designate the body component itself as being scrollable. the way scroll contexts work in the dom complicates this. also, chrome does not use elastic scrolling on anything other than the body element last time i checked.

jumblerg07:10:57

i think all of these issues are solvable, at this point, and i’ve implemented code to address them on various branches i have running locally (although some of these fixes, as is often the case with anything involving css properties, are mutually exclusive of others).

dm308:10:54

can 5 be solved with 3? If you allow for a fixed layer and lay it out separately?

jumblerg09:10:42

@dm3: i hadn’t considered that, but possibly (it’s interesting how, when you get the fundamental abstractions right, even unanticipated cases have a way of working out). one could potentially “fix” some menus by placing them in one layer while making the one behind it scrollable.

jumblerg09:10:24

given a case where there was a fixed left sidebar menu, however, you’d need to specify the width of that menu twice, once for the menu itself on one layer, and again on the layer behind it so the elements in the scrollable layer would fill to the correct width.

dm309:10:13

a pragmatic solution might be needed 🙂 I think everywhere where an in-component scrolling is allowed, a custom scrolling scheme was used

jumblerg09:10:16

it’s pretty cool to see so much interest in the ui project; my time has been a bit more constrained recently, but i do think we’re approaching a production-ready release. the remaining issues are solvable.

dm309:10:36

I mean in browser-based UI libs

jumblerg09:10:55

yeah, we might just need to make some less-than-elegant tradeoffs for some of the remaining cases so we can ship.

jumblerg09:10:44

the advantages of maintaining the lrtb flow, however, are quite significant when it comes to making layouts work across different screen sizes, so i want to avoid introducing other layout schemes if at all possible.

zilvinask12:10:26

are there anywhere examples how to use Hoplon/UI?

zilvinask12:10:47

some sample page maybe

dm312:10:19

there used to be examples

jumblerg12:10:40

@dm3, @zilvinask: that’s quite dated… let me see what i can find.

jumblerg12:10:06

(ns+ hoplon.demo
  (:page
    "index.html")
  (:refer-clojure
    :exclude [-])
  (:require
    [javelin.core    :refer [defc defc= cell= cell]]
    [hoplon.core     :refer [defelem for-tpl when-tpl case-tpl]]
    [hoplon.ui       :refer [window elem image form line lines pick picks file files item send s b]]
    [hoplon.ui.elems :refer [markdown]]
    [hoplon.ui.attrs :refer [- c r d]]))

;;; model ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defc db {:session {:state :home}})

;;; queries ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defc= state (-> db :session :state))

;;; commands ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defn swap-state! [state]
  (swap! db assoc-in [:session :state] state))

;;; styles ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;-- breakpoints ---------------------------------------------------------------;

(def sm 760)
(def md 1240)
(def lg 1480)

(defn >sm [& bks] (apply b (r 1 1) sm bks))

;-- sizes ---- ----------------------------------------------------------------;

(def gutter 6)

;-- colors --------------------------------------------------------------------;

(def black  (c 0x1F1F1F))
(def orange (c 0xE73624))
(def blue   (c 0x009BFF))
(def yellow (c 0xF5841F))

;-- fonts ---------------------------------------------------------------------;

(def menu-font {:f 28 :ff "opensans" :ft :800 :fc :white :fw 1})

;;; views ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(window
  :title "Hoplon UI" 
  :route (cell= [[view]])
  (elem :sh (r 1 1) :ah :mid :c orange :bt 8 :bc yellow
    (elem :sh (>sm md) :p 50 :gv 50 :a :mid
      (image :s 400 :m :pointer :click #(swap-state! :home) :url "")
      (elem :sh (>sm (- (r 1 1) (+ 400 10))) :p 10 :g 10 :ah :end
        (elem :sh (>sm :auto) :ah :mid :m :pointer menu-font "layout")
        (elem :sh (>sm :auto) :ah :mid :m :pointer menu-font "fonts")
        (elem :sh (>sm :auto) :ah :mid :m :pointer menu-font "layout")
        (elem :sh (>sm :auto) :ah :mid :m :pointer menu-font "source")))))

jumblerg12:10:00

those are the beginnings of a documentation site i started working on before i had to catch up with work

zilvinask12:10:05

@jumblerg Thank you, I guess I still miss where does hoplon elements such as input/span/whatever meets e hoplon/ui ? Or does hoplon/ui has a replacement for them?

zilvinask12:10:24

i mean can you combine them together, is there any point to do that at all?

jumblerg12:10:27

@zilvinask: if you’re looking for those, you’ll want to use the underlying hoplon core layer, which maintains a 1:1 correspondence with with the dom.

jumblerg12:10:38

the objective of ui is to create a fresh, programmatic interface for creating user interfaces

zilvinask12:10:08

ok, so lets say i want to make login screen with input field in the middle. How do i do that with hoplon/ui?

jumblerg12:10:47

for most cases, with ui, you’ll simply want an elem.

zilvinask12:10:37

yeah thats what i understand. But then i need ‘input’, and i though that i can combine elem with input (which is hoplon.core)

zilvinask12:10:03

i guess it doesnt work like that, does it?

jumblerg12:10:10

here’s an example of a login viewstate i created:

(defelem authentication [_ _]
  (public :title “Some Software Platform"
    (elem :g 8
      (image :sh (b (r 1 1) sm (r 1 2)) :p 4 :r 6 :b 1 :bc (c 0xCCCCCC) :url “pretty-picture.jpg")
      (form  :sh (b (r 1 1) sm (r 1 2)) :g 8 :submit c/authenticate-user
        (field :sh (r 1 1) :key :email    :prompt "email address")
        (field :sh (r 1 1) :key :password :prompt "password")
        (elem :ah :jst :m :default :fc font-grey
          "Unable to log in? ")
        (elem :sv 142 :fu :underline :m :pointer :click #(c/change-state :state/identification)
          "Click here and we'll send a secret code to your email address instead.")
        (elem :sh (r 1 1) :g 8
          (submit :sh (r 2 5) :label "Sign Up" :submit c/register-user)
          (submit :sh (r 3 5) :label "Sign In"))))))

zilvinask12:10:11

oh i see, I understand now, thank you!

jumblerg12:10:54

forms are one of the rare cases where you’ll need something other than an elem, since input elements carry different semantics for things other than layout.

vigilancetech16:10:29

@lightbulb that pavucontrol worked! What I had to do is set up shell a loop touching a source file and then the volume control became visible enough I could grab the knob and pull it down. WHAT a relief! Maybe my speakers are saved! (also worked for Facebook, and gave me Linux bragging rights on their help forum, as the Windows people look like they are eternally doomed to be confounded with this problem!) Thanks so much!

alandipert17:10:49

@vigilancetech that's awesome! totally forgot about pavucontrol, glad you were directed to it

vigilancetech17:10:15

@alandipert yes, but it would still be nice for speak to have a "volume." I'm putting it in the bazillionth place on my TODO list 😕

vigilancetech17:10:19

maybe someone could mention pavucontrol on the wiki?

lightbulb17:10:03

@vigilancetech Glad you got it to work. I tried to build a tray mixer for pulseaudio like the Windows one in QT a year ago. It sorta worked. I want to revive that project at some point.

vigilancetech17:10:41

sadly now I'm using stumpWM sans tray right now. No time nor energy to configure one. Kind of interesting to see how well I'm getting along without one. Eventually I'll get around to it and then having a mixer there would definitely be good.

lightbulb17:10:33

Not heard of stumpWM. I'll have a look. I'm using Openbox and Tint2. Not sure how much longer that will last with Wayland starting to actually happen.

vigilancetech17:10:28

I never even thought to look and see if there's an issue with stump and wayland. I wanted something lispy, and it was pretty much between stump and some emacs window manager

lightbulb17:10:39

@micha I just want to give you an update on my javelin.core/none issue. I have created a new hoplon project and built a real minimal single page app but I have not been able to reproduce the issue yet. I will keep working on it and let you know when I figure it out. The main project i'm working on is quite large so its a bit of a needle in a haystack situation.

lightbulb18:10:23

@vigilancetech I tried wayland on my laptop with just weston and well, none of my application would open. Basically if your WM doesn't get ported your only option will be to run your WM in a fullscreen xwayland session which defeats the point. Stay with X. I'd be quite happy with weston though once I can get my apps running on it.

vigilancetech18:10:07

@lightbulb well, for most of the rest I'm on Sabayon so I probably won't migrate there till they do. Right now, I've a critical project so I don't even dare upgrade!

alandipert18:10:44

is wayland the default in ubuntu LTS yet?

lightbulb18:10:50

Wayland is still a long way off though.

lightbulb18:10:02

Ubuntu has MIR

lightbulb18:10:44

Not sure if Ubuntu will get Wayland. They went off on there own thing with MIR. Same sort of thing as upstart and systemd.

alandipert19:10:30

ah. i guess my plan will be to use whatever distro has i3

dm321:10:18

where was this clojurescript binding thing implemented? Can't find it...

flyboarder22:10:32

@dm3: it's on micha's attribute dev branch of hoplon