aboutsummaryrefslogtreecommitdiffstats
path: root/root/articles/mmmfs/gallery.moon
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2018-10-31 08:52:16 +0000
committers-ol <s-ol@users.noreply.github.com>2018-10-31 08:52:16 +0000
commitb99de1d4e79e6c4a548d9dddca730eaeeb63a1c9 (patch)
tree1b34fd16a46d2567f7e767d9f260ad238bea0ef9 /root/articles/mmmfs/gallery.moon
parentREHYDRATION (diff)
downloadmmm-b99de1d4e79e6c4a548d9dddca730eaeeb63a1c9.tar.gz
mmm-b99de1d4e79e6c4a548d9dddca730eaeeb63a1c9.zip
almost there tbh
Diffstat (limited to 'root/articles/mmmfs/gallery.moon')
-rw-r--r--root/articles/mmmfs/gallery.moon49
1 files changed, 49 insertions, 0 deletions
diff --git a/root/articles/mmmfs/gallery.moon b/root/articles/mmmfs/gallery.moon
new file mode 100644
index 0000000..081865a
--- /dev/null
+++ b/root/articles/mmmfs/gallery.moon
@@ -0,0 +1,49 @@
+import define_fileders from require 'lib.mmmfs'
+import div, h1, a, img, br from require 'lib.dom'
+
+Fileder = define_fileders ...
+
+with Fileder {
+ 'name: alpha': 'gallery',
+ 'title: text/plain': "A Gallery of 25 random pictures, come in!",
+ 'preview: moon -> mmm/dom': => div {
+ 'the first pic as a little taste:',
+ br!,
+ img src: @children[1]\get 'preview', 'URL -> image/png'
+ }
+ 'moon -> mmm/dom': =>
+ link = (child) -> a {
+ href: '#',
+ onclick: -> BROWSER\navigate { 'gallery', (child\get 'name', 'alpha'), nil },
+ img src: child\gett 'preview', 'URL -> image/png'
+ }
+
+ content = [link child for child in *@children]
+ table.insert content, 1, h1 'gallery index'
+ div content
+
+ 'slideshow: moon -> mmm/dom': =>
+ import ReactiveVar, text, elements from require 'lib.component'
+
+ index = ReactiveVar 1
+
+ prev = (i) -> math.max 1, i - 1
+ next = (i) -> math.min #@children, i + 1
+
+ e = elements
+ e.div {
+ e.div {
+ e.a 'prev', href: '#', onclick: -> index\transform prev
+ index\map (i) -> text " image ##{i} "
+ e.a 'next', href: '#', onclick: -> index\transform next
+ },
+ index\map (i) -> img src: @children[i]\gett nil, 'URL -> image/png'
+ }
+ }
+ for i=1,25
+ id = 120 + i
+ .children[i] = Fileder {
+ 'name: alpha': "image#{id}"
+ 'URL -> image/png': "https://picsum.photos/600/600/?image=#{id}"
+ 'preview: URL -> image/png': "https://picsum.photos/200/200/?image=#{id}"
+ }