Skip to content

Commit

Permalink
adds name and description to toast, improves devcards. fixes #28
Browse files Browse the repository at this point in the history
  • Loading branch information
oliyh committed Mar 15, 2022
1 parent 413a430 commit 3866b47
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
8 changes: 8 additions & 0 deletions dev-resources/public/css/re-learn-test-overrides.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.toast {
position: relative;
display: inline-block;
}

.context-container {
position: relative;
}
9 changes: 7 additions & 2 deletions dev-resources/public/css/re-learn.css
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@
border-top-left-radius: 4px;
}

.toast .actions {
margin: 0 auto;
text-align: center;
}

.toast button {
margin-left: 4px;
padding: 4px;
Expand Down Expand Up @@ -144,12 +149,12 @@
z-index: 10000;
}

.tutorial-description {
.context-container .tutorial-description {
width: 40%;
display: inline-block;
}

.tutorial-description h2 {
.context-container .tutorial-description h2 {
margin-top: 0;
}

Expand Down
1 change: 1 addition & 0 deletions dev-resources/public/devcards/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta charset="UTF-8">
<link rel="stylesheet" href="/css/re-learn.css">
<link rel="stylesheet" href="/css/re-learn-test-overrides.css">
</head>
<body>
<script src="js/devcards.js" type="text/javascript"></script>
Expand Down
20 changes: 14 additions & 6 deletions src/re_learn/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,19 @@
[help-mode]
[lesson-view current-lesson]))))

(defn tutorial-toast [tutorial]
[:div.toast
[:h2
[:span.tutorial-name-prefix "Tutorial: "]
[:span.tutorial-name (get-in tutorial [:tutorial :name])]]
[:p.tutorial-description (get-in tutorial [:tutorial :description])]

[:div.actions
[:button.accept {:on-click #(re-frame/dispatch [::model/accept-tutorial (get-in tutorial [:tutorial :id])])}
"Start tutorial"]
[:button.dismiss {:on-click #(re-frame/dispatch [::model/skip-tutorial (get-in tutorial [:tutorial :id])])}
"Dismiss"]]])

(defn tutorial
"Root view for displaying unlearned tutorials on the page.
The :context? key allows you to turn on the context view which shows progress through the tutorial
Expand All @@ -181,12 +194,7 @@
[help-mode]

(and (false? auto-accept?) (false? (:accepted? @tutorial)))
[:div.toast
"There is a tutorial available"
[:button.accept {:on-click #(re-frame/dispatch [::model/accept-tutorial (get-in @tutorial [:tutorial :id])])}
"Start"]
[:button.dismiss {:on-click #(re-frame/dispatch [::model/skip-tutorial (get-in @tutorial [:tutorial :id])])}
"Dismiss"]]
[tutorial-toast @tutorial]

(or auto-accept? (:accepted? @tutorial))
[:div
Expand Down
3 changes: 3 additions & 0 deletions test/re_learn/devcards/context.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@

(defcard-rg lesson-bubble
[views/lesson-context context])

(defcard-rg tutorial-toast
[views/tutorial-toast @context])

0 comments on commit 3866b47

Please sign in to comment.