Skip to content

Commit 79c3225

Browse files
committed
autofocus: wip
1 parent 8470a90 commit 79c3225

File tree

1 file changed

+171
-18
lines changed

1 file changed

+171
-18
lines changed

src/remplater/templates/autofocus.clj

+171-18
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
[org.apache.pdfbox.pdmodel.common PDRectangle]))
1212

1313
(def paddings
14-
{:layout-left 200
14+
{:layout-left 220
1515
:layout-top 105})
1616

1717
(def colors
18-
{:gray (pdf/make-color 50 50 50)
18+
{:black (pdf/make-color 0 0 0)
19+
:gray (pdf/make-color 50 50 50)
1920
:light-gray (pdf/make-color 100 100 100)})
2021

2122
(def styles
@@ -25,10 +26,14 @@
2526

2627
(def page-names
2728
{:day #(str "day-" %)
28-
:weeks #(str "weeks-" %)})
29+
:weeks #(str "weeks-" %)
30+
:weeks-inbox #(str "weeks-inbox-" %)
31+
:project #(str "project-" %1 "-" %2)})
2932

33+
(def line-height 52)
3034
(def days-per-weeks-page 28)
3135
(def week-days-completion-mark-size 60)
36+
(def week-projects-completion-mark-size 40)
3237
(def day-completion-mark-size 60)
3338

3439
(defn get-page-name [page-name & params]
@@ -44,11 +49,26 @@
4449

4550
(def lines-layout-pattern
4651
{:width "100%"
47-
:height 52
52+
:height line-height
4853
:outline (fn [{:as attrs :keys [side]} & children]
4954
(when (#{:bottom :top} side)
5055
light-gray-line))
51-
:line light-gray-line})
56+
:line light-gray-line
57+
:row (fn [{:as attrs :keys [row-content row-index]}]
58+
(when (and row-content row-index)
59+
(when-let [content (get row-content row-index)]
60+
content)))})
61+
62+
(defn leftline [{:keys [text target-page]}]
63+
[:padding {:padding-right 10}
64+
[:text {:text text
65+
:font-size 20
66+
:color (:black colors)
67+
:halign :right
68+
:valign :center}
69+
(when target-page
70+
[:padding {:padding -10}
71+
[:page-link {:target-page target-page}]])]])
5272

5373
(defn completion-mark [{:as attrs :keys [x1 y1 x2 y2]}]
5474
(let [attrs (merge attrs light-gray-line)
@@ -59,6 +79,13 @@
5979
[:line (assoc attrs :x1 x2 :y1 y :x2 x :y2 y1)]
6080
[:line (assoc attrs :x1 x :y1 y1 :x2 x1 :y2 y)]]))
6181

82+
(def page-completion-mark
83+
[:padding {:padding-top "25%"
84+
:padding-left 150}
85+
[:split {:direction :x :splits [day-completion-mark-size]}
86+
[:split {:direction :y :splits [day-completion-mark-size]}
87+
[completion-mark]]]])
88+
6289
(defn page-layout [{:keys [top-left top-right bottom-left bottom-right]}]
6390
[:split {:direction :y :splits [(:layout-top paddings)]}
6491
[:div
@@ -75,11 +102,47 @@
75102
bottom-left]
76103
bottom-right]])
77104

78-
(defn weeks-page [{:keys [from-date]}]
105+
(defn weeks-page [{:keys [from-date to-date]}]
79106
[:page {:name (get-page-name :weeks from-date)}
80107
[page-layout
81-
{:bottom-right
82-
[:split {:direction :y :splits [700]}
108+
{:top-left
109+
page-completion-mark
110+
111+
:top-right
112+
[:padding {:padding-left 20}
113+
[:text {:text (str
114+
(t/format (t/formatter "dd MMM") from-date)
115+
" - "
116+
(t/format (t/formatter "dd MMM") to-date))
117+
:font-size 40
118+
:valign :center
119+
:halign :left}]]
120+
121+
:bottom-right
122+
[:split {:direction :y :splits [(* 1 line-height)
123+
(* 12 line-height)
124+
(* 6 line-height)
125+
(* 4 line-height)
126+
(* 1 line-height)
127+
(* 10 line-height)]}
128+
[:grid {:cols 7 :rows 1
129+
:line light-gray-line
130+
:outline (fn [attrs & _]
131+
[bottom-outline attrs light-gray-line])}
132+
(fn [{:keys [index]}]
133+
(let [columns {0 "MON"
134+
1 "TUE"
135+
2 "WED"
136+
3 "THU"
137+
4 "FRI"
138+
5 "SAT"
139+
6 "SUN"}]
140+
[:text {:text (get columns index)
141+
:color (:gray colors)
142+
:font-size 20
143+
:valign :center
144+
:halign :center}]))]
145+
83146
[:grid {:cols 7 :rows 4
84147
:line light-gray-line
85148
:outline (fn [attrs & _]
@@ -90,41 +153,119 @@
90153
[:padding {:padding 10}
91154
[:split {:direction :y :splits [30]}
92155
[:text {:text (t/format (t/formatter "dd") date)
93-
:color (:gray colors)
156+
:color (:black colors)
94157
:font-size 30
95158
:valign :top
96159
:halign :right}]
97160
[:text {:text (-> (t/format (t/formatter "MMM") date)
98161
(str/upper-case))
99-
:color (:light-gray colors)
162+
:color (:gray colors)
100163
:font-size 20
101164
:valign :top
102165
:halign :right}]]]
103166

104167
[:split {:direction :x :splits [week-days-completion-mark-size]}
105168
[:split {:direction :y :splits [week-days-completion-mark-size]}
106169
[:padding (:week-days-completion-mark styles)
107-
[completion-mark]]]]]))]]}]])
170+
[completion-mark]]]]]))]
171+
172+
[:pattern-grid {:pattern lines-layout-pattern}]
173+
174+
[:grid {:cols 4 :rows 2
175+
:line light-gray-line
176+
:outline (fn [attrs & _]
177+
[bottom-outline attrs light-gray-line])}
178+
(fn [{:keys [index]}]
179+
[:page-link {:target-page (get-page-name :project from-date index)}
180+
[:split {:direction :x :splits [60]}
181+
[:padding {:padding-top (/ line-height 2)
182+
:padding-bottom (/ line-height 2)
183+
:padding-left 10}
184+
[completion-mark]]]])]
185+
186+
[:grid {:cols 28 :rows 1
187+
:line light-gray-line
188+
:outline (fn [attrs & _]
189+
[bottom-outline attrs light-gray-line])}
190+
(fn [{:keys [index]}]
191+
(let [date (t/>> from-date (t/of-days index))]
192+
[:padding {:padding 0}
193+
[:text {:text (t/format (t/formatter "dd") date)
194+
:font-size 20
195+
:color (:black colors)
196+
:halign :center
197+
:valign :center}]]))]
198+
199+
[:grid {:cols 28 :rows 10
200+
:line light-gray-line}]]
201+
202+
:bottom-left
203+
[:pattern-grid {:pattern lines-layout-pattern
204+
:row-content {1 [leftline {:text "DAYS>"}]
205+
13 [leftline {:text "NOTES>"}]
206+
18 [leftline {:text "INBOX>"
207+
:target-page (get-page-name :weeks-inbox from-date)}]
208+
19 [leftline {:text "PROJECTS>"}]
209+
23 [leftline {:text "HABITS>"}]}}]}]])
108210

109211
(defn day-page [{:keys [date weeks-date]}]
110212
[:page {:name (get-page-name :day date)
111213
:size (PDRectangle. 1404 6000)}
112214
[page-layout
113215
{:top-left
114-
[:padding {:padding-top "25%"
115-
:padding-left 120}
116-
[:split {:direction :x :splits [day-completion-mark-size]}
117-
[:split {:direction :y :splits [day-completion-mark-size]}
118-
[completion-mark]]]]
216+
page-completion-mark
119217

120218
:top-right
121219
[:page-link {:target-page (get-page-name :weeks weeks-date)}
122220
[:padding {:padding-left 20}
123221
[:text {:text (t/format (t/formatter "dd MMM") date)
222+
:color (:black colors)
124223
:font-size 40
125224
:valign :center
126225
:halign :left}]]]
127226

227+
:bottom-left
228+
[:pattern-grid {:pattern lines-layout-pattern
229+
:row-content {1 [leftline {:text "INBOX>"
230+
:target-page (get-page-name :weeks-inbox weeks-date)}]}}]
231+
232+
:bottom-right
233+
[:pattern-grid {:pattern lines-layout-pattern}]}]])
234+
235+
(defn project-page [{:keys [weeks-date index]}]
236+
[:page {:name (get-page-name :project weeks-date index)
237+
:size (PDRectangle. 1404 6000)}
238+
[page-layout
239+
{:top-left
240+
page-completion-mark
241+
242+
:top-right
243+
[:page-link {:target-page (get-page-name :weeks weeks-date)}]
244+
245+
:bottom-left
246+
[:pattern-grid {:pattern lines-layout-pattern}]
247+
248+
:bottom-right
249+
[:pattern-grid {:pattern lines-layout-pattern}]}]])
250+
251+
(defn inbox-page [{:keys [weeks-date]}]
252+
[:page {:name (get-page-name :weeks-inbox weeks-date)
253+
:size (PDRectangle. 1404 6000)}
254+
[page-layout
255+
{:top-left
256+
page-completion-mark
257+
258+
:top-right
259+
[:page-link {:target-page (get-page-name :weeks weeks-date)}
260+
[:padding {:padding-left 10}
261+
[:text {:text (str
262+
(str/upper-case (t/format (t/formatter "MMMM") weeks-date))
263+
" INBOX")
264+
:font-size 40
265+
:color (:black colors)
266+
:halign :left
267+
:valign :center}]]]
268+
128269
:bottom-left
129270
[:pattern-grid {:pattern lines-layout-pattern}]
130271

@@ -138,15 +279,27 @@
138279
(concat
139280
(->> (dt/range-dates from-date to-date (t/of-days days-per-weeks-page))
140281
(mapv (fn [from-date]
141-
[weeks-page {:from-date from-date}])))
282+
[weeks-page {:from-date from-date
283+
:to-date (t/>> from-date (t/of-days (dec days-per-weeks-page)))}])))
142284

143285
(->> (dt/range-dates from-date to-date (t/of-days days-per-weeks-page))
144286
(mapcat (fn [from-date]
145287
(let [weeks-to-date (t/>> from-date (t/of-days days-per-weeks-page))]
146288
(->> (dt/range-dates from-date weeks-to-date)
147289
(mapv (fn [date]
148290
[day-page {:date date
149-
:weeks-date from-date}]))))))))))
291+
:weeks-date from-date}])))))))
292+
293+
(->> (dt/range-dates from-date to-date (t/of-days days-per-weeks-page))
294+
(mapv (fn [from-date]
295+
[inbox-page {:weeks-date from-date}])))
296+
297+
(->> (dt/range-dates from-date to-date (t/of-days days-per-weeks-page))
298+
(mapcat (fn [from-date]
299+
(->> (range 8)
300+
(mapv (fn [index]
301+
[project-page {:weeks-date from-date
302+
:index index}])))))))))
150303

151304
(comment
152305
(render/render-document

0 commit comments

Comments
 (0)