alongslide 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,444 @@
1
+ //
2
+ // alongslide.sass: Set up CSS Regions and basic scrolling mechanism.
3
+ //
4
+ // Copyright 2013 Canopy Canopy Canopy, Inc.
5
+ //
6
+
7
+ @import "compass"
8
+
9
+ //
10
+ // FIXED pixel-based values from comps.
11
+ //
12
+ $fixed-frame-width: 980px
13
+ $fixed-frame-height: 612.5px
14
+
15
+ // at all four edges
16
+ $fixed-column-outer-margin: 54px
17
+
18
+ // vertical
19
+ $fixed-vertical-grid-unit: 11.04px
20
+ // $num-vertical-units: 56
21
+
22
+ $fixed-wide-bar: 28px
23
+ $fixed-narrow-bar: 22px
24
+
25
+ @function fixed-width-in-bars($wide, $narrow)
26
+ @return $wide * $fixed-wide-bar + $narrow * $fixed-narrow-bar
27
+
28
+ // computed
29
+ $fixed-usable-width: fixed-width-in-bars($wide: 17, $narrow: 18)
30
+ $fixed-usable-height: 45 * $fixed-vertical-grid-unit
31
+ $fixed-two-column-width: fixed-width-in-bars($wide: 8, $narrow: 8)
32
+ $fixed-three-column-width: fixed-width-in-bars($wide: 5, $narrow: 6)
33
+ $fixed-2-column-inner-margin: fixed-width-in-bars($wide: 1, $narrow: 2)
34
+ $fixed-3-column-inner-margin: fixed-width-in-bars($wide: 1, $narrow: 0)
35
+
36
+ //
37
+ // PERCENTAGE-based values based on fixed values above
38
+ //
39
+ $full-bleed: 100%
40
+ $outer-margin-width: percentage($fixed-column-outer-margin / $fixed-frame-width)
41
+ $outer-margin-height: percentage($fixed-column-outer-margin / $fixed-frame-height)
42
+ $inner-margin-2-column: percentage($fixed-2-column-inner-margin / $fixed-frame-width)
43
+ $inner-margin-3-column: percentage($fixed-3-column-inner-margin / $fixed-frame-width)
44
+ $vertical-grid-unit: percentage($fixed-vertical-grid-unit / $fixed-frame-height)
45
+ $width-2-column: ($full-bleed - 2 * $outer-margin-width - $inner-margin-2-column) / 2
46
+ $width-3-column: ($full-bleed - 2 * $outer-margin-width - 2 * $inner-margin-3-column) / 3
47
+
48
+ $white-bg: #fbfbfb
49
+
50
+
51
+ // skrollr elements must all be fixed.
52
+ //
53
+ @mixin scrollable
54
+ position: fixed
55
+ &.unstaged
56
+ position: static
57
+
58
+ // Hide Alongslide directives.
59
+ //
60
+ .alongslide
61
+ display: none
62
+
63
+ // Horizontally-scrolling content viewer.
64
+ //
65
+ #frames
66
+ height: $full-bleed
67
+ background-color: $white-bg
68
+ position: absolute
69
+ text-rendering: optimizelegibility
70
+ text-transform: auto
71
+
72
+ // One frame is one screen's worth.
73
+ //
74
+ // Panels, flow, backgrounds (front-to-back order) all contain frames.
75
+ //
76
+ .frame
77
+ width: $full-bleed
78
+ height: $full-bleed
79
+ @include scrollable
80
+
81
+ // Columns
82
+ //
83
+ // Flowing text laid out by CSS Regions.
84
+ //
85
+ // Column dimensions are all defined in percentages. FixedAspect then overwites
86
+ // the dimensions of `#frames > .flow > .frame`, and the contained columns
87
+ // fit accordingly.
88
+ //
89
+ // Contrast with what FixedAspect does with panels below.
90
+ //
91
+ .flow
92
+ .frame
93
+
94
+ // One text column
95
+ //
96
+ .column
97
+ width: $width-2-column
98
+ height: 45 * $vertical-grid-unit
99
+ top: $outer-margin-height
100
+ position: absolute
101
+ // > div
102
+ // height: $full-bleed - $frame-height-padding
103
+
104
+ // Left/right columns
105
+ //
106
+ &:nth-child(1)
107
+ left: $outer-margin-width
108
+ &:nth-child(2)
109
+ right: $outer-margin-width
110
+
111
+ // With pinned panel: top/bottom
112
+ //
113
+ // All column values assume 'half' size by default and treat
114
+ // 'one-third' and 'two-thirds' as overwrites.
115
+ //
116
+ &.with-panel-pinned-bottom
117
+ .column
118
+ height: 19 * $vertical-grid-unit
119
+ &.with-panel-sized-one-third .column
120
+ height: 27 * $vertical-grid-unit
121
+ &.with-panel-sized-two-thirds .column
122
+ height: 11 * $vertical-grid-unit
123
+
124
+ &.with-panel-pinned-top
125
+ .column
126
+ top: $outer-margin-height + 26 * $vertical-grid-unit
127
+ height: 19 * $vertical-grid-unit
128
+ &.with-panel-sized-one-third .column
129
+ top: $outer-margin-height + 18 * $vertical-grid-unit
130
+ height: 27 * $vertical-grid-unit
131
+ &.with-panel-sized-two-thirds .column
132
+ top: $outer-margin-height + 34 * $vertical-grid-unit
133
+ height: 11 * $vertical-grid-unit
134
+
135
+ // With pinned panel: left/right
136
+ //
137
+ &.with-panel-pinned-left, &.with-panel-pinned-right
138
+ .column
139
+ width: $width-2-column
140
+ &.with-panel-sized-one-third .column
141
+ width: 2 * $width-3-column + $inner-margin-3-column
142
+ &.with-panel-sized-two-thirds .column
143
+ width: $width-3-column
144
+
145
+ &.with-panel-pinned-left
146
+ .column:nth-child(1)
147
+ left: $outer-margin-width + $width-2-column + $inner-margin-2-column
148
+ &.with-panel-sized-one-third .column:nth-child(1)
149
+ left: $outer-margin-width + $width-3-column + $inner-margin-3-column
150
+ &.with-panel-sized-two-thirds .column:nth-child(1)
151
+ left: $outer-margin-width + 2 * ($width-3-column + $inner-margin-3-column)
152
+
153
+ // Three column layout
154
+ //
155
+ &.three-columns
156
+ .column
157
+ width: $width-3-column
158
+ &:nth-child(1)
159
+ left: $outer-margin-width
160
+ &:nth-child(2)
161
+ left: $outer-margin-width + $width-3-column + $inner-margin-3-column
162
+ &:nth-child(3)
163
+ right: $outer-margin-width
164
+
165
+ // Three columns with pinned panel: maintain width
166
+ &.with-panel-pinned-left, &.with-panel-pinned-right
167
+ .column
168
+ width: $width-3-column
169
+
170
+ &.with-panel-pinned-left
171
+ &.with-panel-sized-one-third
172
+ .column:nth-child(1)
173
+ left: $outer-margin-width + $width-3-column + $inner-margin-3-column
174
+ .column:nth-child(2)
175
+ left: $outer-margin-width + 2 * ($width-3-column + $inner-margin-3-column)
176
+
177
+ // Panels
178
+ //
179
+ // Contrary to columns above, all values are defined in pixels, which
180
+ // FixedAspect uses to re-apply percentages in JS. It then overwrites
181
+ // the below pixel-based values with percentage values based on aspect.
182
+ //
183
+ // The reason is that JS can't access the CSS percentage values anyway,
184
+ // so, to maintain floating point precision, we may as well do the
185
+ // math in JS--rather than go from pixels to percentages in SASS, and then
186
+ // re-derive the percentages in JS, which will be rounded to integers
187
+ // (and therefore exhibit sampling inaccuracy).
188
+ //
189
+ // The rule is:
190
+ // - `.panel` is the content area, defined in fixed pixel widths
191
+ // - `.panel .contents` is relative to the content area
192
+ //
193
+ .panels
194
+ .panel
195
+ width: $fixed-frame-width
196
+ height: $fixed-frame-height
197
+ top: 0
198
+ overflow: hidden
199
+
200
+ .contents
201
+ position: absolute
202
+ top: $fixed-column-outer-margin
203
+ left: $fixed-column-outer-margin
204
+ width: $fixed-usable-width
205
+ height: $fixed-usable-height
206
+ z-index: 101
207
+ overflow: visible
208
+
209
+ // Class for inner padding. This one _is_ percentage-based.
210
+ //
211
+ .inner
212
+ width: 100%
213
+ height: 100%
214
+ position: absolute
215
+ z-index: 101
216
+
217
+ // Responsive images
218
+ img
219
+ max-width: 100%
220
+ height: auto
221
+
222
+ // Pinned
223
+ //
224
+ // As with columns, default size is 'half'.
225
+ // 'one-third' and 'two-thirds' overwrite.
226
+ //
227
+ &.pin
228
+ background-color: $white-bg
229
+ &.top
230
+ bottom: auto
231
+ .contents
232
+ height: 22.5 * $fixed-vertical-grid-unit
233
+ .inner
234
+ height: $full-bleed - percentage(1 / 22.5)
235
+ &.one-third .contents
236
+ height: 15 * $fixed-vertical-grid-unit
237
+ .inner
238
+ height: $full-bleed - percentage(1 / 14)
239
+ &.two-thirds .contents
240
+ height: 31 * $fixed-vertical-grid-unit
241
+ .inner
242
+ height: $full-bleed - percentage(1 / 30)
243
+
244
+
245
+ &.bottom
246
+ top: auto
247
+ .contents
248
+ top: $fixed-column-outer-margin + 22.5 * $fixed-vertical-grid-unit
249
+ height: 22.5 * $fixed-vertical-grid-unit
250
+ .inner
251
+ top: percentage(1 / 22.5)
252
+ height: $full-bleed - percentage(1 / 22.5)
253
+ &.one-third .contents
254
+ top: $fixed-column-outer-margin + 31 * $fixed-vertical-grid-unit
255
+ height: 14 * $fixed-vertical-grid-unit
256
+ .inner
257
+ top: percentage(1 / 14)
258
+ height: $full-bleed - percentage(1 / 14)
259
+ &.two-thirds .contents
260
+ top: $fixed-column-outer-margin + 15 * $fixed-vertical-grid-unit
261
+ height: 30 * $fixed-vertical-grid-unit
262
+ .inner
263
+ top: percentage(1 / 30)
264
+ height: $full-bleed - percentage(1 / 30)
265
+
266
+ $fixed-panel-margin-half: fixed-width-in-bars($wide: 1, $narrow: 2) / 2
267
+ $fixed-panel-width-half: fixed-width-in-bars($wide: 8, $narrow: 8) + $fixed-panel-margin-half
268
+ $fixed-panel-margin-one-third: fixed-width-in-bars($wide: 1, $narrow: 0) / 2
269
+ $fixed-panel-width-one-third: fixed-width-in-bars($wide: 5, $narrow: 6) + $fixed-panel-margin-one-third
270
+ $fixed-panel-margin-two-thirds: fixed-width-in-bars($wide: 1, $narrow: 0) / 2
271
+ $fixed-panel-width-two-thirds: fixed-width-in-bars($wide: 11, $narrow: 12) + $fixed-panel-margin-two-thirds
272
+
273
+ &.left, &.right
274
+ background-color: $white-bg
275
+ .contents
276
+ width: $fixed-panel-width-half
277
+ .inner
278
+ width: $full-bleed - percentage($fixed-panel-margin-half / $fixed-panel-width-half)
279
+ &.one-third .contents
280
+ width: $fixed-panel-width-one-third
281
+ .inner
282
+ width: $full-bleed - percentage($fixed-panel-margin-one-third / $fixed-panel-width-one-third)
283
+ &.two-thirds .contents
284
+ width: $fixed-panel-width-two-thirds
285
+ .inner
286
+ width: $full-bleed - percentage($fixed-panel-margin-two-thirds / $fixed-panel-width-two-thirds)
287
+
288
+ &.left
289
+
290
+ // JS will turn these left values into `margin-left`
291
+ &.right
292
+ .contents
293
+ left: $fixed-column-outer-margin + $fixed-panel-width-half
294
+ .inner
295
+ left: percentage($fixed-panel-margin-half / $fixed-panel-width-half)
296
+ &.one-third .contents
297
+ left: $fixed-column-outer-margin + $fixed-panel-width-two-thirds
298
+ .inner
299
+ left: percentage($fixed-panel-margin-one-third / $fixed-panel-width-one-third)
300
+ &.two-thirds .contents
301
+ left: $fixed-column-outer-margin + $fixed-panel-width-one-third
302
+ .inner
303
+ left: percentage($fixed-panel-margin-two-thirds / $fixed-panel-width-two-thirds)
304
+
305
+ // Section backgrounds
306
+ //
307
+ .backgrounds
308
+ .background
309
+ width: $full-bleed
310
+ height: $full-bleed
311
+ p
312
+ -webkit-hyphens: auto
313
+ -moz-hyphens: auto
314
+ -ms-hyphens: auto
315
+ hyphens: auto
316
+
317
+ // Footnotes
318
+ sup[id^="fnref"]
319
+ position: absolute
320
+ left: -25px
321
+ z-index: 214748364
322
+ > a
323
+ border: none
324
+ position: absolute
325
+ height: 25px
326
+ width: 25px
327
+ z-index: 1000001
328
+ > li
329
+ background-color: $white-bg
330
+ opacity: 0
331
+ float: left
332
+ list-style: none
333
+ p:first-child
334
+ text-indent: 5% !important
335
+ ul,
336
+ a[rev="footnote"]
337
+ display: none
338
+ > a:hover,
339
+ > a.active
340
+ ~ li
341
+ opacity: 1
342
+
343
+
344
+
345
+ // DEBUG GRID
346
+ //
347
+ #als-debug-grid
348
+ position: fixed
349
+ width: 100%
350
+ height: 100%
351
+ opacity: 0.8
352
+
353
+ &.hidden
354
+ display: none
355
+
356
+ .margins
357
+ position: absolute
358
+
359
+ &.horizontal
360
+ width: $full-bleed
361
+ height: 45 * $vertical-grid-unit
362
+ top: $vertical-grid-unit * 5
363
+ left: 0
364
+ border: 1px solid #00feff
365
+ border-left-width: 0
366
+ border-right-width: 0
367
+
368
+ &.vertical
369
+ width: $full-bleed - 2 * $outer-margin-width
370
+ height: $full-bleed
371
+ left: $outer-margin-width
372
+ top: 0
373
+ border: 1px solid #ff2598
374
+ border-top-width: 0
375
+ border-bottom-width: 0
376
+
377
+ &.inner
378
+ width: $inner-margin-2-column
379
+ left: $outer-margin-width + percentage(8 * ($fixed-wide-bar + $fixed-narrow-bar) / $fixed-frame-width)
380
+
381
+ .more
382
+ width: 100%
383
+ height: 100%
384
+
385
+ .units
386
+ position: absolute
387
+ top: 0
388
+ width: 100%
389
+ height: 100%
390
+
391
+ &.vertical
392
+ .unit
393
+ width: $full-bleed
394
+ border-top: 1px solid #def0f7
395
+ height: $vertical-grid-unit
396
+
397
+ &.horizontal
398
+ top: 5 * $vertical-grid-unit
399
+ height: 45 * $vertical-grid-unit
400
+ margin: 0 $outer-margin-width
401
+ width: percentage($fixed-usable-width / $fixed-frame-width)
402
+
403
+ .unit
404
+ height: 100%
405
+ width: percentage($fixed-narrow-bar / ($fixed-usable-width))
406
+ margin-right: percentage($fixed-wide-bar / ($fixed-usable-width))
407
+ float: left
408
+ background-color: #d8e7f6
409
+ opacity: 0.4
410
+ &:last-child
411
+ margin-right: 0
412
+
413
+ &.thirds .margins.vertical.inner
414
+ width: $inner-margin-3-column
415
+ &:nth-child(1)
416
+ left: $outer-margin-width + percentage($fixed-three-column-width / $fixed-frame-width)
417
+ &:nth-child(2)
418
+ left: $outer-margin-width + percentage(($fixed-three-column-width * 2 + $fixed-3-column-inner-margin) / $fixed-frame-width)
419
+
420
+ #source
421
+ display: none
422
+
423
+ #please-rotate
424
+ display: none
425
+
426
+ @media only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait)
427
+ #please-rotate
428
+ display: block
429
+ position: fixed
430
+ top: 0
431
+ width: 100%
432
+ height: 100%
433
+ background: white
434
+ h1
435
+ font-size: 100px
436
+ line-height: 1em
437
+ margin: auto
438
+ position: absolute
439
+ top: 0
440
+ left: 0
441
+ bottom: 0
442
+ right: 0
443
+ height: 150px
444
+ text-align: center
@@ -0,0 +1,8 @@
1
+ ---
2
+ greedy: true
3
+ ---
4
+ - classes ||= ""
5
+ .alongslide.show.panel{"data-alongslide-id" => identifier, :class => classes}
6
+ .contents
7
+ .inner
8
+ = raw content.join
@@ -0,0 +1,4 @@
1
+ ---
2
+ greedy: false
3
+ ---
4
+ .alongslide.unpin.panel{"data-alongslide-id" => identifier}
@@ -0,0 +1,4 @@
1
+ ---
2
+ greedy: false
3
+ ---
4
+ .alongslide.exit.section{"data-alongslide-id" => identifier}
@@ -0,0 +1,4 @@
1
+ ---
2
+ greedy: false
3
+ ---
4
+ .alongslide.enter.section{"data-alongslide-id" => identifier, :class => classes}
@@ -0,0 +1,162 @@
1
+ #
2
+ # Grammar for Alongslide directives embedded in Markdown.
3
+ #
4
+ # This grammar is used to parse large blocks of Markdown, which consists of
5
+ # typical text content as well as special directives, which are lines
6
+ # beginning with a plus sign.
7
+ #
8
+ # Copyright 2013 Canopy Canopy Canopy, Inc.
9
+ # Authors Adam Florin & Anthony Tran
10
+ #
11
+ module Alongslide
12
+ module Grammar
13
+
14
+ grammar Root
15
+ include Alongslide::Templates
16
+ include Panel
17
+
18
+ # Root context: Parse input as a sequence of "blocks".
19
+ #
20
+ rule root
21
+ blocks:(paragraph_break* content:(block:block/template:independent_template))*
22
+ paragraph_break*
23
+ <RootNode>
24
+ end
25
+
26
+ # A "block" is a top-level directive.
27
+ #
28
+ # For example, defining (or hiding) a panel, entering or exiting a section.
29
+ #
30
+ rule block
31
+ panel / section
32
+ end
33
+
34
+ # Panel declaration.
35
+ #
36
+ # Panels may contain templates, or text directly.
37
+ #
38
+ rule panel
39
+ directive_prefix
40
+ command:("panel"/"unpin") space
41
+ identifier
42
+ class_params:panel_params
43
+ contents:((paragraph_break 2..) content:(template:template_wrapper/text:text))*
44
+ <PanelNode>
45
+ end
46
+
47
+ # Flowing text section
48
+ #
49
+ rule section
50
+ directive_prefix
51
+ command:("section"/"exit")
52
+ space
53
+ identifier
54
+ class_params:section_params
55
+ <SectionNode>
56
+ end
57
+
58
+ # Commonalities between greedy and nongreedy templates.
59
+ #
60
+ rule template_wrapper
61
+ !block
62
+ directive_prefix
63
+ renderable:(template:greedy_template / template:nongreedy_template)
64
+ end
65
+
66
+ # Greedy templates may contain other templates.
67
+ #
68
+ # Consult Alongslide::Templates to get valid template names.
69
+ #
70
+ rule greedy_template
71
+ command:(identifier &{|seq|
72
+ @@template_names[:greedy].include? seq.first.text_value
73
+ })
74
+ template_params:template_params
75
+ contents:((paragraph_break 2..) content:(template:template_wrapper))*
76
+ <UserTemplateNode>
77
+ end
78
+
79
+ # Nongreedy templates may only contain text.
80
+ #
81
+ # Consult Alongslide::Templates to get valid template names.
82
+ #
83
+ rule nongreedy_template
84
+ command:(identifier &{|seq|
85
+ @@template_names[:nongreedy].include? seq.first.text_value
86
+ })
87
+ template_params:template_params
88
+ contents:((paragraph_break 2..) content:text)*
89
+ <UserTemplateNode>
90
+ end
91
+
92
+ # Independent templates stand alone, outside of the panel-nesting system.
93
+ # E.g. column breaks.
94
+ #
95
+ rule independent_template
96
+ directive_prefix
97
+ command:(identifier &{|seq|
98
+ @@template_names[:independent].include? seq.first.text_value
99
+ })
100
+ template_params:template_params
101
+ <UserTemplateNode>
102
+ end
103
+
104
+ #
105
+ #
106
+ rule template_params
107
+ (space param:key_value_pair)*
108
+ end
109
+
110
+ # Key/value pair. Value is optionally a quoted string.
111
+ #
112
+ rule key_value_pair
113
+ key:identifier space value:(quoted_string / (!"\s" .)+)
114
+ end
115
+
116
+ # Plain old Markdown text (one paragraph).
117
+ #
118
+ rule text
119
+ !directive_prefix
120
+ (!(paragraph_break 2..) .)+
121
+ end
122
+
123
+ # Signal that what follows is an Alongslide directive, not plain text.
124
+ #
125
+ rule directive_prefix
126
+ "+" extra_space
127
+ end
128
+
129
+ # Often required two-at-a-time to match familiar Markdown syntax.
130
+ #
131
+ rule paragraph_break
132
+ extra_space "\n"
133
+ end
134
+
135
+ # Panels and sections must be tracked by unique identifiers.
136
+ #
137
+ # Underscore notation for compatibility with CSS classes, etc.
138
+ #
139
+ rule identifier
140
+ [a-zA-Z0-9_-]+
141
+ end
142
+
143
+ # String in double quotes, with backslash escaping.
144
+ #
145
+ rule quoted_string
146
+ '"' ( ('\\' .) / (!'"' .) )+ '"'
147
+ end
148
+
149
+ # One or more spaces.
150
+ #
151
+ rule space
152
+ "\s"+
153
+ end
154
+
155
+ # Zero or more spaces.
156
+ #
157
+ rule extra_space
158
+ "\s"*
159
+ end
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,67 @@
1
+ #
2
+ #
3
+ #
4
+ # Copyright 2013 Canopy Canopy Canopy, Inc.
5
+ # Authors Adam Florin & Anthony Tran.
6
+ #
7
+ module Alongslide
8
+ module Grammar
9
+ grammar Panel
10
+
11
+ # All panel params.
12
+ #
13
+ rule panel_params
14
+ (space param:(position/transition/placement/depth))*
15
+ end
16
+
17
+ # All section params.
18
+ #
19
+ rule section_params
20
+ (space param:(transition/columns))*
21
+ end
22
+
23
+ # Position: fullscreen or pinned.
24
+ #
25
+ rule position
26
+ "fullscreen" / ("pin" space edge (space size)?)
27
+ end
28
+
29
+ #
30
+ #
31
+ rule columns
32
+ "three-columns"
33
+ end
34
+
35
+ # Screen edge.
36
+ #
37
+ rule edge
38
+ "left" / "top" / "right" / "bottom"
39
+ end
40
+
41
+ # Transition animation style.
42
+ #
43
+ rule transition
44
+ ("fade" / "slide") "-" ("in" / "out")
45
+ end
46
+
47
+ # Keyword to bias panel placement immediately or later (default)
48
+ #
49
+ rule placement
50
+ "now" / "later"
51
+ end
52
+
53
+ # Size of panel
54
+ #
55
+ rule size
56
+ "one-third" / "half" / "two-thirds"
57
+ end
58
+
59
+ # Depth, i.e. z-index.
60
+ #
61
+ rule depth
62
+ "front"
63
+ end
64
+
65
+ end
66
+ end
67
+ end