0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-22 22:49:01 -05:00
This commit is contained in:
Andrey Antukh 2015-12-14 10:48:50 +02:00
parent 2663acf224
commit 62b9267d4f
3 changed files with 28 additions and 25 deletions

View file

@ -1,8 +1,10 @@
(ns uxbox.ui (ns uxbox.ui
(:require [rum.core :as rum] (:require [sablono.core :as html :refer-macros [html]]
[rum.core :as rum]
[cats.labs.lens :as l] [cats.labs.lens :as l]
[uxbox.state :as s] [uxbox.state :as s]
[uxbox.util :as util] [uxbox.util :as util]
[uxbox.ui.lightbox :as ui.lb]
[uxbox.ui.users :as ui.u] [uxbox.ui.users :as ui.u]
[uxbox.ui.dashboard :as ui.d])) [uxbox.ui.dashboard :as ui.d]))
@ -15,7 +17,7 @@
(let [{:keys [location location-params] :as state} (rum/react state)] (let [{:keys [location location-params] :as state} (rum/react state)]
(html (html
[:section [:section
(lb/lightb (ui.lb/lightbox)
(case location (case location
:auth/login (ui.u/login) :auth/login (ui.u/login)
;; :auth/register (u/register) ;; :auth/register (u/register)
@ -24,7 +26,7 @@
;; :main/project (w/workspace conn location-params) ;; :main/project (w/workspace conn location-params)
;; :main/page (w/workspace conn location-params)))) ;; :main/page (w/workspace conn location-params))))
nil nil
))) )])))
(def app (def app
(util/component {:render app-render (util/component {:render app-render

View file

@ -1,7 +1,7 @@
(ns uxbox.ui.dashboard (ns uxbox.ui.dashboard
(:require [sablono.core :as html :refer-macros [html]] (:require [sablono.core :as html :refer-macros [html]]
[rum.core :as rum] [rum.core :as rum]
[cuerdas.core :refer [trim]] [cuerdas.core :as str]
[uxbox.util :as util] [uxbox.util :as util]
[uxbox.router :as r] [uxbox.router :as r]
[uxbox.ui.icons :as i] [uxbox.ui.icons :as i]
@ -51,35 +51,34 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn layout-input (defn layout-input
[layout local] [local layout-id]
(let [human-name (get-in project-layouts [layout :name]) (let [layout (get-in project-layouts [layout-id])
id (str "project-" (get-in project-layouts [layout :id])) id (:id layout)
tag (str "input#" id) name (:name layout)
tag (keyword tag)] width (:width layout)
[[tag height (:height layout)]
(html
[:input
{:type "radio" {:type "radio"
:key id :key id
:id id
:name "project-layout" :name "project-layout"
:value human-name :value name
:checked (= layout (:layout @local)) :checked (= layout-id (:layout @local))
:on-change #(swap! local merge {:layout layout :on-change #(swap! local merge {:layout layout-id :width width :height height})}]
:width (get-in project-layouts [layout :width]) [:label {:value (:name @local) :for id} name])))
:height (get-in project-layouts [layout :height])})}]
[:label
{:value name
:for id}
human-name]]))
(defn- layout-selector (defn- layout-selector
[local] [local]
(html (html
[:div.input-radio.radio-primary [:div.input-radio.radio-primary
(vec (cons :div.input-radio.radio-primary (vec (cons :div.input-radio.radio-primary
(mapcat #(layout-input % local) (keys project-layouts))))])) (mapcat #(layout-input local %) (keys project-layouts))))]))
(defn- new-project-lightbox-render (defn- new-project-lightbox-render
[own] [own]
(let [local (:rum/local own) (let [local (:rum/local own)
name (:name @local)
width (:width @local) width (:width @local)
height (:height @local)] height (:height @local)]
(html (html
@ -114,7 +113,7 @@
;; Layout selector ;; Layout selector
(layout-selector local) (layout-selector local)
;; Submit ;; Submit
(when-not (empty? (trim name)) (when-not (empty? (str/trim name))
[:input#project-btn.btn-primary [:input#project-btn.btn-primary
{:value "Go go go!" {:value "Go go go!"
:type "submit"}])] :type "submit"}])]

View file

@ -1,5 +1,6 @@
(ns uxbox.ui.lightbox (ns uxbox.ui.lightbox
(:require [rum.core :as rum] (:require [sablono.core :as html :refer-macros [html]]
[rum.core :as rum]
[uxbox.util :as util] [uxbox.util :as util]
[uxbox.ui.keyboard :as k] [uxbox.ui.keyboard :as k]
[goog.events :as events]) [goog.events :as events])
@ -49,10 +50,11 @@
(defn- lightbox-render (defn- lightbox-render
[own] [own]
(let [name (rum/react +current+)] (let [name (rum/react +current+)]
[:div.lightbox {:class (when (nil? name) "hide")} (html
(render-lightbox name)])) [:div.lightbox {:class (when (nil? name) "hide")}
(render-lightbox name)])))
(def lightbox (def ^:static lightbox
(util/component (util/component
{:name "lightbox" {:name "lightbox"
:render lightbox-render :render lightbox-render