JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
center when big, code cleanup
[wfpl-cms.git] / style.styl
1 @require 'inc/wfpl/stylus_helpers.styl'
2 @require '.sha1sums.styl'
3
4 // constants
5 golden_ratio_small = 0.38196601125010515180 // ratio of whole to smaller part
6
7 ////////////////
8 // SETTINGS { //
9 ////////////////
10
11 ////// Dimensions
12 image_float_size = golden_ratio_small
13 narrow_column_ifs = image_float_size * 1.5
14 image_float_min_size = 0.5
15 image_float_margin = 2%
16 mobile_menu_width = 600px // switch to mobile menu when screen gets this narrow
17 single_column_max = 600px // switch to single column when screen gets this narrow
18 runaround_max = 370px // center left/right images when _column_ gets this narrow
19 //// Column Dimensions
20 centerer_width = 950px // inside. outside is columns.width
21 sidebar_width = 250px
22 sidebar_gap = 30px
23 columns = wfpl_columns({
24         type: 'node'
25         name: 'centerer'
26         margin: 15px
27         width: centerer_width
28         position: relative
29         child: {
30                 type: 'alternatives'
31                 full: {
32                         type: 'node'
33                         name: 'main'
34                 },
35                 with_sidebar: {
36                         type: 'series'
37                         main: {
38                                 type: 'node'
39                                 float: left
40                                 width: centerer_width - sidebar_width - sidebar_gap
41                         },
42                         sidebar: {
43                                 type: 'alternatives'
44                                 plain: {
45                                         type: 'node'
46                                         margin-left: sidebar_gap
47                                         width: sidebar_width
48                                         float: left
49                                 },
50                                 bordered: {
51                                         type: 'node'
52                                         margin-left: sidebar_gap
53                                         border-width: 1px
54                                         border-style: solid
55                                         border-color: red
56                                         padding: 15px
57                                         width: sidebar_width - 2px - 30px
58                                         float: left
59                                 }
60                         }
61                 }
62         }
63 })
64
65 biggest_content_width = columns['widths']['.centerer.full > .main']
66
67 hide_in_one_column_mode = {
68         ".centerer.with_sidebar > .sidebar.plain": 1
69         ".centerer.with_sidebar > .sidebar.bordered": 1
70 }
71
72 // fonts
73 font_size_large = 18px
74 font_size_normal = 15px
75 font_size_small = 13px
76 font_size_tiny = 11px
77
78 // colors
79 content_bg = #fff
80 content_fg = #000
81 window_bg = #fff
82
83 ////////////////////
84 // } END SETTINGS //
85 ////////////////////
86
87
88
89 // always show vertical scrollbar, so content doesn't shift around when
90 // switching from tall to short pages
91 html
92         overflow-y: scroll
93
94 header, hgroup, section, footer, aside, nav, article, figure, img
95         display: block
96
97 code.html
98         display: block
99         font: 12px monospace
100         border: 1px solid black
101         background: #ccc
102
103 .caption
104         font-weight: bold
105         * + &
106                 margin-top: 15px
107
108 .field
109         padding-top: 3px;
110
111 div.field_notes
112         font-size: 12px
113         line-height: 16px
114
115 fieldset
116         border: 1px dotted black
117         padding: 0 15px 15px 15px
118         margin: 15px 0
119         position: relative
120
121 legend
122         padding: 0 6px
123         font-weight: bold
124
125 div.error
126         border: 2px solid red
127         padding: 13px
128         margin: 20px
129         background: #fdd
130
131 h1
132         font-size: 26px
133         margin: 20px 0 10px
134
135 h1 + h4.tagline
136         margin: -10px 0 10px
137
138 h1 + h2
139         margin-top: -6px
140
141 h2
142         font-size: 20px
143         margin: 16px 0px 8px
144
145 h2 + h4.tagline
146         margin: -8px 0 8px
147
148 h3
149         font-size: 18px
150         margin: 12px 0 5px
151
152 h3 + h4.tagline
153         margin: -5px 0 5px
154
155 h4
156         font-size: 14px
157         margin: 10px 0 3px
158
159 h4 + h4.tagline
160         margin: -3px 0 3px
161
162
163 h1, h2, h3, h4
164         font-weight: bold
165
166 h4.tagline
167         font-weight: normal
168
169
170 p.quote
171         font-size: 14px
172         font-weight: bold
173         padding-bottom: 1px
174         margin: 15px 15px 0 15px
175
176 p.quote:before, p.quote:after
177         font-size: 40px
178         line-height: 0
179         color: #777
180         font-weight: bold
181         display: inline-block
182         height: 10px
183         position: relative
184
185 p.quote:before
186         content: '“'
187         top: 10px
188
189 p.quote:after
190         content: '”'
191         top: 20px
192         width: 0; // make sure it doesn't wrap
193
194 p.attrib, p.attribution
195         margin: 0 0 15px 20px
196         margin-top: 1px
197         padding-left: 30px
198         font-size: 12px
199         font-weight: normal
200         &:before
201                 content: "— "
202
203 body
204         margin: 0
205         padding: 0
206         background: window_bg
207         color: content_fg
208         font: font_size_normal Arimo, Arial, sans-serif
209
210 // call this for each ckeditor on each page
211 ckeditor_elements_already = {}
212 ckeditor(basename, element_name, body_id, width)
213         // ckeditor ui, including border around wysiwyg area
214         unless element_name in ckeditor_elements_already
215                 ckeditor_elements_already[element_name] = 1
216                 #{basename}_body #cke_{element_name}
217                         width: biggest_content_width + 30px
218                         margin-right: -30px
219         // body tag of the wysiwyg area
220         #{basename}_wysiwyg_{body_id}
221                 background: content_bg
222                 width: width
223                 margin: 0 auto
224                 min-width: 0
225                 width: width
226                 margin: 0 auto
227                 border: 5px solid #eee
228                 min-height: 50px
229
230 ckeditor('admin_pages', 'content', 'content_full_main', columns['widths']['.centerer.full > .main'])
231 ckeditor('admin_pages', 'content', 'content_with_sidebar_main', columns['widths']['.centerer.with_sidebar > .main'])
232 ckeditor('admin_pages', 'sidebar_content', 'content_with_sidebar_sidebar_plain', columns['widths']['.centerer.with_sidebar > .sidebar.plain'])
233 ckeditor('admin_pages', 'sidebar_content', 'content_with_sidebar_sidebar_bordered', columns['widths']['.centerer.with_sidebar > .sidebar.bordered'])
234
235 body > .centerer > .nav
236         padding-bottom: 20px
237         ul
238                 li_reset()
239                 space_evenly()
240
241 footer
242         clear: both
243         padding-top: 40px
244         ul
245                 li_reset()
246                 li
247                         li_reset()
248                         display: inline-block
249                         margin-right: 10px
250
251 #wfpl_messages
252         background: #ffd
253         padding: 5px 12px
254         margin: 0 0 20px 0
255         box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.4)
256         border-radius: 4px
257         p
258                 font-size: 120%
259                 padding: 5px 0
260                 margin: 0px
261
262         hr
263                 display: block
264                 height: 1px
265                 border: 0
266                 border-top: 1px dotted #ddc;
267                 margin: 0
268                 padding: 0
269
270
271 #admin_links
272         background: #fdd
273         padding: 3px
274         margin-bottom: 15px
275
276
277
278
279
280 // obsolete floating images (from pastable example code on admin_images)
281 span.wfpl_ifl
282         display: block
283         float: left
284         clear: left
285         font-size: 10px
286         color: black
287         text-align: right
288         background-repeat: no-repeat
289         background-position: left top
290         margin: 0 10px 2px 0
291
292 span.wfpl_ifr
293         display: block
294         float: right
295         clear: right
296         font-size: 10px
297         color: black
298         font-weight: normal
299         text-align: right
300         background-repeat: no-repeat
301         background-position: left top
302         margin: 0 0 2px 10px
303
304 div.wfpl_ic
305         margin: 15px auto
306         font-size: 10px
307         font-weight: normal
308         text-align: right
309         background-repeat: no-repeat
310         background-position: center top
311
312
313 // hack so that vertical margins are only between siblings for the most part
314 td > :first-child,
315 th > :first-child,
316 legend + *,
317 article > :first-child,
318 aside > :first-child,
319 section > :first-child,
320 nav > :first-child,
321 div > :first-child,
322 .first
323         margin-top: 0px
324
325 td > :last-child,
326 th > :last-child,
327 fieldset > :last-child,
328 article > :last-child,
329 aside > :last-child,
330 section > :last-child,
331 nav > :last-child,
332 div > :last-child,
333 .last
334         margin-bottom: 0px
335
336 table.evenodd
337         td, th
338                 padding: 6px 12px
339                 text-align: left
340         > thead, > tbody, &
341                 > tr:nth-child(2n+1)
342                         > td, > th
343                                 background: rgba(0,0,0,0.04)
344                         &:hover
345                                 > td, > th
346                                         background: rgba(0,0,0,0.07)
347                 > tr:nth-child(2n+0)
348                         > td, > th
349                                 background: rgba(0,0,0,0.02)
350                         &:hover
351                                 > td, > th
352                                         background: rgba(0,0,0,0.09)
353
354 .field_error
355         input
356                 border: 1px solid red
357
358 .password_suggestion
359         & + &
360                 margin-left: 10px
361
362 .wfpl_li, .wfpl_ci, .wfpl_ri, .wfpl_fi
363         display: block
364         margin-bottom: 1%
365         clear: both
366         font-size: 80%
367         text-align: right
368         .wfpl_i
369                 display: block
370                 width: 100%
371                 background-size: 100% auto
372                 background-repeat: no-repeat
373                 background-position: 50% top
374                 margin-bottom: 3px // padding above caption
375                 // clip line with   (which is there so ckeditor doesn't delete this)
376                 height: 0
377                 overflow: hidden
378 .wfpl_li, .wfpl_ci, .wfpl_ri
379         width: unit(image_float_size * 100, '%') // when window is large
380 .wfpl_li
381         float: left
382         margin-right: image_float_margin // this can be a percent right?
383 .wfpl_ci, .wfpl_fi
384         margin-left: auto
385         margin-right: auto
386 .wfpl_ri
387         float: right
388         margin-left: image_float_margin // this can be a percent right?
389 .wfpl_thumb // note: does not contain a .wfpl_i
390         display: inline-block
391         width: 70px
392         height: 70px
393         background-size: contain
394         background-position: 50% 50%
395         background-repeat: no-repeat
396 .wfpl_li, .wfpl_ci, .wfpl_ri, .wfpl_fi, .wfpl_thumb
397         max-width: 100%
398
399
400 // output css from column calculations
401 for selector, css in columns.css
402         body > {selector}
403                 {css}
404
405 // center when big
406 body > .centerer
407         margin: 0 auto
408
409 @media screen and (max-width: (columns.width))
410         // output responsive css from column calculations
411         for selector, css in columns.responsive_css
412                 body > {selector}
413                         {css}
414
415         // as big as it can be
416         body > .centerer
417                 width: auto
418
419         // make sure that borders (which won't scale) and rounding errors don't
420         // break the layout
421         body > .centerer.full > .main,
422         body > .centerer.with_sidebar > .sidebar.plain,
423         body > .centerer.with_sidebar > .sidebar.bordered
424                 margin-right: -10px
425
426 // big left/right images
427 for selector, css in columns.css
428         if columns['widths'][selector] > runaround_max
429                 body > {selector}
430                         col_max_width = columns['widths'][selector]
431                         col_min_width = col_max_width / columns.width * single_column_max
432                         .wfpl_li, .wfpl_ri
433                                 width: linear_scale_calc(col_max_width, col_min_width, col_max_width * image_float_size, col_min_width * image_float_min_size)
434                         .wfpl_ci
435                                 width: col_max_width * image_float_size
436
437 // mixin for making left/right images behave as centered
438 wfpl_li_ri_to_ci(selector, width)
439         {selector}
440                 .wfpl_li, .wfpl_ci, .wfpl_ri
441                         float: none
442                         width: width
443                         margin-right: auto
444                         margin-left: auto
445
446 // convert left/right to centered when columns width <= runaround_max
447 for selector, css in columns.css
448         if columns['widths'][selector] > runaround_max
449                 // calculate screen width when column width is runaround_max
450                 screen_rmax = columns['widths'][selector] / columns.width * runaround_max
451                 @media screen and (max-width: (screen_rmax))
452                         wfpl_li_ri_to_ci(selector, columns['widths'][selector] * image_float_size)
453         else
454                 // no @media, because these colums are always narrower than runaround_max
455                 wfpl_li_ri_to_ci(selector, columns['widths'][selector] * narrow_column_ifs)
456
457 // switch to 1-column layout
458 @media screen and (max-width: (single_column_max))
459         for selector, css in columns.css
460                 body > {selector}
461                         if selector == '.centerer'
462                                 margin-top: 0
463                         else if selector in hide_in_one_column_mode
464                                 display: none
465                         else
466                                 border: none
467                                 float: none
468                                 width: auto
469                                 margin: 0
470                                 padding: 0
471                                 margin-top: columns['responsive_css']['.centerer']['margin']
472
473 #mobile_menu_button
474         display: none;
475 #mobile_menu_check
476         display: none;
477 @media screen and (max-width: (mobile_menu_width))
478         #mobile_menu_check:not(:checked) + div
479                 display: none
480         #mobile_menu_check:checked + div
481                 display: block
482                 position: relative
483                 > ul
484                         z-index: 1000
485                         background: white
486                         background: rgba(255, 255, 255, 0.95)
487                         display: block
488                         position: absolute
489                         top: 100%
490                         width: 96%
491                         left: 2%
492                         margin: 0
493                         padding: 0
494                         border-bottom-left-radius: 4px
495                         border-bottom-right-radius: 4px
496                         box-shadow: 0px 3px 3px rgba(0,0,0,0.1)
497                         li
498                                 padding: 15px
499                                 & + li
500                                         padding-top: 0
501                                 a
502                                         font-size: 18px
503                                 white-space: nowrap
504
505                         // undo space_evenly stuff:
506                         &:before, &:after
507                                 display: none
508                                 content: none
509                                 margin: 0
510                                 padding: 0
511                         > *
512                                 position: static
513                                 top: 0
514
515         body > .centerer > .nav ul > li, #mobile_menu_button
516                 display: block
517                 padding: 3px 10px 4px 17px
518                 font-size: font_size_large
519 #admin_images_body .th_toggle_buttons
520         font-weight: normal
521         color: #777
522         space_evenly()