Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/todomvc/resources/public/todos.css
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ label[for='toggle-all'] {
text-decoration: line-through;
}

#todo-list li .created {
font-size: 14px;
float: right;
word-break: break-all;
}

#todo-list li .destroy {
display: none;
position: absolute;
Expand Down
3 changes: 2 additions & 1 deletion examples/todomvc/src/todomvc/db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
(s/def ::id int?)
(s/def ::title string?)
(s/def ::done boolean?)
(s/def ::todo (s/keys :req-un [::id ::title ::done]))
(s/def ::date #(instance? js/Date (js/Date. %)))
(s/def ::todo (s/keys :req-un [::id ::title ::done ::date]))
(s/def ::todos (s/and ;; should use the :kind kw to s/map-of (not supported yet)
(s/map-of ::id ::todo) ;; in this map, each todo is keyed by its :id
#(instance? PersistentTreeMap %) ;; is a sorted-map (not just a map)
Expand Down
2 changes: 1 addition & 1 deletion examples/todomvc/src/todomvc/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
;; The "path" interceptor in `todo-interceptors` means 1st parameter is :todos
(fn [todos [text]]
(let [id (allocate-next-id todos)]
(assoc todos id {:id id :title text :done false}))))
(assoc todos id {:id id :title text :done false :date (.getTime (js/Date.))}))))


(reg-event-db
Expand Down
6 changes: 4 additions & 2 deletions examples/todomvc/src/todomvc/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
(defn todo-item
[]
(let [editing (reagent/atom false)]
(fn [{:keys [id done title]}]
(fn [{:keys [id done title date]}]
[:li {:class (str (when done "completed ")
(when @editing "editing"))}
[:div.view
Expand All @@ -36,7 +36,9 @@
:on-change #(dispatch [:toggle-done id])}]
[:label
{:on-double-click #(reset! editing true)}
title]
title
[:span.created
(.toDateString (js/Date. date))]]
[:button.destroy
{:on-click #(dispatch [:delete-todo id])}]]
(when @editing
Expand Down