This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-06-01
Channels
- # babashka (30)
- # beginners (80)
- # calva (21)
- # chlorine-clover (2)
- # cider (22)
- # clj-kondo (65)
- # cljfx (2)
- # cljs-dev (3)
- # cljsrn (3)
- # clojure (37)
- # clojure-europe (27)
- # clojure-italy (3)
- # clojure-nl (2)
- # clojure-taiwan (1)
- # clojure-uk (21)
- # clojurescript (13)
- # conjure (23)
- # core-typed (1)
- # cursive (16)
- # datahike (1)
- # datomic (6)
- # docs (2)
- # emacs (5)
- # figwheel-main (1)
- # fulcro (12)
- # helix (11)
- # jobs (2)
- # jobs-discuss (2)
- # leiningen (1)
- # lsp (34)
- # luminus (1)
- # malli (19)
- # microservices (1)
- # nrepl (1)
- # off-topic (25)
- # pathom (6)
- # polylith (47)
- # practicalli (5)
- # re-frame (8)
- # reagent (1)
- # reitit (1)
- # releases (2)
- # remote-jobs (2)
- # reveal (1)
- # sci (1)
- # shadow-cljs (11)
- # sql (8)
- # tools-deps (9)
- # xtdb (16)
ANy recommendations for stuff to look into if I want to have a grid in html that is big'ish, 20x20, where each cell is clickable? Something like this: right now I just have it generating 400 divs then i partition them by 20 for each row... What's a smarter way for a frontend n00b to look into?
can you detect where the user is clicking on a canvas? I want them to be able to click squares and toggle thembetwen open and maze wall
eventually i want to draw lines on the maze to show the solved route, which WOULD be easier on a canvas.
there you could draw with a similar api, but also have pointer-events for the individual elements
so i could use the divs for the squres, but maybe draw the route using svg? or would it be one or the other?
If you're only drawing vertical and horizontal lines, you can use divs with borders and/or background colors to draw lines.
there's also css to rotate divs for non vertical/horizontal lines, but at that point, SVG is probably a better fit
Canvas is pretty easy. https://gameoflife2d.gklijs.tech/ play/pause and you can turn cells active/dead. Source https://github.com/gklijs/game-of-life/blob/2d/www/index.js
Seems like a decent solution already if you're just capturing clicks and don't care too much about render time. Lots of divs = more repainting / processing on the DOM level, but it might be perfectly fine for what you're doing. Are you wondering what the fastest implementation might be? or the most convenient to code? or some balance point between/betwixt?
Really more that I'm quite newish to front end stuff and I don't really have anyone to ask that has up to date experience. So I often sit and try to make things all the time wondering "Am I being a total idiot here" with my implementations.
I built https://djblue.github.io/tetris/ in cljs as a table of divs and it works well enough 😆 10 * 24 = 240 elements in the grid.
You are not being an idiot. 😃 And there are lots of way to do it. I bet some CSS magician can do it with gradients or something.
well, i got somethign that sorta works. https://stuartstein777.github.io/maze-solver/ Guess what they say, if it works, it isn't stupid 🙂