JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
fix ckeditor outer width dedup accross pages
[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         outer_selector = '#' + basename + '_body #cke_' + element_name
215         unless outer_selector in ckeditor_elements_already
216                 ckeditor_elements_already[outer_selector] = 1
217                 {outer_selector}
218                         width: biggest_content_width + 30px
219                         margin-right: -30px
220         // body tag of the wysiwyg area
221         #{basename}_wysiwyg_{body_id}
222                 background: content_bg
223                 width: width
224                 margin: 0 auto
225                 min-width: 0
226                 width: width
227                 margin: 0 auto
228                 border: 5px solid #eee
229                 min-height: 50px
230
231 ckeditor('admin_pages', 'content', 'content_full_main', columns['widths']['.centerer.full > .main'])
232 ckeditor('admin_pages', 'content', 'content_with_sidebar_main', columns['widths']['.centerer.with_sidebar > .main'])
233 ckeditor('admin_pages', 'sidebar_content', 'content_with_sidebar_sidebar_plain', columns['widths']['.centerer.with_sidebar > .sidebar.plain'])
234 ckeditor('admin_pages', 'sidebar_content', 'content_with_sidebar_sidebar_bordered', columns['widths']['.centerer.with_sidebar > .sidebar.bordered'])
235
236 body > .centerer > .nav
237         padding-bottom: 20px
238         ul
239                 li_reset()
240                 space_evenly()
241
242 footer
243         clear: both
244         padding-top: 40px
245         ul
246                 li_reset()
247                 li
248                         li_reset()
249                         display: inline-block
250                         margin-right: 10px
251
252 #wfpl_messages
253         background: #ffd
254         padding: 5px 12px
255         margin: 0 0 20px 0
256         box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.4)
257         border-radius: 4px
258         p
259                 font-size: 120%
260                 padding: 5px 0
261                 margin: 0px
262
263         hr
264                 display: block
265                 height: 1px
266                 border: 0
267                 border-top: 1px dotted #ddc;
268                 margin: 0
269                 padding: 0
270
271
272 #admin_links
273         background: #fdd
274         padding: 3px
275         margin-bottom: 15px
276
277
278
279
280
281 // obsolete floating images (from pastable example code on admin_images)
282 span.wfpl_ifl
283         display: block
284         float: left
285         clear: left
286         font-size: 10px
287         color: black
288         text-align: right
289         background-repeat: no-repeat
290         background-position: left top
291         margin: 0 10px 2px 0
292
293 span.wfpl_ifr
294         display: block
295         float: right
296         clear: right
297         font-size: 10px
298         color: black
299         font-weight: normal
300         text-align: right
301         background-repeat: no-repeat
302         background-position: left top
303         margin: 0 0 2px 10px
304
305 div.wfpl_ic
306         margin: 15px auto
307         font-size: 10px
308         font-weight: normal
309         text-align: right
310         background-repeat: no-repeat
311         background-position: center top
312
313
314 // hack so that vertical margins are only between siblings for the most part
315 td > :first-child,
316 th > :first-child,
317 legend + *,
318 article > :first-child,
319 aside > :first-child,
320 section > :first-child,
321 nav > :first-child,
322 div > :first-child,
323 .first
324         margin-top: 0px
325
326 td > :last-child,
327 th > :last-child,
328 fieldset > :last-child,
329 article > :last-child,
330 aside > :last-child,
331 section > :last-child,
332 nav > :last-child,
333 div > :last-child,
334 .last
335         margin-bottom: 0px
336
337 table.evenodd
338         td, th
339                 padding: 6px 12px
340                 text-align: left
341         > thead, > tbody, &
342                 > tr:nth-child(2n+1)
343                         > td, > th
344                                 background: rgba(0,0,0,0.04)
345                         &:hover
346                                 > td, > th
347                                         background: rgba(0,0,0,0.07)
348                 > tr:nth-child(2n+0)
349                         > td, > th
350                                 background: rgba(0,0,0,0.02)
351                         &:hover
352                                 > td, > th
353                                         background: rgba(0,0,0,0.09)
354
355 .field_error
356         input
357                 border: 1px solid red
358
359 .password_suggestion
360         & + &
361                 margin-left: 10px
362
363 .wfpl_li, .wfpl_ci, .wfpl_ri, .wfpl_fi
364         display: block
365         margin-bottom: 1%
366         clear: both
367         font-size: 80%
368         text-align: right
369         .wfpl_i
370                 display: block
371                 width: 100%
372                 background-size: 100% auto
373                 background-repeat: no-repeat
374                 background-position: 50% top
375                 margin-bottom: 3px // padding above caption
376                 // clip line with   (which is there so ckeditor doesn't delete this)
377                 height: 0
378                 overflow: hidden
379 .wfpl_li, .wfpl_ci, .wfpl_ri
380         width: unit(image_float_size * 100, '%') // when window is large
381 .wfpl_li
382         float: left
383         margin-right: image_float_margin // this can be a percent right?
384 .wfpl_ci, .wfpl_fi
385         margin-left: auto
386         margin-right: auto
387 .wfpl_ri
388         float: right
389         margin-left: image_float_margin // this can be a percent right?
390 .wfpl_thumb // note: does not contain a .wfpl_i
391         display: inline-block
392         width: 70px
393         height: 70px
394         background-size: contain
395         background-position: 50% 50%
396         background-repeat: no-repeat
397 .wfpl_li, .wfpl_ci, .wfpl_ri, .wfpl_fi, .wfpl_thumb
398         max-width: 100%
399
400
401 // output css from column calculations
402 for selector, css in columns.css
403         body > {selector}
404                 {css}
405
406 // center when big
407 body > .centerer
408         margin: 0 auto
409
410 @media screen and (max-width: (columns.width))
411         // output responsive css from column calculations
412         for selector, css in columns.responsive_css
413                 body > {selector}
414                         {css}
415
416         // as big as it can be
417         body > .centerer
418                 width: auto
419
420         // make sure that borders (which won't scale) and rounding errors don't
421         // break the layout
422         body > .centerer.full > .main,
423         body > .centerer.with_sidebar > .sidebar.plain,
424         body > .centerer.with_sidebar > .sidebar.bordered
425                 margin-right: -10px
426
427 // big left/right images
428 for selector, css in columns.css
429         if columns['widths'][selector] > runaround_max
430                 body > {selector}
431                         col_max_width = columns['widths'][selector]
432                         col_min_width = col_max_width / columns.width * single_column_max
433                         .wfpl_li, .wfpl_ri
434                                 width: linear_scale_calc(col_max_width, col_min_width, col_max_width * image_float_size, col_min_width * image_float_min_size)
435                         .wfpl_ci
436                                 width: col_max_width * image_float_size
437
438 // mixin for making left/right images behave as centered
439 wfpl_li_ri_to_ci(selector, width)
440         {selector}
441                 .wfpl_li, .wfpl_ci, .wfpl_ri
442                         float: none
443                         width: width
444                         margin-right: auto
445                         margin-left: auto
446
447 // convert left/right to centered when columns width <= runaround_max
448 for selector, css in columns.css
449         if columns['widths'][selector] > runaround_max
450                 // calculate screen width when column width is runaround_max
451                 screen_rmax = columns['widths'][selector] / columns.width * runaround_max
452                 @media screen and (max-width: (screen_rmax))
453                         wfpl_li_ri_to_ci(selector, columns['widths'][selector] * image_float_size)
454         else
455                 // no @media, because these colums are always narrower than runaround_max
456                 wfpl_li_ri_to_ci(selector, columns['widths'][selector] * narrow_column_ifs)
457
458 // switch to 1-column layout
459 @media screen and (max-width: (single_column_max))
460         for selector, css in columns.css
461                 body > {selector}
462                         if selector == '.centerer'
463                                 margin-top: 0
464                         else if selector in hide_in_one_column_mode
465                                 display: none
466                         else
467                                 border: none
468                                 float: none
469                                 width: auto
470                                 margin: 0
471                                 padding: 0
472                                 margin-top: columns['responsive_css']['.centerer']['margin']
473
474 #mobile_menu_button
475         display: none;
476 #mobile_menu_check
477         display: none;
478 @media screen and (max-width: (mobile_menu_width))
479         #mobile_menu_check:not(:checked) + div
480                 display: none
481         #mobile_menu_check:checked + div
482                 display: block
483                 position: relative
484                 > ul
485                         z-index: 1000
486                         background: white
487                         background: rgba(255, 255, 255, 0.95)
488                         display: block
489                         position: absolute
490                         top: 100%
491                         width: 96%
492                         left: 2%
493                         margin: 0
494                         padding: 0
495                         border-bottom-left-radius: 4px
496                         border-bottom-right-radius: 4px
497                         box-shadow: 0px 3px 3px rgba(0,0,0,0.1)
498                         li
499                                 padding: 15px
500                                 & + li
501                                         padding-top: 0
502                                 a
503                                         font-size: 18px
504                                 white-space: nowrap
505
506                         // undo space_evenly stuff:
507                         &:before, &:after
508                                 display: none
509                                 content: none
510                                 margin: 0
511                                 padding: 0
512                         > *
513                                 position: static
514                                 top: 0
515
516         body > .centerer > .nav ul > li, #mobile_menu_button
517                 display: block
518                 padding: 3px 10px 4px 17px
519                 font-size: font_size_large
520 #admin_images_body .th_toggle_buttons
521         font-weight: normal
522         color: #777
523         space_evenly()