Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(defn weekdays []
(let [weekdays-ratom {:mon {:takes-place? true :times ["9:00" "10:30"]}
:tue {:takes-place? false}
:wed {:takes-place? false}
:thu {:takes-place? false}
:fri {:takes-place? false}
:sat {:takes-place? false}
:sun {:takes-place? false}}
names {:mon {:intro "und zwar jeden" :word "Montag"}
:tue {:intro "und jeden" :word "Dienstag"}
:wed {:intro "und jeden" :word "Mittwoch"}
:thu {:intro "und jeden" :word "Donnerstag"}
:fri {:intro "und jeden" :word "Freitag"}
:sat {:intro "und jeden" :word "Samstag"}
:sun {:intro "sowie jeden" :word "Sonntag"}}
]
[:div.row
(doall (apply concat (for [[key {:keys [intro word]}] names
:let [short-name (name key)
{:keys [takes-place? times]} (key weekdays-ratom)]]
[^{:key (str key "intro")}
[:div.col.s2.right-align intro]
^{:key (str key "takes-place")}
[:div.col.s2
[:input.filled-in {:type "checkbox"
:id (str "weekdays-" short-name)
:checked takes-place?
}]
[:label.black-text {:for (str "weekdays-" short-name)
:style {:height "auto"
:line-height "normal"}}
word (when-not takes-place? (str " nicht" (when (= key :sun) ".")))]]
(if takes-place?
^{:key (str key "times")}
[:div.col.s8
"um "
(when times
(apply concat
(for [[index time] (map-indexed vector times)]
(list
^{:key (str index "f")}
[:div {
:id (str "weekdays-" short-name "-" index)
:value time
:style {:width "3rem" :height "auto" :text-align "center" :margin "0"} }]
^{:key (str index "t")}
[:span ""]
))
(list (list " und "))))
^{:key (count times)}
[:div {
:id (count times)
:style {:width "3rem" :height "auto" :text-align "center" :margin "0"} }]
(if (= key :sun) "." ",")]
^{:key (str key "not")}[:div.col.s8 " "])])))]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.