Skip to content

Commit 201b68f

Browse files
authored
Merge pull request #12 from mvc-works/reuse-styles
reuse styles for rendering sidebar and markdown
2 parents 352fc09 + 518e1d1 commit 201b68f

File tree

13 files changed

+1358
-116
lines changed

13 files changed

+1358
-116
lines changed

.github/workflows/upload.yaml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Upload
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- main
8+
pull_request: {}
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Get yarn cache
17+
id: yarn-cache
18+
run: echo "::set-output name=dir::$(yarn cache dir)"
19+
20+
- uses: actions/cache@v2
21+
name: Cache node modules of yarn
22+
with:
23+
path: ${{ steps.yarn-cache.outputs.dir }}
24+
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
25+
restore-keys: |
26+
${{ runner.os }}-yarn-
27+
28+
- name: ACTIONS_ALLOW_UNSECURE_COMMANDS
29+
id: ACTIONS_ALLOW_UNSECURE_COMMANDS
30+
run: echo 'ACTIONS_ALLOW_UNSECURE_COMMANDS=true' >> $GITHUB_ENV
31+
32+
- name: add cr
33+
run: |
34+
mkdir -p $GITHUB_WORKSPACE/bin
35+
wget -O $GITHUB_WORKSPACE/bin/cr http://repo.calcit-lang.org/binaries/linux/cr
36+
chmod +x $GITHUB_WORKSPACE/bin/cr
37+
echo "::add-path::$GITHUB_WORKSPACE/bin"
38+
39+
- name: "prepare modules"
40+
run: >
41+
mkdir -p ~/.config/calcit/modules/ && cd ~/.config/calcit/modules/
42+
&& git clone https://github.com/calcit-lang/lilac.git
43+
&& git clone https://github.com/calcit-lang/memof.git
44+
&& git clone https://github.com/Respo/respo.calcit.git
45+
&& git clone https://github.com/Respo/reel.calcit.git
46+
&& git clone https://github.com/Respo/respo-markdown.calcit.git
47+
&& git clone https://github.com/Respo/respo-ui.calcit.git
48+
&& git clone https://github.com/Respo/respo-router.calcit.git
49+
50+
- name: "compiles to js"
51+
run: >
52+
cr --emit-js --once
53+
&& yarn && yarn vite build --base=./
54+
55+
- name: Deploy to server
56+
id: deploy
57+
uses: Pendect/action-rsyncer@v1.1.0
58+
env:
59+
DEPLOY_KEY: ${{secrets.rsync_private_key}}
60+
with:
61+
flags: '-avzr --progress'
62+
options: ''
63+
ssh_options: ''
64+
src: 'dist/*'
65+
dest: 'rsync-user@tiye.me:/web-assets/repo/${{ github.repository }}'
66+
67+
- name: Display status from deploy
68+
run: echo "${{ steps.deploy.outputs.status }}"

assets/calcit-tile.png

14.5 KB
Loading

assets/github-gist.css

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* GitHub Gist Theme
3+
* Author : Louis Barranqueiro - https://github.com/LouisBarranqueiro
4+
* https://raw.githubusercontent.com/isagalaev/highlight.js/master/src/styles/github-gist.css
5+
*/
6+
7+
.hljs {
8+
display: block;
9+
background: white;
10+
padding: 0.5em;
11+
color: #333333;
12+
overflow-x: auto;
13+
}
14+
15+
.hljs-comment,
16+
.hljs-meta {
17+
color: #969896;
18+
}
19+
20+
.hljs-string,
21+
.hljs-variable,
22+
.hljs-template-variable,
23+
.hljs-strong,
24+
.hljs-emphasis,
25+
.hljs-quote {
26+
color: #df5000;
27+
}
28+
29+
.hljs-keyword,
30+
.hljs-selector-tag,
31+
.hljs-type {
32+
color: #a71d5d;
33+
}
34+
35+
.hljs-literal,
36+
.hljs-symbol,
37+
.hljs-bullet,
38+
.hljs-attribute {
39+
color: #0086b3;
40+
}
41+
42+
.hljs-section,
43+
.hljs-name {
44+
color: #63a35c;
45+
}
46+
47+
.hljs-tag {
48+
color: #333333;
49+
}
50+
51+
.hljs-title,
52+
.hljs-attr,
53+
.hljs-selector-id,
54+
.hljs-selector-class,
55+
.hljs-selector-attr,
56+
.hljs-selector-pseudo {
57+
color: #795da3;
58+
}
59+
60+
.hljs-addition {
61+
color: #55a532;
62+
background-color: #eaffea;
63+
}
64+
65+
.hljs-deletion {
66+
color: #bd2c00;
67+
background-color: #ffecec;
68+
}
69+
70+
.hljs-link {
71+
text-decoration: underline;
72+
}

assets/main.css

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2+
@import url("./github-gist.css");
3+
@import url("../node_modules/github-markdown-css/github-markdown.css");
4+
@import url("../node_modules/cirru-color/assets/cirru.css");
5+
26
body {
37
margin: 0;
48
overscroll-behavior-y: none;
@@ -30,3 +34,34 @@ body * {
3034
::-webkit-resizer {
3135
background-color:transparent;
3236
}
37+
38+
pre {
39+
background-color: hsla(0, 0%, 96%, 0.5);
40+
border: 1px solid #eee;
41+
padding: 2px 8px;
42+
line-height: 1.4;
43+
min-width: 400px;
44+
}
45+
46+
.doc-entry:hover {
47+
background-color: hsla(190, 10%, 80%, 0.1);
48+
}
49+
50+
::-webkit-input-placeholder { /* Chrome/Opera/Safari */
51+
color: #ccc;
52+
}
53+
::-moz-placeholder { /* Firefox 19+ */
54+
color: #ccc;
55+
}
56+
:-ms-input-placeholder { /* IE 10+ */
57+
color: #ccc;
58+
}
59+
:-moz-placeholder { /* Firefox 18- */
60+
color: #ccc;
61+
}
62+
63+
64+
.calcit-tile {
65+
background-image: url('./calcit-tile.png');
66+
background-size: 163px 395px;
67+
}

calcit.cirru

Lines changed: 968 additions & 95 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compact.cirru

Lines changed: 132 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11

22
{} (:package |app)
33
:configs $ {} (:init-fn |app.main/main!) (:reload-fn |app.main/reload!)
4-
:modules $ [] |respo.calcit/ |lilac/ |memof/ |respo-ui.calcit/ |respo-markdown.calcit/ |reel.calcit/
4+
:modules $ [] |respo.calcit/ |lilac/ |memof/ |respo-ui.calcit/ |respo-markdown.calcit/ |reel.calcit/ |respo-router.calcit/
55
:version |0.0.1
66
:entries $ {}
77
:files $ {}
88
|app.comp.container $ {}
99
:ns $ quote
1010
ns app.comp.container $ :require (respo-ui.core :as ui)
11-
respo.core :refer $ defcomp defeffect <> >> div button textarea span input
11+
respo-ui.core :refer $ hsl
12+
respo.core :refer $ defcomp defeffect <> >> div button textarea span input list->
1213
respo.comp.space :refer $ =<
1314
reel.comp.reel :refer $ comp-reel
1415
respo-md.comp.md :refer $ comp-md
1516
app.config :refer $ dev?
17+
app.schema :refer $ docs
18+
"\"remarkable" :refer $ Remarkable
19+
"\"highlight.js" :default hljs
20+
"\"cirru-color" :as color
1621
:defs $ {}
1722
|comp-container $ quote
1823
defcomp comp-container (reel)
@@ -21,32 +26,136 @@
2126
states $ :states store
2227
cursor $ or (:cursor states) ([])
2328
state $ or (:data states)
24-
{} $ :content "\""
29+
{} $ :selected ([])
2530
div
26-
{} $ :style (merge ui/global ui/row)
27-
textarea $ {}
28-
:value $ :content state
29-
:placeholder "\"Content"
30-
:style $ merge ui/expand ui/textarea
31-
{} $ :height 320
32-
:on-input $ fn (e d!)
33-
d! cursor $ assoc state :content (:value e)
34-
=< 8 nil
35-
div
36-
{} $ :style ui/expand
37-
comp-md "|This is some content with `code`"
38-
=< |8px nil
39-
button $ {} (:style ui/button) (:inner-text "\"Run")
40-
:on-click $ fn (e d!)
41-
println $ :content state
31+
{} (:class-name "\"calcit-tile")
32+
:style $ merge ui/fullscreen ui/global ui/row
33+
list->
34+
{} $ :style
35+
merge ui/row $ {}
36+
:background-color $ hsl 0 0 94 0.8
37+
apply-args
38+
[]
39+
, docs ([]) (:selected state)
40+
fn (acc entries base-path selected)
41+
let
42+
base-path' base-path $ ; "\"problem in compiling tail recursions"
43+
next-acc $ conj acc
44+
[] (count acc)
45+
comp-sidebar
46+
>> states $ count acc
47+
first selected
48+
, entries $ fn (p d!)
49+
d! cursor $ assoc state :selected (conj base-path' p)
50+
if (empty? selected) next-acc $ let
51+
s0 $ first selected
52+
target $ find entries
53+
fn (entry)
54+
= s0 $ :key entry
55+
if
56+
or (nil? target)
57+
empty? $ get target :children
58+
, next-acc $ recur next-acc (get target :children) (conj base-path s0) (rest selected)
59+
let
60+
target $ find-target docs (:selected state)
61+
if (some? target)
62+
div
63+
{} $ :style
64+
merge ui/expand $ {} (:padding "\"8px 16px")
65+
:background-color $ hsl 0 0 100 0.6
66+
div $ {}
67+
:innerHTML $ .!render md (:content target)
68+
div
69+
{} $ :style
70+
merge ui/expand $ {} (:padding "\"20px 16px")
71+
do $ <> "\"Empty"
72+
{} (:font-family ui/font-fancy) (:font-style :italic)
73+
:color $ hsl 0 0 80
4274
when dev? $ comp-reel (>> states :reel) reel ({})
75+
|md $ quote
76+
def md $ new Remarkable
77+
js-object (:html false) (:breaks true)
78+
:highlight $ fn (code lang)
79+
if (= lang "\"cirru") (color/generate code)
80+
.-value $ .!highlightAuto hljs code lang
81+
|style-entry $ quote
82+
def style-entry $ {} (:padding "\"0 8px") (:cursor :pointer) (:transition-duration "\"200ms") (:line-height 2.4)
83+
:border-bottom $ str "\"1px solid " (hsl 0 0 92)
84+
:border-left $ str "\"0px solid " (hsl 200 90 60)
85+
:background-color $ hsl 0 0 100 0.6
86+
|comp-sidebar $ quote
87+
defcomp comp-sidebar (states selected entries on-select)
88+
let
89+
cursor $ :cursor states
90+
state $ or (:data states)
91+
{} $ :query "\""
92+
div
93+
{} $ :style
94+
{} (:min-width 200) (:max-width 240)
95+
:border-right $ str "\"1px solid " (hsl 0 0 94)
96+
input $ {}
97+
:style $ merge ui/input
98+
{} (:width "\"100%") (:border :none) (:line-height 32) (:height 32)
99+
:border-bottom $ str "\"1px solid " (hsl 0 0 90)
100+
:placeholder "\"Search..."
101+
:value $ :query state
102+
:on-input $ fn (e d!)
103+
d! cursor $ assoc state :query (:value e)
104+
list-> ({})
105+
-> entries
106+
filter $ fn (entry)
107+
if
108+
blank? $ :query state
109+
, true $ -> (:title entry) .!toLowerCase
110+
.includes? $ :query state
111+
map-indexed $ fn (idx entry)
112+
[] idx $ div
113+
{} (:class-name "\"doc-entry")
114+
:style $ merge style-entry
115+
if
116+
= selected $ :key entry
117+
{} (:background-color :white)
118+
:border-left $ str "\"10px solid " (hsl 200 90 70)
119+
:on-click $ fn (e d!)
120+
on-select (:key entry) d!
121+
<> $ :title entry
122+
|find-target $ quote
123+
defn find-target (entries path)
124+
if (empty? path) nil $ let
125+
p0 $ first path
126+
if-let
127+
target $ find entries
128+
fn (entry)
129+
= p0 $ :key entry
130+
if
131+
= 1 $ count path
132+
, target $ recur (:children target) (rest path)
133+
w-log nil
43134
|app.schema $ {}
44135
:ns $ quote (ns app.schema)
45136
:defs $ {}
46137
|store $ quote
47138
def store $ {}
48139
:states $ {}
49140
:cursor $ []
141+
|docs $ quote
142+
def docs $ []
143+
{} (:title "\"Guide") (:key :guide)
144+
:content $ load-doc "\"guide.md"
145+
{} (:title "\"Design") (:key :design)
146+
:content $ load-doc "\"design.md"
147+
:children $ []
148+
{} (:title "\"Guide") (:key :guide)
149+
:content $ load-doc "\"guide.md"
150+
{} (:title "\"Design") (:key :design)
151+
:content $ load-doc "\"design.md"
152+
{} (:title "\"Overview") (:key :overview)
153+
:content $ load-doc "\"overview.md"
154+
{} (:title "\"About") (:key :about)
155+
:content $ load-doc "\"about.md"
156+
|load-doc $ quote
157+
defmacro load-doc (filename)
158+
read-file $ str "\"docs/" filename
50159
|app.updater $ {}
51160
:ns $ quote
52161
ns app.updater $ :require
@@ -71,6 +180,9 @@
71180
app.config :as config
72181
"\"./calcit.build-errors" :default build-errors
73182
"\"bottom-tip" :default hud!
183+
"\"highlight.js" :default hljs
184+
"\"highlight.js/lib/languages/bash" :default bash-lang
185+
"\"highlight.js/lib/languages/clojure" :default clojure-lang
74186
:defs $ {}
75187
|render-app! $ quote
76188
defn render-app! () $ render! mount-target (comp-container @*reel) dispatch!
@@ -83,7 +195,7 @@
83195
|*reel $ quote
84196
defatom *reel $ -> reel-schema/reel (assoc :base schema/store) (assoc :store schema/store)
85197
|main! $ quote
86-
defn main! ()
198+
defn main! () (.!registerLanguage hljs "\"clojure" clojure-lang) (.!registerLanguage hljs "\"bash" bash-lang)
87199
println "\"Running mode:" $ if config/dev? "\"dev" "\"release"
88200
if config/dev? $ load-console-formatter!
89201
render-app!

docs/about.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
## About
3+
4+
about me.

docs/design.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
## design
3+
4+
Some design:
5+
6+
1. Like this.
7+
2. Like that.
8+
3. Then with that.

0 commit comments

Comments
 (0)