Skip to content

Commit

Permalink
Merge pull request #6 from Cirru/empty-expr
Browse files Browse the repository at this point in the history
updates; fix empty expr style
  • Loading branch information
NoEgAm authored Aug 15, 2023
2 parents 883ee71 + 27f9cad commit 88b5243
Show file tree
Hide file tree
Showing 7 changed files with 356 additions and 349 deletions.
47 changes: 16 additions & 31 deletions .github/workflows/upload.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,33 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3

- name: Get yarn cache
id: yarn-cache
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
name: Cache node modules of yarn
- uses: actions/setup-node@v3
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: ACTIONS_ALLOW_UNSECURE_COMMANDS
id: ACTIONS_ALLOW_UNSECURE_COMMANDS
run: echo 'ACTIONS_ALLOW_UNSECURE_COMMANDS=true' >> $GITHUB_ENV
node-version: 18
cache: 'yarn'

- name: add cr
run: |
mkdir -p $GITHUB_WORKSPACE/bin
wget -O $GITHUB_WORKSPACE/bin/cr https://github.com/calcit-lang/calcit/releases/download/0.6.0/cr
chmod +x $GITHUB_WORKSPACE/bin/cr
echo "::add-path::$GITHUB_WORKSPACE/bin"
- uses: supplypike/setup-bin@v3
with:
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.7.13/cr'
name: 'cr'
version: '0.7.13'

- name: "prepare modules"
run: >
mkdir -p ~/.config/calcit/modules/ && cd ~/.config/calcit/modules/
&& git clone https://github.com/calcit-lang/lilac.git
&& git clone https://github.com/calcit-lang/memof.git
&& git clone https://github.com/Respo/respo.calcit.git
&& git clone https://github.com/Respo/reel.calcit.git
&& git clone https://github.com/Respo/respo-ui.calcit.git
- uses: supplypike/setup-bin@v3
with:
uri: 'https://github.com/calcit-lang/calcit/releases/download/0.7.13/caps'
name: 'caps'
version: '0.7.13'

- name: "compiles to js"
run: >
cr --emit-js --once
caps --ci && cr --emit-js --once
&& yarn && yarn vite build --base=./
- name: Deploy to server
id: deploy
uses: Pendect/action-rsyncer@v1.1.0
uses: Pendect/action-rsyncer@v2.0.0
env:
DEPLOY_KEY: ${{secrets.rsync_private_key}}
with:
Expand Down
184 changes: 105 additions & 79 deletions calcit.cirru

Large diffs are not rendered by default.

53 changes: 30 additions & 23 deletions compact.cirru
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

{} (:package |calcit-theme)
:configs $ {} (:init-fn |calcit-theme.main/main!) (:reload-fn |calcit-theme.main/reload!) (:version |0.2.4)
:modules $ [] |memof/compact.cirru |lilac/compact.cirru |respo.calcit/compact.cirru |respo-ui.calcit/compact.cirru |reel.calcit/compact.cirru
:configs $ {} (:init-fn |calcit-theme.main/main!) (:reload-fn |calcit-theme.main/reload!) (:version |0.2.5)
:modules $ [] |memof/ |lilac/ |respo.calcit/ |respo-ui.calcit/ |reel.calcit/
:entries $ {}
:files $ {}
|calcit-theme.comp.container $ {}
Expand All @@ -11,7 +11,7 @@
let
store $ :store reel
states $ :states store
data $ parse-cirru (slurp "\"examples/demo.cirru")
data $ parse-cirru-list (slurp "\"examples/demo.cirru")
div
{} $ :class-name css-body
render-expr data
Expand All @@ -37,24 +37,26 @@
|comp-expr $ quote
defcomp comp-expr (expr tailing? root? inline?)
assert "\"expr in list" $ list? expr
div
list->
{} (:class-name css-expr)
:style $ merge (theme/decorate-expr tailing? inline? root?)
, & $ apply-args
apply-args
[] ([]) expr 0 nil
fn (acc xs idx prev-kind)
cond
empty? xs
, acc
(string? (first xs))
recur
conj acc $ comp-leaf (first xs) (&= 0 idx)
conj acc $ [] idx
comp-leaf (first xs) (&= 0 idx)
rest xs
inc idx
, :leaf
(&let (cursor (first xs)) (and (= 1 (count cursor)) (string? (first cursor))))
recur
conj acc $ comp-expr (first xs) false false true
conj acc $ [] idx
comp-expr (first xs) false false true
rest xs
inc idx
, :leaf
Expand All @@ -71,9 +73,10 @@
prev-kind $ raise "\"Unpected case"
, :expr
recur
conj acc $ comp-expr cursor
= (inc idx) (count expr)
, false (= layout-kind :inline-expr)
conj acc $ [] idx
comp-expr cursor
= (inc idx) (count expr)
, false $ = layout-kind :inline-expr
rest xs
inc idx
, layout-kind
Expand Down Expand Up @@ -113,20 +116,21 @@
|*reel $ quote
defatom *reel $ -> reel-schema/reel (assoc :base schema/store) (assoc :store schema/store)
|dispatch! $ quote
defn dispatch! (op op-data) (; println |Dispatch: op)
reset! *reel $ reel-updater updater @*reel op op-data
defn dispatch! (op) (; println |Dispatch: op)
reset! *reel $ reel-updater updater @*reel op
|main! $ quote
defn main! ()
println "\"Running mode:" $ if config/dev? "\"dev" "\"release"
render-app! render!
add-watch *reel :changes $ fn (reel prev) (render-app! render!)
listen-devtools! |a dispatch!
.!addEventListener js/window |beforeunload $ fn (event) (persist-storage!)
js/window.addEventListener |beforeunload $ fn (event) (persist-storage!)
repeat! 60 persist-storage!
let
raw $ .!getItem js/localStorage (:storage-key config/site)
raw $ js/localStorage.getItem (:storage-key config/site)
when (some? raw)
dispatch! :hydrate-storage $ extract-cirru-edn (js/JSON.parse raw)
dispatch! $ :: :hydrate-storage
extract-cirru-edn $ js/JSON.parse raw
println "|App started."
|mount-target $ quote
def mount-target $ .querySelector js/document |.app
Expand All @@ -143,7 +147,7 @@
hud! "\"error" build-errors
|render-app! $ quote
defn render-app! (renderer)
renderer mount-target (comp-container @*reel) (\ dispatch! % %2)
renderer mount-target (comp-container @*reel) dispatch!
|repeat! $ quote
defn repeat! (duration cb)
js/setTimeout
Expand Down Expand Up @@ -206,21 +210,24 @@
|style-expr $ quote
def style-expr $ {} (:display :block) (:border-radius "\"8px") (:color :white) (:vertical-align :top) (:padding "\"4px 4px 0px 8px") (:margin-left 8) (:margin-bottom 4) (:transition-duration "\"240ms") (:border-width "\"0 0 0 1px") (:border-style :solid)
:border-color $ hsl 0 0 100 0.3
:min-height 24
:min-width 8
|style-leaf $ quote
def style-leaf $ {} (:display :inline-block) (:text-align :top) (:font-family ui/font-code) (:margin "\"0 4px") (:padding "\"0 4px")
def style-leaf $ {} (:display :inline-block) (:vertical-align :top) (:font-family ui/font-code) (:margin "\"0 4px") (:padding "\"0 4px")
:color $ hsl 200 14 60
:ns $ quote
ns calcit-theme.theme $ :require ( respo-ui.core :as ui)
respo.util.format :refer $ [] hsl
|calcit-theme.updater $ {}
:defs $ {}
|updater $ quote
defn updater (store op op-data op-id op-time)
case-default op
do (js/console.warn "\"unknown op:" op) store
:states $ update-states store op-data
:content $ assoc store :content op-data
:hydrate-storage op-data
defn updater (store op op-id op-time)
tag-match op
:states cursor s
update-states store cursor s
(:content c) (assoc store :content c)
(:hydrate-storage d) d
_ $ do (eprintln "\"unknown op:" op) store
:ns $ quote
ns calcit-theme.updater $ :require
respo.cursor :refer $ update-states
3 changes: 3 additions & 0 deletions examples/demo.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ defn decorate-expr (expr tailing? root?)
{} (|:display |:inline-block) (|:border-left "\"none") (|:border-bottom "\"1px solid white")
|:nothing nil
|:else $ {} 1
list-match ([] 1 2 3)
() (a 1)
(x0 xs) (b 2)
7 changes: 7 additions & 0 deletions package.cirru
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{}
:dependencies $ {}
|calcit-lang/lilac |main
|calcit-lang/memof |main
|Respo/respo.calcit |main
|Respo/reel.calcit |main
|Respo/respo-ui.calcit |main
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"version": "0.2.4",
"dependencies": {
"@calcit/procs": "^0.6.0"
"@calcit/procs": "^0.7.13"
},
"devDependencies": {
"bottom-tip": "^0.1.3",
"vite": "^3.0.2"
"bottom-tip": "^0.1.5",
"vite": "^4.4.9"
}
}
Loading

0 comments on commit 88b5243

Please sign in to comment.