 ;; View Components
 ;;----------------
 
-(declare proposal-list
-				 proposal-item)
-
-(defn proposal-list
-	"An unordered list of proposals"
-	[proposal-list]
+(declare
+	proposal-page
+	proposal-search
+	proposal-list
+	proposal-item)
+
+
+(defn proposal-page
+	"Proposal page" []
+	(let [{:keys [proposals search]} @app-state]
+		[:div.contain
+		 [:div.row
+			[:div.col-md-12
+			 [:img.proposal-img.pull-left {:src "/img/proposal.jpg"}]
+			 [:h1 "Proposals"]
+			 [proposal-search search]
+			 [proposal-list proposals search]]]]))
+
+(defn proposal-search
+	"A searchbox"
+	[search]
+	[:span "search, "
+	 [:input {:type      "text"
+						:value     search
+						:on-change (fn [event] (swap!
+																		 app-state
+																		 update-search
+																		 (-> event .-target .-value)))}]]
+	)
+
+(defn proposal-list "An unordered list of proposals"
+	[proposals search]
 	[:div.container-fluid
 	 [:ul.proposal-list
-		(for [proposal proposal-list]
+		(for [proposal (->> proposals (filter #(matches-search? search %)))]
 			^{:key (:title proposal)} [proposal-item proposal])]])
 
-(defn proposal-item
-	"A proposal item component"
+(defn proposal-item "A proposal item component"
 	[{:keys [title description] {:keys [nickname avatar-url]} :author}]
 	[:li.proposal-item
 	 [:h4 title]

	 [:img.img-circle.img-thumb {:src avatar-url}]
	 [:span.nickname nickname]])

(defn nav-link [uri title page collapsed?]
	[:li {:class (when (= page (session/get :page)) "active")}
	 [:a {:href     uri
				:on-click #(reset! collapsed? true)}
		title]])


(defn navbar []
	(let [collapsed? (atom true)]
		(fn []
			[:nav.navbar.navbar-inverse.navbar-fixed-top

																				 :email      "stullrich@tomicowski.com"}}])


;; App State
;; ---------

(defonce app-state (atom {:proposals hardcoded-proposals
													:search    ""}))


(defn update-search
	"Updates :search in app-state"
	[app-state new-search]
	(assoc app-state :search new-search))


;; Search logic
