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="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="css/screen.css">
<link href="material-components.inc.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.js" 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))}]
[:div.mdc-form-field
[:input.mdc-radio__native-control
{:type "radio",
:id (:id o),
:name eid,
:disabled result,
:on-change #(on-change (:id o))
:checked (= answer (:id o))}]
[:label.black-text {: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
(cond
(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 "")}
[:div.card-content
[:div.mdc-card__content
[: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
(:require
[reagent.core :as reagent]
["@material/ripple" :refer [MDCRipple]]
["@material/icon-toggle" :as MDCIconToggle]))
(defn Button [props & children]
(let [instance (atom nil)]
(reagent/create-class
{:component-did-mount
(fn [e]
(let [node (reagent/dom-node e)]
(reset! instance (new MDCRipple node))))
:component-will-unmount (fn [e]
(swap! instance #(.destroy %)))
:reagent-render
(fn [props & children]
[:button.mdc-button props children])})))
#_(defn Icon-Toggle [props children]
(let [instance (atom nil)
inverse children]
(reagent/create-class
{:component-did-mount
(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/console.info "add event")
(add-custom-event node "MDCIconToggle:change"
#(swap! local-state assoc :state (let [v (-> % .-detail .-isOn)]
(if inverse v (not v))))))))
:reagent-render
(fn [props children]
[:i.material-icons.mdc-icon-toggle
{:class ""
:role "button"
:aria-pressed false
:aria-disabled false
:aria-label "Add to favorites"
:tab-index 0
:data-toggle-on
(js/JSON.stringify
(clj->js {:label "Remove from favorites"
:content "favorite"}))
:data-toggle-off
(js/JSON.stringify
(clj->js {:label "Add to favorites"
:content "favorite_border"}))}
"favorite_border"])
:component-did-update
(fn [e]
(let [state (:state (reagent/props e))
render-state (if inverse state (not state))]
(set! (.-on @instance) render-state)))
:component-will-unmount
(fn []
(.destroy @instance))})))
(defn Radio [props children]
(fn [props children]
[:div
[:div.mdc-radio
[:input.mdc-radio__native-control {:type :radio :id :radio-1 :name :radios :checked true}]
[:div.mdc-radio__background
[:div.mdc-radio__outer-circle]
[:div.mdc-radio__inner-circle]]
]
[:label {:id :radio-1-label :for :radio-1} "Radio Label"]
]
)
)
......@@ -3,6 +3,7 @@
[devcards.core :as dc])
(:require
[lernmeister.components.first-card]
[devcards.lernmeister.components.mcfw-card]
[devcards.lernmeister.components.tex-test-card]
[devcards.lernmeister.components.exercise-programming]
[devcards.lernmeister.components.exercise-editor-card]
......
(ns devcards.lernmeister.components.mcfw-card
(:require-macros
[devcards.core :refer [defcard-doc
defcard-rg
mkdn-pprint-source]])
(:require
[lernmeister.components.sample-data :as data]
[lernmeister.components.core]
[lernmeister.components.content-elements.exercise :as exercise]
[devcards.core]
[lernmeister.components.ui :refer [Button Radio]]
[reagent.core :as reagent]))
(defonce appstate (reagent/atom {:count 0}))
(defn counter [state]
(let [count (:count @state)]
[:div
[:p "Current count: " count]
[Button {:class "mdc-button--raised"
:on-click #(swap! state update :count inc)} "+1" " " "+2"]]))
(defcard-rg counter
[counter appstate]
appstate
{:inspect-data true
:history true})
(defcard-rg form
[:div
[:div.dc-form-field.mdc-form-field--align-end
[:input#input {:type :checkbox}]
[:label {:for :input} "Input Label"]
]
[Radio]]
)
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