From 927b25e3dddde019274a4c5237b8a37d1024b419 Mon Sep 17 00:00:00 2001 From: Gabriel Giovanini Date: Sun, 23 Jun 2019 21:03:12 +0200 Subject: Simplyfies things --- src/genpass/components/button.cljc | 7 ------- src/genpass/components/input.cljc | 13 ------------- src/genpass/core.cljs | 26 ++++++++++---------------- 3 files changed, 10 insertions(+), 36 deletions(-) delete mode 100644 src/genpass/components/button.cljc delete mode 100644 src/genpass/components/input.cljc diff --git a/src/genpass/components/button.cljc b/src/genpass/components/button.cljc deleted file mode 100644 index 1a20c08..0000000 --- a/src/genpass/components/button.cljc +++ /dev/null @@ -1,7 +0,0 @@ -(ns genpass.components.button) - -(defn button-primary [label fn] - [:input.button.is-primary - {:value label - :type "button" - :on-click fn}]) diff --git a/src/genpass/components/input.cljc b/src/genpass/components/input.cljc deleted file mode 100644 index a4b8499..0000000 --- a/src/genpass/components/input.cljc +++ /dev/null @@ -1,13 +0,0 @@ -(ns genpass.components.input) - - -(defn input-primary - ([text] - (input-primary text #())) - ([text fn] - [:input.input.is-primary - {:type "text" - :value text - :on-click fn}])) - - diff --git a/src/genpass/core.cljs b/src/genpass/core.cljs index f6e1b68..b207cb5 100644 --- a/src/genpass/core.cljs +++ b/src/genpass/core.cljs @@ -1,12 +1,9 @@ (ns genpass.core (:require [reagent.core :as r] - [genpass.components.input :refer [input-primary]] - [genpass.components.button :refer [button-primary]] [genpass.gen :refer [genpwd]])) -(def size (r/atom 12)) -(def password (r/atom (genpwd @size))) +(def password (r/atom (genpwd))) (defn magic-selection-trick-took-from-so [e] (let [this (.-target e)] @@ -21,17 +18,6 @@ (.moveToElementText range) (.select range this)))))) -(defn update-pwd [arg] - (reset! size arg) - (reset! password (genpwd @size))) - -(defn main-section [] - [:div - [:div.field.has-text-centered - [:span.title.is-2 {:on-click magic-selection-trick-took-from-so} @password]] - [:div.field.is-grouped.is-grouped-centered - [:div.control - (button-primary "Generate" #(update-pwd @size))]]]) (defn home-page [] [:div @@ -40,7 +26,15 @@ :aria-label "main navigation"} [:div.navbar-brand>a.navbar-item>h1 [:a {:href "https://github.com//gabrielgio/genpass"} "Genpass source code"]]] - [:div.section.container (main-section)]]) + [:div.section.container + [:div.field.has-text-centered + [:span.title.is-3 {:on-click magic-selection-trick-took-from-so} @password]] + [:div.field.is-grouped.is-grouped-centered + [:div.control + [:input.button.is-primary + {:value "Generate" + :type "button" + :on-click #(reset! password (genpwd))}]]]]]) (defn mount-root [] (r/render [home-page] (.getElementById js/document "app"))) -- cgit v1.2.3