Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ jobs:
bash <(curl https://raw.githubusercontent.com/babashka/babashka/master/install) --dev-build --dir /tmp
/tmp/bb test:bb

- name: Run vhs
run: |
sudo apt-get -qq update
sudo apt-get -qq install -y ffmpeg ttyd
go install github.com/charmbracelet/vhs@v0.11.0
cd doc/examples/
${HOME}/go/bin/vhs vhs/pomodoro.tape
${HOME}/go/bin/vhs vhs/download.tape
# - name: Run vhs
# run: |
# sudo apt-get -qq update
# sudo apt-get -qq install -y ffmpeg ttyd
# go install github.com/charmbracelet/vhs@v0.11.0
# cd doc/examples/
# ${HOME}/go/bin/vhs vhs/pomodoro.tape
# ${HOME}/go/bin/vhs vhs/download.tape

- name: Build JAR
run: clojure -T:build jar
Expand Down
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
cider/cider-nrepl {:mvn/version "0.58.0"}}
:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}

:examples {:extra-paths ["doc"]}
:examples {:extra-deps {charm/examples {:local/root "doc/examples"}}}

:user {:extra-paths ["user"]}

Expand Down
4 changes: 4 additions & 0 deletions doc/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ bb cheatsheet
```
![cheatsheet gif](images/cheatsheet.gif)
```
bb talk
```
![talk gif](images/talk.gif)
```
bb pomodoro
```
![pomodoro gif](images/pomodoro.gif)
Expand Down
24 changes: 19 additions & 5 deletions doc/examples/bb.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{:paths ["src" "../../src"]
{:paths ["src" "../../src" "resources"]
:deps {djblue/portal {:mvn/version "0.58.5"}}
:tasks
{cheatsheet {:doc "Run cheatsheet example"
:task (exec 'examples.cheatsheet/-main)}
Expand All @@ -21,6 +22,9 @@
form {:doc "Run form example"
:task (exec 'examples.form/-main)}

talk {:doc "Run talk example"
:task (exec 'examples.talk/-main)}

pomodoro {:doc "Run pomodoro example"
:task (exec 'examples.pomodoro/-main)}

Expand All @@ -36,17 +40,27 @@

todos {:doc "Run todos example"
:task (exec 'examples.todos/-main)}

recreate-gifs {:doc "Recreate all gifs with vhs"
:task (do (shell "vhs vhs/cheatsheet.tape")
(shell "vhs vhs/countdown.tape")
(shell "vhs vhs/counter.tape")
#_(shell "vhs vhs/emojis.tape")
(shell "vhs vhs/download.tape")
(shell "vhs vhs/file-browser.tape")
(shell "vhs vhs/file_browser.tape")
(shell "vhs vhs/form.tape")
(shell "vhs vhs/pomodoro.tape")
(shell "vhs vhs/sketch.tape")
(shell "vhs vhs/spinner.tape")
#_(shell "vhs vhs/timer.tape")
(shell "vhs vhs/todos.tape"))}}}
(shell "vhs vhs/timer.tape")
(shell "vhs vhs/todos.tape"))}

portal {:doc "Start nREPL server with portal + tap> wired up"
:requires ([babashka.nrepl.server :as nrepl]
[portal.api :as p])
:task (do
(p/open)
(add-tap p/submit)
(println "Portal opened. nREPL on localhost:1667")
(nrepl/start-server! {:port 1667})
(deref (promise)))}}}
2 changes: 1 addition & 1 deletion doc/examples/deps.edn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{:paths ["src"]
{:paths ["src" "resources"]
:deps {de.timokramer/charm.clj {:local/root "../../"}
com.github.clj-easy/graal-build-time {:mvn/version "1.0.5"}}
:aliases
Expand Down
Binary file modified doc/examples/images/cheatsheet.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/examples/images/emojis.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/examples/images/talk.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions doc/examples/resources/talk/slide01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
__ __ _ _ _ _
\ \ / / __(_) |_ ___ ___| |__ __ _ _ __ _ __ ___ (_)_ __ __ _
\ \ /\ / / '__| | __/ _ \ / __| '_ \ / _` | '__| '_ ` _ \| | '_ \ / _` |
\ V V /| | | | || __/ | (__| | | | (_| | | | | | | | | | | | | (_| |
\_/\_/ |_| |_|\__\___| \___|_| |_|\__,_|_| |_| |_| |_|_|_| |_|\__, |
|___/
_____ _ _ ___ _ _ _ _ _
|_ _| | | |_ _|___ (_)_ __ | |__ __ _| |__ __ _ ___| |__ | | ____ _
| | | | | || |/ __| | | '_ \ | '_ \ / _` | '_ \ / _` / __| '_ \| |/ / _` |
| | | |_| || |\__ \ | | | | | | |_) | (_| | |_) | (_| \__ \ | | | < (_| |
|_| \___/|___|___/ |_|_| |_| |_.__/ \__,_|_.__/ \__,_|___/_| |_|_|\_\__,_|

by Timo Kramer
6 changes: 6 additions & 0 deletions doc/examples/resources/talk/slide02.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
_____ _ _ _ _
|_ _| |__ ___ | |__ ___ __ _(_)_ __ _ __ (_)_ __ __ _
| | | '_ \ / _ \ | '_ \ / _ \/ _` | | '_ \| '_ \| | '_ \ / _` |
| | | | | | __/ | |_) | __/ (_| | | | | | | | | | | | | (_| |
|_| |_| |_|\___| |_.__/ \___|\__, |_|_| |_|_| |_|_|_| |_|\__, |
|___/ |___/
13 changes: 13 additions & 0 deletions doc/examples/resources/talk/slide03.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
_ _ _ _
(_) (_)_ __ ___ __ _ _ __ __| |
| | | | '_ \ / _ \ / _` | '_ \ / _` |
| | | | | | | __/ | (_| | | | | (_| |
_/ |_|_|_| |_|\___| \__,_|_| |_|\__,_|
|__/
_ _ _ _
___| |__ __ _ _ __ _ __ ___ | |__ _ __ __ _ ___ ___| | ___| |_
/ __| '_ \ / _` | '__| '_ ` _ \| '_ \| '__/ _` |/ __/ _ \ |/ _ \ __|
| (__| | | | (_| | | | | | | | | |_) | | | (_| | (_| __/ | __/ |_
\___|_| |_|\__,_|_| |_| |_| |_|_.__/|_| \__,_|\___\___|_|\___|\__|

😈😊🏳️‍🌈🙂‍↔️👨‍👩‍👧🇳🇱👍🏿
12 changes: 12 additions & 0 deletions doc/examples/resources/talk/slide04.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
____ _ _ _
| __ ) __ _| |_| |_ ___ _ __(_) ___ ___
| _ \ / _` | __| __/ _ \ '__| |/ _ \/ __|
| |_) | (_| | |_| || __/ | | | __/\__ \
|____/ \__,_|\__|\__\___|_| |_|\___||___/

_ _ _ _
(_)_ __ ___| |_ _ __| | ___ __| |
| | '_ \ / __| | | | |/ _` |/ _ \/ _` |
| | | | | (__| | |_| | (_| | __/ (_| |
|_|_| |_|\___|_|\__,_|\__,_|\___|\__,_|

12 changes: 12 additions & 0 deletions doc/examples/resources/talk/slide05.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
____ _____ ____ _
| _ \| ____| _ \| |
| |_) | _| | |_) | |
| _ <| |___| __/| |___
|_| \_\_____|_| |_____|

_ _ _
__| | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_
/ _` |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __|
| (_| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_
\__,_|\___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__|
|_|
7 changes: 7 additions & 0 deletions doc/examples/resources/talk/slide06.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
___ _
/ _ \__ _____ _ __| | __ _ _ _
| | | \ \ / / _ \ '__| |/ _` | | | |
| |_| |\ V / __/ | | | (_| | |_| |
\___/ \_/ \___|_| |_|\__,_|\__, |
|___/

6 changes: 6 additions & 0 deletions doc/examples/resources/talk/slide07.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
_ _ _ _
/ \ _ __ (_)_ __ ___ __ _| |_(_) ___ _ __ ___
/ _ \ | '_ \| | '_ ` _ \ / _` | __| |/ _ \| '_ \/ __|
/ ___ \| | | | | | | | | | (_| | |_| | (_) | | | \__ \
/_/ \_\_| |_|_|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/

6 changes: 6 additions & 0 deletions doc/examples/resources/talk/slide08.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
____ _ _ _
| _ \ __ _ __ _(_)_ __ __ _| |_(_) ___ _ __
| |_) / _` |/ _` | | '_ \ / _` | __| |/ _ \| '_ \
| __/ (_| | (_| | | | | | (_| | |_| | (_) | | | |
|_| \__,_|\__, |_|_| |_|\__,_|\__|_|\___/|_| |_|
|___/
6 changes: 6 additions & 0 deletions doc/examples/resources/talk/slide09.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
_____ _ _
| ____|_ __ ___ ___ (_|_)___
| _| | '_ ` _ \ / _ \| | / __|
| |___| | | | | | (_) | | \__ \
|_____|_| |_| |_|\___// |_|___/
|__/
50 changes: 17 additions & 33 deletions doc/examples/src/examples/pomodoro.clj
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
[charm.components.timer :as timer]
[charm.message :as msg]
[charm.program :as program]
[charm.style.core :as style]
[clojure.string :as str])
[charm.style.core :as style])
(:gen-class))

;; ---------------------------------------------------------------------------
Expand Down Expand Up @@ -96,11 +95,12 @@
(style/render hint-style "↑/↓ to select, Enter to start, q to quit"))))

;; ---------------------------------------------------------------------------
;; View - Timer Running
;; View - Timer
;; ---------------------------------------------------------------------------

(defn view-running [state]
(let [{:keys [phase timer total-ms cycle-count]} state
(defn view-timer [state]
(let [{:keys [phase timer total-ms cycle-count screen]} state
paused? (= screen :paused)
remaining (max 0 (timer/timeout timer))
elapsed (- total-ms remaining)
p (if (pos? total-ms) (/ elapsed total-ms) 0.0)
Expand All @@ -112,48 +112,24 @@
:empty-style (style/style :fg (gradient-color p phase true)))]
(str (style/render (phase-style phase) phase-label)
(style/render hint-style (str " (cycle " cycle-count ")"))
(when paused? " ")
(when paused? (style/render (style/style :fg (style/rgb 255 200 100) :bold true) "PAUSED"))
"\n\n"
(progress/progress-view bar)
" "
(style/render time-style (format-remaining remaining))
"\n\n"
(style/render hint-style "p to pause/resume, q to quit"))))

;; ---------------------------------------------------------------------------
;; View - Paused
;; ---------------------------------------------------------------------------

(defn view-paused [state]
(let [{:keys [phase timer total-ms cycle-count]} state
remaining (max 0 (timer/timeout timer))
elapsed (- total-ms remaining)
p (if (pos? total-ms) (/ elapsed total-ms) 0.0)
phase-label (if (= phase :work) "WORK" "BREAK")
bar (progress/progress-bar :width 30
:percent p
:bar-style :thick
:full-style (style/style :fg (gradient-color p phase))
:empty-style (style/style :fg (gradient-color p phase true)))]
(str (style/render (phase-style phase) phase-label)
(style/render hint-style (str " (cycle " cycle-count ")"))
" "
(style/render (style/style :fg (style/rgb 255 200 100) :bold true) "PAUSED")
"\n\n"
(progress/progress-view bar)
" "
(style/render time-style (format-remaining remaining))
"\n\n"
(style/render hint-style "p to resume, q to quit"))))

;; ---------------------------------------------------------------------------
;; Main View
;; ---------------------------------------------------------------------------

(defn view [state]
(case (:screen state)
:selecting (view-selecting state)
:running (view-running state)
:paused (view-paused state)))
:running (view-timer state)
:paused (view-timer state)))

;; ---------------------------------------------------------------------------
;; Timer Helpers
Expand All @@ -180,6 +156,7 @@
;; ---------------------------------------------------------------------------

(defn update-fn [state msg]
(tap> state)
(let [{:keys [screen]} state]
(cond
;; Global quit
Expand Down Expand Up @@ -269,3 +246,10 @@
:alt-screen false
:hide-cursor true})
(println))))

(comment
(def app (program/run-async {:init init
:update #'update-fn
:view #'view
:alt-screen false
:hide-cursor true})))
Loading
Loading