-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme.lisp
340 lines (294 loc) · 9.72 KB
/
theme.lisp
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
(defpackage #:40ants-doc-theme-40ants
(:use #:cl)
(:import-from #:lass)
(:import-from #:40ants-doc-full/themes/api)
(:import-from #:40ants-doc-full/themes/default
#:default-theme)
(:import-from #:40ants-doc-full/commondoc/html
#:with-html)
(:import-from #:alexandria
#:when-let*)
(:import-from #:40ants-doc-full/builder)
(:import-from #:40ants-doc-full/github)
(:nicknames #:40ants-doc-theme-40ants/theme)
(:export #:40ants-theme))
(in-package 40ants-doc-theme-40ants)
(defparameter *google-analytics-code* "
<!-- Google tag (gtag.js) -->
<script async src=\"https://www.googletagmanager.com/gtag/js?id=G-FL71WXK73K\"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-FL71WXK73K');
</script>
")
(defparameter *yandex-metrics-code* "
<!-- Yandex.Metrika counter -->
<script type=\"text/javascript\" >
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
(window, document, \"script\", \"https://mc.yandex.ru/metrika/tag.js\", \"ym\");
ym(42462884, \"init\", {
clickmap:true,
trackLinks:true,
accurateTrackBounce:true
});
</script>
<noscript><div><img src=\"https://mc.yandex.ru/watch/42462884\" style=\"position:absolute; left:-9999px;\" alt=\"\" /></div></noscript>
<!-- /Yandex.Metrika counter -->
")
(defclass 40ants-theme (default-theme)
())
(defmethod 40ants-doc-full/themes/api:render-html-head ((theme 40ants-theme) uri title)
(call-next-method)
(with-html
(:raw *google-analytics-code*)
(:raw *yandex-metrics-code*)))
(defmethod 40ants-doc-full/themes/api:render-css ((theme 40ants-theme))
(let ((toc-back "#FFFEFB")
(orange "#E78B24"))
(concatenate
'string
(call-next-method)
(lass:compile-and-write
`(body
:font-family "\"Lora\",Georgia,\"Times New Roman\",Times,serif"
:font-size 17px
:line-height 26px
:color "#333"
((:or |#sidebar-check|
|#sidebar-trigger|)
:display none)
((:or h1 h2 h3 h4 h5 h6 h7)
:color ,orange
:border-bottom none)
(.sidebar
:background ,toc-back
:box-shadow inset -3px 0 3px 0px "#777"
:transition all .4s
(.page-toc
(a
:color "#333"))
(.toc-active
:background "rgba(0,0,0,0)"
:box-shadow 0 0 0
:border-left 10px solid ,orange
:margin-left 0))
(.navbar
:margin-top 2em
:margin-bottom 26px
:margin-left 44ex
:max-width 70%
:overflow visible
(a
:border-bottom none)
(.navbar-inner
:min-height 60px
:padding-right 20px
:padding-left 20px
:display flex
:flex-wrap nowrap
:border 1px solid "#d7d7d7"
:border-radius 4px
:box-shadow 0 1px 4px "rgb(0 0 0 / 7%)")
(.nav
:left 0
:display flex
:margin 0 10px 0 0
:list-style none
(li
:text-align center
(a
:display inline-block
:padding 17px 15px 17px
:color "#333"
:text-decoration none
:text-shadow 0 1px 0 "#f6f6f6")))
(.brand
:padding 0
:margin -5px 0 0 -15px
:display block)
((.brand > .logo)
:width 60px))
((.page > .footer)
:margin-left 44ex
:margin-right 44ex
(.fineprint
:font-size smaller)
(.separator
:margin 26px 0
:height 1px
:linear-gradient left "rgba(0,0,0,0)" 0% "rgba(0,0,0,0.75)" 50% "rgba(0,0,0,0)" 100%)
(.lisp-logo
:float right
:margin-right 1em
:margin-top -0.5em
:border none)
((.lisp-logo img)
:width 60px))
;; I use this class on tables with GitHub badges
(.badges
(a
:border-bottom none))
;; This code renders a GitHub stripe if ASDF system's github url is known
(|#fork-me|
:top 3em
:right -6em
:color "#fff"
:display block
:position fixed
:text-align center
:text-decoration none
:letter-spacing .06em
:background-color "#A00"
:padding 0.5em 5em 0.4em 5em
:text-shadow 0 0 0.75em "#444"
:box-shadow "0 0 0.5em rgba(0,0,0,0.5)"
:transform "rotate(45deg) scale(0.75,1)"
:font bold "16px/1.2em" "Arial, Sans-Serif"
:z-index 10)
((:and |#fork-me| :before)
:content ""
:top 0
:left 0
:right 0
:bottom 0
:position absolute
:margin -0.3em -5em
:transform "scale(0.7)"
:border "2px rgba(255,255,255,0.7) dashed")
((:and |#fork-me| :hover)
:opacity 0.9)
(.demo :border 0.1em solid "#CCCCCC"
:background-color "#F5F3ED"
:margin-top 1em
:padding 3px
:padding-right 5px
(iframe :background-color white
:border 1px solid "#CCC"))
;; Autogenerated docs representation
(.object-name
(a :color "#c7254e"))))
(lass:compile-and-write
'(:media "(max-width: 800px)"
(body
(.search
(input
:font-size 3ex))
((.page > .content) :margin 0 2ex 0 2ex
:padding 1ex)
((.page > .footer) :margin 0 2ex 0 2ex
:padding 1ex
(.fineprint
:text-align center))
;; TODO: Make bar visible and readable on phones
(.navbar :display none)
;; This sidebar trigger was inspired by these articles
;; https://www.cssscript.com/hamburger-sidebar-navigation/
;; https://gscode.in/css-hamburger-menu/
(|#sidebar-trigger|
:display inline-block
:position relative
:top 2ex
:left 3ex
:z-index 1000
:width 50px
:height 44px
:cursor pointer
:box-sizing border-box
(span
:display inline-block
:transition all .4s
:box-sizing border-box
:position absolute
:left 0
:width 100%
:height 4px
:background-color orange
:border-radius 4px)
((:and span (:nth-of-type 1))
:top 0)
((:and span (:nth-of-type 2))
:top 20px)
((:and span (:nth-of-type 3))
:bottom 0))
(((:and |#sidebar-check| :checked)
~
.sidebar)
:display block
:width 100%
:max-width 100%
:position relative)
(((:and |#sidebar-check| :checked)
~
(:or .content
.footer))
:display none)
(((:and |#sidebar-check| :checked)
~
(label (:and span (:nth-of-type 1))))
:top 20px
:transform rotate -45deg)
(((:and |#sidebar-check| :checked)
~
(label (:and span (:nth-of-type 2))))
:opacity 0)
(((:and |#sidebar-check| :checked)
~
(label (:and span (:nth-of-type 3))))
:top 20px
:transform rotate 45deg)
(.sidebar
:display none
:box-shadow none
;; To remove scroll in the sidebar itself,
;; when we show it full screen on small devices
:height inherit
(.page-toc
(p :font-size 3ex)))))))))
(defmethod 40ants-doc-full/themes/api:highlight-theme ((theme 40ants-theme))
"a11y-dark")
(defparameter *menu-items*
'(("/posts/" "Blog")
("/ru/posts/" "Blog (RU)")
("/tips/" "Lisp Tips")
("/projects/" "Our Projects")
("/about/" "About")))
(defmethod 40ants-doc-full/themes/api:render-page-header ((theme 40ants-theme) uri title)
(with-html
;; Code of the GitHub stripe was taken from:
;; https://codepen.io/beben-koben/pen/BoLyf
(when-let* ((asdf-system (40ants-doc-full/builder:get-current-asdf-system))
(github-uri (40ants-doc-full/github::asdf-system-github-uri asdf-system)))
(:a :id "fork-me"
:href github-uri
"Fork me on GitHub"))
(:div :class "navbar"
(:div :class "navbar-inner"
(:a :class "brand"
:href "/"
(:img :class "logo"
:src "https://40ants.com/img/logo.svg"))
(:ul :class "nav"
(loop for (url item) in *menu-items*
do (:li (:a :href url
item))))))
(:input :type "checkbox"
:id "sidebar-check")
(:label :for "sidebar-check"
(:div :id "sidebar-trigger"
(:span)
(:span)
(:span)))))
(defmethod 40ants-doc-full/themes/api:render-page-footer ((theme 40ants-theme) uri)
(with-html
(:div :class "footer"
(:hr :class "separator")
(:p :class "fineprint"
"Created with passion by " (:em "40Ants")
(:a :class "lisp-logo"
:href "http://lisp-lang.org/"
(:img :src "https://40ants.com/img/made-with-lisp.svg"))))))