Commit bc7dd53b authored by Bruno Burke's avatar Bruno Burke 🍔
Browse files

add testcard and change sc exercise to mcfw

parent b6af1668
Pipeline #2362 failed with stages
in 57 seconds
......@@ -54,6 +54,7 @@
:figwheel {:on-jsload "lernmeister.components.core/reload"
:websocket-host :js-client-host}
:compiler {:main lernmeister.components.core
:npm-deps {:material-components-web "latest"}
:optimizations :none
:output-to "resources/public/js/app.js"
:output-dir "resources/public/js/dev"
......@@ -66,6 +67,9 @@
:websocket-host :js-client-host}
:compiler {:main "lernmeister.components.core-card"
:optimizations :none
:language-in :ecmascript6-strict
:npm-deps {:material-components-web "0.30.0"}
:install-deps false
:output-to "resources/public/js/devcards.js"
:output-dir "resources/public/js/devcards"
:asset-path "js/devcards"
......@@ -4,6 +4,7 @@
<meta charset='utf-8'>
<link href="" rel="stylesheet">
<link rel="stylesheet" href="css/screen.css">
<link href="" rel="stylesheet" type="text/css">
<script type="text/javascript" src=""></script>
<script src="" integrity="sha384-/y1Nn9+QQAipbNQWU65krzJralCnuOasHncUFXGkdwntGeSvQicrYkiUBwsgUqc1" crossorigin="anonymous"></script>
This diff is collapsed.
......@@ -2,4 +2,6 @@
(:require [garden.def :refer [defstyles]]))
(defstyles screen
[:.shifttotop {:margin-top "-1rem"}])
[:.shifttotop {:margin-top "-1rem"}]
[:.mdc-card__content {:padding "15px"}]
......@@ -5,13 +5,14 @@
(defn sc-input [eid o answer result on-change]
[:div {:style {:display :inline-block}}
[:input.with-gap {:type "radio",
:id (:id o),
:name eid,
:disabled result,
:on-change #(on-change (:id o))
:checked (= answer (:id o))}]
{:type "radio",
:id (:id o),
:name eid,
:disabled result,
:on-change #(on-change (:id o))
:checked (= answer (:id o))}]
[ {:for (:id o)}
(when (and result (= (:answer-id result) (:id o)))
(if-not (:correct result)
......@@ -36,7 +37,7 @@
(defn print-single-choice [exercise & {:keys [result answer on-change]}]
(fn [exercise & {:keys [result answer on-change]}]
[:div.card {:class
[:div.mdc-card {:class
(and (:points result) (:points-max result)
(= (:points result) (:points-max result))) "green lighten-4"
......@@ -44,7 +45,7 @@
(< 0 (:points result) (:points-max result))) "yellow lighten-4"
(and (:points result) (<= (:points result) 0)) "red lighten-4"
:else "")}
[:span.card-title [:b (:title exercise)]]
(doall (for [ce (:task-description exercise)]
^{:key (:id ce)}[(content-manager/get-renderer (:type ce)) ce]))
(ns lernmeister.components.ui
[reagent.core :as reagent]
["@material/ripple" :refer [MDCRipple]]
["@material/icon-toggle" :as MDCIconToggle]))
(defn Button [props & children]
(let [instance (atom nil)]
(fn [e]
(let [node (reagent/dom-node e)]
(reset! instance (new MDCRipple node))))
:component-will-unmount (fn [e]
(swap! instance #(.destroy %)))
(fn [props & children]
[:button.mdc-button props children])})))
#_(defn Icon-Toggle [props children]
(let [instance (atom nil)
inverse children]
(fn [e]
(let [node (reagent/dom-node e)
state (:state (reagent/props e))
render-state (if inverse state (not state))]
(reset! instance (new iconToggle.MDCIconToggle node))
(set! (.-on @instance) render-state)
(swap! local-state update :count inc)
(when (< (:count @local-state) 3)
(js/ "add event")
(add-custom-event node "MDCIconToggle:change"
#(swap! local-state assoc :state (let [v (-> % .-detail .-isOn)]
(if inverse v (not v))))))))
(fn [props children]
{:class ""
:role "button"
:aria-pressed false
:aria-disabled false
:aria-label "Add to favorites"
:tab-index 0
(clj->js {:label "Remove from favorites"
:content "favorite"}))
(clj->js {:label "Add to favorites"
:content "favorite_border"}))}
(fn [e]
(let [state (:state (reagent/props e))
render-state (if inverse state (not state))]
(set! (.-on @instance) render-state)))
(fn []
(.destroy @instance))})))
(defn Radio [props children]
(fn [props children]
[:input.mdc-radio__native-control {:type :radio :id :radio-1 :name :radios :checked true}]
[:label {:id :radio-1-label :for :radio-1} "Radio Label"]
......@@ -3,6 +3,7 @@
[devcards.core :as dc])
(ns devcards.lernmeister.components.mcfw-card
[devcards.core :refer [defcard-doc
[lernmeister.components.sample-data :as data]
[lernmeister.components.content-elements.exercise :as exercise]
[lernmeister.components.ui :refer [Button Radio]]
[reagent.core :as reagent]))
(defonce appstate (reagent/atom {:count 0}))
(defn counter [state]
(let [count (:count @state)]
[:p "Current count: " count]
[Button {:class "mdc-button--raised"
:on-click #(swap! state update :count inc)} "+1" " " "+2"]]))
(defcard-rg counter
[counter appstate]
{:inspect-data true
:history true})
(defcard-rg form
[:input#input {:type :checkbox}]
[:label {:for :input} "Input Label"]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment