-
Notifications
You must be signed in to change notification settings - Fork 0
/
compact.cirru
1457 lines (1456 loc) · 67.6 KB
/
compact.cirru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{} (:package |respo-ui)
:configs $ {} (:init-fn |respo-ui.main/main!) (:reload-fn |respo-ui.main/reload!) (:version |0.6.2)
:modules $ [] |respo.calcit/ |lilac/ |memof/ |respo-router.calcit/ |respo-markdown.calcit/
:entries $ {}
:files $ {}
|respo-ui.comp $ %{} :FileEntry
:defs $ {}
|comp-attributes $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-attributes (options)
let
items $ &map:get options :items
item-width $ either (&map:get options :item-width) 160
item-height $ &map:get options :item-height
title $ &map:get options :title
ret $ list->
{}
:class-name $ &map:get options :class-name
:style $ merge
{} (:display :grid)
:grid-template-columns $ str "\"repeat(auto-fit, minmax(" item-width "\"px,1fr))"
:gap 8
&map:get options :style
-> items $ map-indexed
fn (idx info)
[] idx $ let
item $ cond
map? info
, info
(tuple? info)
tag-match info
:attr l v
{} (:value v) (:label l)
(:attr-span l v s)
{} (:value v) (:label l) (:span s)
true $ raise "\"unknown attribute info"
div
{}
:style $ {}
:grid-column $ let
sp $ &map:get item :span
if (some? sp) (str-spaced "\"span" sp) "\""
:class-name $ str-spaced style-item (&map:get options :css-item)
div
{} $ :class-name
str-spaced css-item-label $ &map:get options :css-label
<> $ &map:get item :label
div
{} $ :class-name (&map:get options :css-value)
let
v $ &map:get item :value
if (literal? v) (<> v) v
if (some? title)
div ({})
div
{} $ :class-name
str-spaced style-attributes-title $ &map:get options :css-title
<> title
, ret
, ret
|comp-catoptric-text $ %{} :CodeEntry (:doc "|by \"catoptric text\" I mean text added with CSS content, thus unsearchable from browser search or select. The text can still be grabbed from DOM tree though.")
:code $ quote
defcomp comp-catoptric-text (text ? options)
[] (effect-dataset-text text)
span $ {}
:class-name $ str-spaced style-catoptric (get options :class-name)
:style $ get options :style
|comp-cirru-snippet $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-cirru-snippet (text ? options)
div
{}
:class-name $ str-spaced css/row css-snippet (get options :class-name)
:style $ get options :style
pre $ {} (:class-name css/expand)
:innerHTML $ generateHtml text
span
{} $ :class-name style-copy-wrapper
comp-copy text $ fn (e d!) (copy! text)
|comp-close $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-close (? options)
span $ {} (:inner-text "\"✕")
:style $ get options :style
:class-name $ str-spaced style-close (get options :class-name)
:on-click $ get options :on-click
|comp-copy $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-copy (code ? f)
div
{}
:class-name $ str-spaced style-copy-outline style-copy-container
:on-click $ either f
fn (e d!) (copy! code)
div $ {} (:class-name style-copy-outline)
:style $ {} (:top -5) (:right -2)
|comp-placeholder $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-placeholder (text)
div
{} $ :class-name css-placeholder
<> text
|comp-snippet $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-snippet (code ? options)
div
{} $ :class-name
str-spaced css/row css-snippet $ :class-name options
pre $ {} (:class-name css/expand)
:style $ :style options
:inner-text code
span
{} $ :class-name style-copy-wrapper
comp-copy code $ fn (e d!) (copy! code)
|comp-tabs $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-tabs (options tabs on-route)
let
selected $ :selected options
vertical? $ :vertical? options
[] (effect-tab-highlight selected vertical?)
div
{}
:class-name $ str-spaced style-tabs (if vertical? css/column css/row) (get options :class-name)
:style $ merge
{} $ :width (:width options)
get options :style
div $ {}
:class-name $ str-spaced style-tab-highlight (if vertical? style-tab-vertical-highlight)
, & $ -> tabs
map $ fn (info)
let
item $ cond
tuple? info
, info
(map? info)
:: :tab
or (&map:get info :value) (&map:get info :name)
or (&map:get info :display) (&map:get info :title)
true $ raise "\"Unknown tab value"
tag-match item $
:tab value display
let
selected? $ = selected value
div
{}
:class-name $ str-spaced css-tab (get options :tab-class-name) (if selected? style-selected-tab)
:style $ merge (:tab-style options)
if selected? $ :selected-tab-style options
:on-click $ fn (e d!) (on-route item d!)
<> display
|comp-tag $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-tag (kind content ? options)
div
{}
:class-name $ str-spaced style-tag
case-default kind nil (:info style-tag-info) (:success style-tag-success) (:warning style-tag-warning) (:error style-tag-error)
:class-name options
:style $ :style options
:on-click $ either (:on-click options)
fn $ e d!
<> content
|comp-time $ %{} :CodeEntry (:doc "|pass a time in string(internally handled by dayjs)\n\nif is today, just show the time of today.\nif not today, only show date and week.\n\nneed to be extended in future...")
:code $ quote
defcomp comp-time (time & options) (.!extend dayjs is-today)
let
now $ dayjs time
mark $ if (.!isToday now)
str "\"Today " $ .!format now "\"HH:mm"
.!format now "\"MM-DD ddd"
span $ {} (:class-name css/font-fancy) (:title time) (:inner-text mark)
:on-click $ fn (e d!) (js/console.log :time time)
|css-item-label $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-item-label $ {}
"\"$0" $ {} (:font-weight 300) (:font-family ui/font-fancy) (:font-size 15) (:line-height "\"14px")
:color $ hsl 0 0 60
|css-placeholder $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-placeholder $ {}
"\"$0" $ merge ui/center
{} (:padding 16) (:font-family ui/font-fancy)
:color $ hsl 0 0 80
:font-size 12
:font-style :italic
|css-snippet $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-snippet $ {}
"\"&" $ {} (:font-family ui/font-code) (:white-space :pre) (:font-size 12) (:line-height "\"20px")
:color $ hsl 0 0 40
:padding "\"4px 32px 4px 6px"
:border $ str "\"1px solid " (hsl 0 0 90)
:border-radius "\"4px"
:margin 0
:position :relative
"\"& > pre" $ {} (:margin 0)
|css-tab $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-tab $ {}
"\"$0" $ {} (:padding "\"0 8px") (:font-family ui/font-normal) (:font-weight 300) (:cursor :pointer) (:font-size 14)
:color $ hsl 0 0 70
:line-height "\"24px"
:border-radius "\"2px"
"\"$0:hover" $ {}
:background-color $ hsl 0 0 98
|effect-dataset-text $ %{} :CodeEntry (:doc "|Respo does not support dataset from attribute, write with effect")
:code $ quote
defeffect effect-dataset-text (text) (action el at?)
if
or (= action :update) (= action :mount)
-> el .-dataset .-text $ set! text
|effect-tab-highlight $ %{} :CodeEntry (:doc |)
:code $ quote
defeffect effect-tab-highlight (selected vertical?) (action el at?)
when
or (= action :mount) (= action :update)
let
target $ .!querySelector el (str "\"." style-selected-tab)
cursor $ .!querySelector el (str "\"." style-tab-highlight)
if (some? target)
let
left $ - (.-offsetLeft target) 0
width $ .-clientWidth target
height $ .-clientHeight target
if vertical?
do
-> cursor .-style .-top $ set!
str (.-offsetTop target) "\"px"
-> cursor .-style .-bottom $ set! (str 0 "\"px")
-> cursor .-style .-height $ set! (str height "\"px")
do
-> cursor .-style .-left $ set! (str left "\"px")
-> cursor .-style .-width $ set! (str width "\"px")
if (not vertical?)
-> cursor .-style .-width $ set! (str 0 "\"px")
|literal? $ %{} :CodeEntry (:doc |)
:code $ quote
defn literal? (v)
or (string? v) (tag? v) (number? v) (bool? v)
|style-attributes-title $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-attributes-title $ {}
"\"$0" $ {} (:font-size 18) (:margin-bottom 6)
|style-catoptric $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-catoptric $ {}
"\"&::before" $ {} (:content "\"attr(data-text)")
|style-close $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-close $ {}
"\"&" $ {} (:font-size 16) (:line-height "\"16px") (:height "\"16px") (:font-weight 100)
:color $ hsl 0 90 70
:opacity 0.5
:cursor :pointer
:transition-duration "\"200ms"
:user-select :none
"\"&:hover" $ {} (:opacity 1)
"\"&:active" $ {} (:transform "\"scale(1.1)") (:transition-duration "\"0ms")
|style-copy-container $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-copy-container $ {}
"\"&" $ {} (:display :inline-block) (:margin "\"0 8px 0 4px")
"\"&:hover" $ {} (:transition-duration "\"200ms") (:transform "\"scale(1.06)")
|style-copy-outline $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-copy-outline $ {}
"\"&" $ {} (:position :relative) (:width 12) (:height 12) (:border-radius "\"2px")
:border $ str "\"1.5px solid " (hsl 0 0 80)
:cursor :pointer
:outline "\"1px solid white"
"\"&:active" $ {}
:border-color $ hsl 0 0 50
:transition-duration "\"0ms"
|style-copy-wrapper $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-copy-wrapper $ {}
"\"&" $ {} (:position :absolute) (:top 10) (:right 2)
|style-item $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-item $ {}
"\"$0" $ {} (:min-height 72)
:background-color $ hsl 0 0 99
:padding "\"8px"
:transition-duration "\"240ms"
:border-radius "\"4px"
"\"$0:hover" $ {}
:background-color $ hsl 0 0 100
:box-shadow $ str "\"0 0 4px 1px " (hsl 0 0 0 0.08)
|style-selected-tab $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-selected-tab $ {}
"\"&" $ {}
|style-tab-highlight $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-tab-highlight $ {}
"\"&" $ {} (:min-width 0) (:left 0) (:height 1)
:background-color $ hsl 200 60 80
:bottom 0
:position :absolute
:transition-duration "\"200ms"
:border-radius "\"2px"
(str "\"." style-tabs "\":hover &")
{} $ :height 3
|style-tab-vertical-highlight $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-tab-vertical-highlight $ {}
"\"div&" $ {} (:width 2) (:left 0)
(str "\"." style-tabs "\":hover div&")
{} $ :width 4
|style-tabs $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-tabs $ {}
"\"&" $ {} (:position :relative)
|style-tag $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-tag $ {}
"\"&" $ {} (:display :inline-block)
:background-color $ hsl 0 0 96
:border $ str "\"1px solid " (hsl 0 0 92)
:border-radius "\"4px"
:height "\"20px"
:line-height "\"20px"
:font-size 12
:padding "\"0px 8px"
:color $ hsl 0 0 64
:cursor :default
"\"&:hover" $ {}
:background-color $ hsl 0 0 94
"\"&:active" $ {} (:transform "\"translate(1px,1px)")
|style-tag-error $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-tag-error $ {}
"\"div&" $ {} (:color :white) (:border :none)
:background-color $ hsl 0 90 76
"\"div&:hover" $ {}
:background-color $ hsl 0 90 72
|style-tag-info $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-tag-info $ {}
"\"div&" $ {} (:color :white) (:border :none)
:background-color $ hsl 240 99 86
"\"div&:hover" $ {}
:background-color $ hsl 240 99 84
|style-tag-success $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-tag-success $ {}
"\"div&" $ {} (:color :white) (:border :none)
:color $ hsl 120 99 40
:background-color $ hsl 120 99 92
"\"div&:hover" $ {}
:background-color $ hsl 120 99 88
|style-tag-warning $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle style-tag-warning $ {}
"\"div&" $ {} (:color :white) (:border :none)
:color $ hsl 60 90 30
:background-color $ hsl 60 98 58
"\"div&:hover" $ {}
:background-color $ hsl 60 98 49
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns respo-ui.comp $ :require
respo.core :refer $ defcomp defeffect div list-> input textarea button span select option a <> pre
respo.comp.space :refer $ =<
respo-ui.core :as ui
respo.util.format :refer $ hsl
"\"cirru-color" :refer $ generateHtml
respo.css :refer $ defstyle
respo-ui.css :as css
"\"copy-text-to-clipboard" :default copy!
"\"dayjs" :default dayjs
"\"dayjs/plugin/isToday" :default is-today
|respo-ui.comp.components $ %{} :FileEntry
:defs $ {}
|comp-components-page $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-components-page (states)
let
state $ or (:data states) false
div
{} $ :style
{} $ :padding-bottom "\"50vh"
div ({}) (<> "|There are also components follow the guidelines of Respo UI:") (render-entry "\"https://github.com/Respo/alerts.calcit" "\"alerts") (render-entry "\"https://github.com/Respo/respo-feather.calcit" "\"respo-feather") (render-entry |https://github.com/Respo/respo-message.calcit "\"respo-message") (render-entry |https://github.com/Respo/respo-markdown.calcit "\"respo-markdown") (; render-entry |https://github.com/Respo/notifier.calcit "\"notifier")
comp-demo-attributes
comp-demo-tabs $ >> states :tabs
comp-demo-cirru-snippet
comp-demo-snippet
comp-demo-copy
comp-demo-time
comp-demo-tags
comp-demo-close
comp-demo-catoptric-text
comp-demo-placeholder
|comp-demo-attributes $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-demo-attributes () $ div
{} $ :class-name css/column
div
{} $ :class-name css-title
<> "\"Attributes demo"
=< nil 8
div
{} $ :class-name (str-spaced css/row css/gap8)
comp-cirru-snippet "\"respo-ui.comp/comp-attributes\n\n\ncomp-attributes $ {} (:title \"\\\"Attributes DEMO\")\n :items $ [] (:: :attr \"\\\"Demo\" \"\\\"content\")\n :: :attr \"\\\"Demo 2\" \"\\\"content 2\"\n :: :attr-span \"\\\"DEMO 2\" \"\\\"content 2\" 2\n :: :attr \"\\\"Demo 2\" \"\\\"content 2\"\n :: :attr \"\\\"Demo 2\" \"\\\"content 2\"\n :: :attr \"\\\"DEMO 3\" $ a\n {} (:inner-text \"\\\"Demo\")\n :href \"\\\"https://respo-mvc.org\"\n :target \"\\\"_blank\"\n" $ {}
:style $ {} (:flex 1)
div
{} $ :class-name css/flex
comp-attributes $ {} (:title "\"Attributes DEMO")
:items $ [] (:: :attr "\"Demo" "\"content") (:: :attr "\"Demo 2" "\"content 2") (:: :attr-span "\"DEMO 2" "\"content 2" 2) (:: :attr "\"Demo 2" "\"content 2") (:: :attr "\"Demo 2" "\"content 2")
:: :attr "\"DEMO 3" $ a
{} (:inner-text "\"Demo") (:href "\"https://respo-mvc.org") (:target "\"_blank")
|comp-demo-catoptric-text $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-demo-catoptric-text () $ div
{} $ :class-name css/column
div
{} $ :class-name css-title
<> "\"Catoptric demo"
=< nil 8
div
{} $ :class-name (str-spaced css/row css/gap8)
div
{} $ :class-name css/flex
comp-cirru-snippet "\"respo-ui.comp/comp-catoptric-text\n\ncomp-catoptric-text \"|Demo Text\" $ {}\n :style $ {}\n :class-name $ {}\n" $ {}
div
{}
:class-name $ str-spaced css/flex css/row
:style $ {} (:gap "\"8px")
comp-catoptric-text "\"DEMO Text"
|comp-demo-cirru-snippet $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-demo-cirru-snippet () $ div
{} $ :class-name css/column
div
{} $ :class-name css-title
<> "\"Cirru snippet demo"
=< nil 8
div
{} $ :class-name (str-spaced css/row css/gap8)
div
{} $ :class-name css/flex
comp-cirru-snippet "\"respo-ui.comp/comp-cirru-snippet\n\ncomp-cirru-snippet \"\\\"defn f (a b)\\n + a b\" $ {}\n :style $ {}\n :class-name style-demo"
div
{} $ :class-name (str-spaced css/flex css/column)
comp-snippet "\"@import url(cirru-color/assets/cirru.css);"
=< nil 8
comp-cirru-snippet "\"defn f (a b)\n + a b"
|comp-demo-close $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-demo-close () $ div
{} $ :class-name css/column
div
{} $ :class-name css-title
<> "\"Close demo"
=< nil 8
div
{} $ :class-name (str-spaced css/row css/gap8)
div
{} $ :class-name css/flex
comp-cirru-snippet "\"respo-ui.comp/comp-close\n\ncomp-close $ {}\n :style $ {}\n :class-name |\n :on-click nil" $ {}
div
{}
:class-name $ str-spaced css/flex css/row
:style $ {} (:gap "\"8px")
comp-close
|comp-demo-copy $ %{} :CodeEntry (:doc |)
:code $ quote
defn comp-demo-copy () $ div
{} $ :class-name css/column
div
{} $ :class-name css-title
<> "\"Copy demo"
=< nil 8
div
{} $ :class-name (str-spaced css/row css/gap8)
comp-cirru-snippet "\"respo-ui.comp/comp-copy\n\ncomp-copy \"|demo\"\ncomp-copy \"|demo\" $ fn (e d!)" $ {} (:flex 1)
div
{} $ :class-name css/flex
<> "\"demo demo"
comp-copy "\"DEMO TO COPY"
<> "\"demo demo"
|comp-demo-placeholder $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-demo-placeholder () $ div ({})
div
{} $ :class-name css-title
<> "\"Placeholder demo"
div
{} $ :class-name (str-spaced css/row css/gap8)
comp-cirru-snippet "\"respo-ui.comp/comp-placeholder\n\ncomp-placeholder \"|demo\"\ncomp-placeholder \"|中文\"" $ {} (:flex 1)
div
{} $ :class-name css/flex
comp-placeholder "\"This is a demo"
comp-placeholder "\"中文 Demo"
|comp-demo-snippet $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-demo-snippet () $ div
{} $ :class-name css/column
div
{} $ :class-name css-title
<> "\"Snippet demo"
=< nil 8
div
{} $ :class-name (str-spaced css/row css/gap8)
div
{} $ :class-name css/flex
comp-cirru-snippet "\"respo-ui.comp/comp-snippet\n\ncomp-snippet \"\\\"defn f (a b)\\n + a b\" $ {}\n :class-name style-demo\n :style $ {}" $ {}
div
{} $ :class-name css/flex
comp-cirru-snippet "\"defn f (a b)\n + a b" $ {}
|comp-demo-tabs $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-demo-tabs (states)
let
cursor $ :cursor states
state $ or (:data states)
{} $ :selected nil
en-tabs $ [] (:: :tab :book "\"Book") (:: :tab :card "\"Card") (:: :tab :pl "\"Programming language")
div ({})
div
{} $ :class-name css-title
<> "\"Tabs demo"
div
{} $ :class-name (str-spaced css/row css/gap8)
comp-cirru-snippet "\"respo-ui.comp/comp-tabs\n\ncomp-tabs\n {}\n :selected (:selected state)\n :style {}\n []\n :: :tab :book |Book\n :: :tab :card |Card\n :: :tab :pl \"|Programming language\"\n fn (info d!)\n println |selected info\n d! cursor $ assoc state :selected $ :name info" $ {} (:flex 1)
div
{} $ :class-name css/flex
comp-tabs
{} $ :selected (:selected state)
, en-tabs $ fn (info d!)
d! cursor $ assoc state :selected (nth info 1)
comp-tabs
{} $ :selected (:selected state)
[] (:: :tab :book "\"书本") (:: :tab :card "\"纸牌") (:: :tab :pl "\"编程语言")
fn (info d!)
d! cursor $ assoc state :selected (nth info 1)
comp-tabs
{}
:selected $ :selected state
:style $ {}
:border-bottom $ str "\"1px solid " (hsl 0 0 94)
, en-tabs $ fn (info d!) (println "\"selected" info)
d! cursor $ assoc state :selected (nth info 1)
=< nil 8
div
{} $ :class-name (str-spaced css/row css/gap8)
comp-cirru-snippet "\"respo-ui.comp/comp-tabs\n\ncomp-tabs\n &{} :selected (:selected state) :style ({}) :vertical? true :width 200\n , tabs\n fn (info d!)" $ {} (:flex 1)
div
{} $ :class-name css/flex
comp-tabs
{}
:selected $ :selected state
:vertical? true
:width 200
:style $ {}
, en-tabs $ fn (info d!) (println "\"selected" info)
d! cursor $ assoc state :selected (nth info 1)
|comp-demo-tags $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-demo-tags () $ div
{} $ :class-name css/column
div
{} $ :class-name css-title
<> "\"Tags demo"
=< nil 8
div
{} $ :class-name (str-spaced css/row css/gap8)
div
{} $ :class-name css/flex
comp-cirru-snippet "\"respo-ui.comp/comp-tag\n\ncomp-tag :info \"demo\"\n" $ {}
div
{}
:class-name $ str-spaced css/flex css/row
:style $ {} (:gap "\"8px")
comp-tag :info "\"info demo"
comp-tag :success "\"success demo"
comp-tag :warning "\"warning demo"
comp-tag :error "\"error demo"
comp-tag :default "\"default demo"
|comp-demo-time $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-demo-time () $ div
{} $ :class-name css/column
div
{} $ :class-name css-title
<> "\"Time demo"
=< nil 8
div
{} $ :class-name (str-spaced css/row css/gap8)
div
{} $ :class-name css/flex
comp-cirru-snippet "\"respo-ui.comp/comp-time\n\ncomp-time |2023-11-17T04:07:18.435Z $ {}\n :class-name |demo\n :on-click $ fn ()" $ {}
div
{} $ :class-name css/flex
div ({})
comp-time
.!toISOString $ new js/Date
{}
div ({})
comp-time "\"2023-11-07T06:23:49.688Z" $ {}
|css-title $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-title $ {}
"\"$0" $ {} (:margin-top 40) (:font-size 18) (:font-weight :bold)
:color $ hsl 0 0 10
|render-entry $ %{} :CodeEntry (:doc |)
:code $ quote
defn render-entry (url title)
div ({})
a $ {} (:href url) (:inner-text title)
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns respo-ui.comp.components $ :require
respo.core :refer $ defcomp >> div a <> pre code
respo.comp.space :refer $ =<
respo-ui.comp :refer $ comp-tabs comp-placeholder comp-cirru-snippet comp-button comp-attributes comp-snippet comp-time comp-tag comp-close comp-catoptric-text comp-copy
respo-ui.core :as ui
respo-ui.css :as css
respo.util.format :refer $ hsl
respo.css :refer $ defstyle
|respo-ui.comp.container $ %{} :FileEntry
:defs $ {}
|comp-container $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-container (store)
let
router $ either
first $ :path
either (:router store) ({})
:: :index
states $ :states store
div
{}
:class-name $ str-spaced css/preset css/global css/fullscreen css/row
:style $ {} (:padding-top 16)
comp-sidebar $ or (nth router 0) |index.html
div
{} $ :class-name (str-spaced css/expand css-content)
tag-match router
:index
comp-home
(:index) (comp-home)
(:widgets)
comp-widgets-page $ >> states :widgets
(:layouts) (comp-layouts-page)
(:fonts) (comp-fonts-page)
(:components)
comp-components-page $ >> states :components
(:utils) (comp-utils-page)
(:404 pp)
<> $ to-lispy-string router
_ $ do (eprintln "\"unknown router" router) (comp-home)
if dev? $ comp-inspect "\"Store" store
{} $ :bottom 0
|comp-utils-page $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-utils-page () $ div ({})
div ({}) (<> "\"Utils")
div
{} $ :class-name (str-spaced css/column css/gap8)
div ({}) (<> "\"tab-echo! to open new tab and show EDN data.")
div
{} $ :class-name (str-spaced css/row css/gap8)
div
{} $ :class-name (str-spaced css/row css/gap8)
button $ {} (:inner-text "\"Echo") (:class-name css/button)
:on-click $ fn (e d!)
tab-echo! $ {} (:type :message)
:demo $ {} (:a 1)
:vv $ range
js/Math.floor $ * 100 (js/Math.random)
comp-cirru-snippet "\"respo-ui.util/tab-echo! data" $ {}
div
{} $ :class-name (str-spaced css/row css/gap8)
div
{} $ :class-name (str-spaced css/row css/gap8)
button $ {} (:inner-text "\"Echo") (:class-name css/button)
:on-click $ fn (e d!)
tab-echo!
{} (:type :message)
:demo $ {} (:a 1)
:html "\"code <code> cc c cc </code>"
, :json
comp-cirru-snippet "\"respo-ui.util/tab-echo! data :json" $ {}
div
{} $ :class-name (str-spaced css/row css/gap8)
div
{} $ :class-name (str-spaced css/row css/gap8)
button $ {} (:inner-text "\"Echo") (:class-name css/button)
:on-click $ fn (e d!)
tab-echo!
{} (:type :message)
:demo $ {} (:a 1)
:html "\"code <code> cc c cc </code>"
, :edn
comp-cirru-snippet "\"respo-ui.util/tab-echo! data :edn" $ {}
|css-content $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-content $ {}
"\"$0" $ {} (:padding 8)
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns respo-ui.comp.container $ :require
respo.util.format :refer $ hsl
respo.core :refer $ defcomp >> div span input button <>
respo.comp.space :refer $ =<
respo.comp.inspect :refer $ comp-inspect
respo-ui.core :as ui
respo-ui.comp.sidebar :refer $ comp-sidebar
respo-ui.comp.home :refer $ comp-home
respo-ui.comp.widgets-page :refer $ comp-widgets-page
respo-ui.comp.layouts-page :refer $ comp-layouts-page
respo-ui.comp.fonts-page :refer $ comp-fonts-page
respo-ui.comp.components :refer $ comp-components-page
respo.css :refer $ defstyle
respo-ui.css :as css
respo-ui.config :refer $ dev?
respo-ui.util :refer $ tab-echo!
respo-ui.comp :refer $ comp-cirru-snippet
|respo-ui.comp.fonts-page $ %{} :FileEntry
:defs $ {}
|comp-fonts-page $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-fonts-page () $ div ({})
div
{} $ :style style-section
<> "|Normal fonts"
comp-md-block "|which can be used with `css/font-normal`. It's Hind fonts." $ {}
render-font-demo css/font-normal ui/font-normal 300
render-font-demo css/font-normal ui/font-normal 400
render-font-demo css/font-normal ui/font-normal 500
=< nil 32
div
{} $ :style style-section
<> "|Fancy fonts"
comp-md-block "|which can be used with `css/font-fancy`. Josefin Sans is used here." $ {}
render-font-demo css/font-fancy! ui/font-fancy 100
render-font-demo css/font-fancy! ui/font-fancy 300
render-font-demo css/font-fancy! ui/font-fancy 400
=< nil 32
div
{} $ :style style-section
<> "|Code fonts"
comp-md-block "|which can be used with `css/font-code`." $ {}
render-font-demo css/font-code ui/font-code 100
render-font-demo css/font-code ui/font-code 300
render-font-demo css/font-code ui/font-code 400
|css-demo $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-demo $ {}
"\"$0" $ {} (:font-size 16) (:font-weight |bold) (:line-height |32px)
|render-font-demo $ %{} :CodeEntry (:doc |)
:code $ quote
defn render-font-demo (css-family family weight)
div
{}
:class-name $ str-spaced css-family css-demo
:style $ {} (:font-weight weight)
<> $ str "|This is a demo of the font, guess what you like: " family "| " weight
|style-section $ %{} :CodeEntry (:doc |)
:code $ quote
def style-section $ {} (:font-size 24) (:font-family ui/font-fancy) (:line-height |60px)
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns respo-ui.comp.fonts-page $ :require
respo.core :refer $ defcomp div <>
respo-ui.css :as css
respo-ui.core :as ui
respo.comp.space :refer $ =<
respo-md.comp.md :refer $ comp-md-block
respo.css :refer $ defstyle
|respo-ui.comp.home $ %{} :FileEntry
:defs $ {}
|comp-home $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-home () $ div ({})
div
{} $ :style style-home
<> "|Styles for Respo"
=< nil 32
div ({})
comp-md-block "|Respo UI is some minimal style collections for creating small pieces of apps. It includes variables for Flexbox layouts, basic button and input styles, fonts like \"Josefin Sans\" and \"Hind\".\n\nYou may read code on [GitHub](http://github.com/Respo/respo-ui). [Fonts files](https://github.com/tiye/favored-fonts) are hosted separately on my server." $ {}
|style-home $ %{} :CodeEntry (:doc |)
:code $ quote
def style-home $ {} (:font-size 32) (:font-family "|Josefin Sans")
:color $ hsl 200 100 76
:font-weight 100
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns respo-ui.comp.home $ :require
respo.core :refer $ defcomp div a img <>
respo.comp.space :refer $ =<
respo.util.format :refer $ hsl
respo-md.comp.md :refer $ comp-md-block
|respo-ui.comp.layouts-page $ %{} :FileEntry
:defs $ {}
|comp-layouts-page $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-layouts-page () $ div ({})
div ({}) (<> |Layouts)
comp-md-block "|Flexbox styles are defined in variables like `css/row` `css/center` in flex containers. Here are how they take effects." $ {}
div
{} (:class-name css/row)
:style $ {} (:flex-wrap :wrap) (:font-family ui/font-code) (:font-size 12)
render-demo |center css/center
render-demo |row-center css/row-center
render-demo |row-middle css/row-middle
render-demo |row css/row
render-demo |column css/column
render-demo |row-parted css/row-parted
render-demo |column-parted css/column-parted
render-demo |row-dispersive css/row-dispersive
render-demo |column-dispersive css/column-dispersive
render-demo |row-evenly css/row-evenly
render-demo |column-evenly css/column-evenly
|css-sample $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-sample $ {}
"\"$0" $ {} (:padding "|4px 8px") (:font-size 12) (:line-height "\"20px") (:font-family ui/font-code) (:border-radius "\"4px")
:border $ str "\"1px solid " (hsl 0 0 80)
:color $ hsl 0 0 30
|render-demo $ %{} :CodeEntry (:doc |)
:code $ quote
defn render-demo (title layout-cls)
div
{} $ :style
{} $ :margin 16
div
{} $ :style ({})
<> title
div
{} (:class-name layout-cls)
:style $ {}
:border $ str "|1px solid " (hsl 0 0 86)
:width 120
:height 120
div
{} (:class-name css-sample)
:style $ {}
; :background-color $ hsl 0 80 70
<> |A
div
{} (:class-name css-sample)
:style $ {}
; :background-color $ hsl 120 80 70
<> |B
div
{} (:class-name css-sample)
:style $ {}
; :background-color $ hsl 240 80 80
<> |C
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns respo-ui.comp.layouts-page $ :require
respo.core :refer $ defcomp div a <>
respo.comp.space :refer $ =<
respo-ui.core :as ui
respo.util.format :refer $ hsl
respo-md.comp.md :refer $ comp-md-block
respo.css :refer $ defstyle
respo-ui.css :as css
|respo-ui.comp.sidebar $ %{} :FileEntry
:defs $ {}
|comp-sidebar $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-sidebar (router-name)
div
{} $ :style
{} (:width 160) (:margin-right 24)
div
{} $ :style
{} $ :text-align :right
div $ {} (:style style-logo)
=< nil 16
render-entry |index.html "|Respo UI" $ = :index router-name
render-entry |layouts.html |Layouts $ = :layouts router-name
render-entry |widgets.html |Widgets $ = :widgets router-name
render-entry |fonts.html |Fonts $ = :fonts router-name
render-entry |components.html |Components $ = :components router-name
render-entry |utils.html |Utils $ = :utils router-name
|css-sidebar-entry $ %{} :CodeEntry (:doc |)
:code $ quote
defstyle css-sidebar-entry $ {}
"\"$0" $ {} (:line-height |40px) (:font-size 20) (:cursor |pointer) (:font-weight "\"lighter") (:font-family ui/font-fancy) (:text-align :right) (:padding "|0 16px")
:color $ hsl 0 0 20
"\"$0:hover" $ {}
:background-color $ hsl 0 0 97
|on-route $ %{} :CodeEntry (:doc |)
:code $ quote
defn on-route (path-name)
fn (e dispatch!) (dispatch! :router/nav path-name)
|render-entry $ %{} :CodeEntry (:doc |)
:code $ quote
defn render-entry (path title selected?)
div
{} (:class-name css-sidebar-entry)
:style $ if selected?
{} $ :background-color (hsl 0 0 50 0.1)
:on-click $ on-route path
<> title
|style-logo $ %{} :CodeEntry (:doc |)
:code $ quote
def style-logo $ {} (:background-image "|url(https://cos-sh.tiye.me/cos-up/bb4c2755050318e864b56f59145d726e-SubstractRespo.png)") (:width 80) (:height 80) (:background-size :cover) (:display :inline-block) (:vertical-align :text-bottom)
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns respo-ui.comp.sidebar $ :require
respo.core :refer $ defcomp div <>
respo-ui.core :as ui
respo.util.format :refer $ hsl
respo.comp.space :refer $ =<
respo.css :refer $ defstyle
|respo-ui.comp.widgets-page $ %{} :FileEntry
:defs $ {}
|comp-tags-styles $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-tags-styles () $ div
{} $ :class-name (str-spaced css/row-middle css/gap8)
span $ {} (:inner-text "\"css/tag") (:class-name css/tag)
span $ {} (:inner-text "\"css/tag-stroke") (:class-name css/tag-stroke)
span $ {} (:inner-text "\"css/tag-outline") (:class-name css/tag-outline)
|comp-widgets-page $ %{} :CodeEntry (:doc |)
:code $ quote
defcomp comp-widgets-page (states)
let
cursor $ :cursor states
state $ :data states
div ({})
div ({}) (<> |Widgets)
div ({}) (<> "|link to external pages" ui/text-label) (=< nil 16)
a $ {} (:class-name css/link) (:inner-text |link)
div ({}) (<> "|slight link without underscore" ui/text-label) (=< nil 16)
a $ {} (:class-name css/link-slight) (:inner-text |link)
=< nil 16
div
{} $ :style
merge ui/row $ {} (:gap 16)
button
{} $ :class-name css/button-primary
<> |css/button-primary
button
{} $ :class-name css/button
<> |css/button
button
{} (:class-name css/button)
:style $ {}
:border-color $ hsl 6 100 60
:color $ hsl 6 100 60
<> |css/button
button
{} $ :class-name css/button-danger
<> |css/button-danger
=< nil 16
div ({})
input $ {} (:placeholder "|Some short text") (:value state) (:class-name css/input)
:on $ {}
:input $ fn (e dispatch!)
dispatch! cursor $ :value e
=< 16 nil
button
{} $ :class-name css/button
<> |Add
=< 16 nil
<> |nothing ui/text-label
=< nil 16
div ({})
select
{} $ :class-name css/select
option $ {} (:selected true) (:inner-text |Haskell)
option $ {} (:selected true) (:inner-text |Clojure)
option $ {} (:selected false) (:inner-text |OCaml)
=< nil 16
div ({})
textarea $ {} (:placeholder "|Some long text") (:class-name css/textarea)
=< 16 nil
button
{} $ :class-name css/button
<> |Add
div $ {}
:style $ {} (:height 1) (:width "\"50%")
:background-color $ hsl 0 0 90
:margin "\"48px 12px"
comp-tags-styles
:ns $ %{} :CodeEntry (:doc |)
:code $ quote
ns respo-ui.comp.widgets-page $ :require
respo.core :refer $ defcomp div input textarea button span select option a <>
respo.comp.space :refer $ =<
respo-ui.core :as ui
respo-ui.css :as css
respo.util.format :refer $ hsl
|respo-ui.config $ %{} :FileEntry
:defs $ {}
|dev? $ %{} :CodeEntry (:doc |)
:code $ quote
def dev? $ &= "\"dev" (get-env "\"mode" "\"release")
|site $ %{} :CodeEntry (:doc |)
:code $ quote
def site $ {} (:title "\"Respo UI") (:icon "\"http://cdn.tiye.me/logo/respo.png") (:storage-key "\"respo-ui")