gkss-rails 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @license
3
+ * Copyright (C) 2015 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ /* Pretty printing styles. Used with prettify.js. */
19
+
20
+
21
+ /* SPAN elements with the classes below are added by prettyprint. */
22
+ .pln { color: #000 } /* plain text */
23
+
24
+ @media screen {
25
+ .str { color: #080 } /* string content */
26
+ .kwd { color: #008 } /* a keyword */
27
+ .com { color: #800 } /* a comment */
28
+ .typ { color: #606 } /* a type name */
29
+ .lit { color: #066 } /* a literal value */
30
+ /* punctuation, lisp open bracket, lisp close bracket */
31
+ .pun, .opn, .clo { color: #660 }
32
+ .tag { color: #008 } /* a markup tag name */
33
+ .atn { color: #606 } /* a markup attribute name */
34
+ .atv { color: #080 } /* a markup attribute value */
35
+ .dec, .var { color: #606 } /* a declaration; a variable name */
36
+ .fun { color: red } /* a function name */
37
+ }
38
+
39
+ /* Use higher contrast and text-weight for printable form. */
40
+ @media print, projection {
41
+ .str { color: #060 }
42
+ .kwd { color: #006; font-weight: bold }
43
+ .com { color: #600; font-style: italic }
44
+ .typ { color: #404; font-weight: bold }
45
+ .lit { color: #044 }
46
+ .pun, .opn, .clo { color: #440 }
47
+ .tag { color: #006; font-weight: bold }
48
+ .atn { color: #404 }
49
+ .atv { color: #060 }
50
+ }
51
+
52
+ /* Put a border around prettyprinted code snippets. */
53
+ pre.prettyprint { padding: 2px; border: 1px solid #888 }
54
+
55
+ /* Specify class=linenums on a pre to get line numbering */
56
+ ol.linenums { margin-top: 0; margin-bottom: 0 } /* IE indents via margin-left */
57
+ li.L0,
58
+ li.L1,
59
+ li.L2,
60
+ li.L3,
61
+ li.L5,
62
+ li.L6,
63
+ li.L7,
64
+ li.L8 { list-style-type: none }
65
+ /* Alternate shading for lines */
66
+ li.L1,
67
+ li.L3,
68
+ li.L5,
69
+ li.L7,
70
+ li.L9 { background: #eee }
@@ -0,0 +1,615 @@
1
+ // # Templates: Styleguide CSS
2
+ // This is the CSS stylesheet for the styleguide pages.
3
+
4
+ $pad: 30px
5
+ $checkerboard: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAAAAACoWZBhAAAAF0lEQVQI12P4BAI/QICBFCaYBPNJYQIAkUZftTbC4sIAAAAASUVORK5CYII="
6
+ $dark-checkerboard: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAAAAACoWZBhAAAAFklEQVQI12NQBQF2EGAghQkmwXxSmADZJQiZ2ZZ46gAAAABJRU5ErkJggg=="
7
+ $mono: 'Menlo', 'Monaco', 'Lucida Console', monospace
8
+ $sans: 'Helvetica Neue', sans-serif
9
+ $bluish: #f0f7fb
10
+ $blue: #3ad
11
+
12
+ = box-sizing($val)
13
+ -webkit-box-sizing: $val
14
+ -moz-box-sizing: $val
15
+ -ms-box-sizing: $val
16
+ -o-box-sizing: $val
17
+ box-sizing: $val
18
+
19
+ html, body
20
+ margin: 0
21
+ padding: 0
22
+
23
+ @mixin code
24
+ background: #eee
25
+ padding: 4px 4px
26
+ border-radius: 2px
27
+ margin: 0 2px
28
+ box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2)
29
+
30
+ .sg-badge
31
+ position: absolute
32
+ z-index: 1
33
+ right: 0
34
+ bottom: 0
35
+ padding: 5px 10px
36
+ background: #eee
37
+ color: #888
38
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7)
39
+ border-top-left-radius: 3px
40
+ border-top-right-radius: 3px
41
+ border-left: solid 1px #ddd
42
+ border-right: solid 1px #ddd
43
+ border-top: solid 1px #ddd
44
+ font-size: 9pt
45
+ font-family: $sans
46
+
47
+ body
48
+ padding: 50px !important
49
+ background: #fcfcfc !important
50
+ border-top: solid 6px #222 !important
51
+
52
+ @media (max-width: 480px) /* Mobile */
53
+ padding: 10px !important
54
+
55
+ html, body
56
+ overflow: inherit !important
57
+
58
+ // ### Layout
59
+
60
+ .sg-body
61
+ margin-left: 180px + $pad
62
+ padding-bottom: 20px
63
+
64
+ body .sg-toc
65
+ +box-sizing(content-box)
66
+ font-family: $sans
67
+ font-size: 10pt
68
+ width: 180px
69
+ position: fixed
70
+ padding: 0 20px $pad $pad
71
+ top: 50px
72
+ left: 10px
73
+ bottom: 0
74
+ z-index: 10
75
+
76
+ overflow-y: auto
77
+
78
+ &::-webkit-scrollbar
79
+ width: 10px
80
+ height: 10px
81
+
82
+ &::-webkit-scrollbar-thumb
83
+ background: rgba(0, 0, 0, 0.0)
84
+ border-radius: 5px
85
+
86
+ &:hover::-webkit-scrollbar-thumb
87
+ background: rgba(0, 0, 0, 0.2)
88
+
89
+ // ----------------------------------------------------------------------------
90
+
91
+ // ### Full layout
92
+
93
+ body.sg-full
94
+ .sg-toc
95
+ display: none
96
+ .sg-body
97
+ margin-left: 0
98
+ margin-right: 0
99
+
100
+ // Sidebar toggle button
101
+ .sg-toggle-sidebar
102
+ margin: 0
103
+ padding: 0
104
+ border: 0
105
+ background: rgba(black, 0.0)
106
+
107
+ position: fixed
108
+ left: 0
109
+ top: 0
110
+ bottom: 0
111
+ z-index: 11
112
+
113
+ line-height: 100%
114
+
115
+ width: 20px
116
+
117
+ cursor: pointer
118
+
119
+ color: #aaa
120
+ text-shadow: 0 1px 0 rgba(white, 0.8)
121
+ font-size: 8pt
122
+ font-family: $sans
123
+ text-align: center
124
+
125
+ &:before
126
+ content: '\25c0'
127
+ display: none
128
+
129
+ &:hover
130
+ background: rgba(black, 0.1)
131
+ border-right: solid 1px rgba(black, 0.03)
132
+
133
+ &:before
134
+ display: block
135
+
136
+ // ----------------------------------------------------------------------------
137
+
138
+ // ### Contents
139
+
140
+ .sg-toc
141
+ h1
142
+ font-size: 18pt
143
+ color: #888
144
+ font-weight: 200
145
+ line-height: 1.2
146
+
147
+ margin-bottom: 0px
148
+ padding-bottom: 30px
149
+
150
+ small, strong
151
+ display: block
152
+ text-align: right
153
+
154
+ small
155
+ font-size: 1em
156
+ strong
157
+ font-weight: bold
158
+ color: #222
159
+
160
+ ul, li
161
+ list-style-type: none
162
+ margin: 0
163
+ padding: 0
164
+
165
+ li a
166
+ border-top: solid 1px #eee
167
+
168
+ a
169
+ display: block
170
+ padding: 7px 0
171
+ +box-sizing(content-box)
172
+
173
+ height: 24px
174
+ line-height: 24px
175
+
176
+ a:visited, a
177
+ font-weight: normal
178
+ color: #777
179
+
180
+ a:after
181
+ content: ''
182
+ display: table
183
+ clear: both
184
+
185
+ a:hover
186
+ color: #36c
187
+
188
+ a.active
189
+ font-weight: bold
190
+ color: #222
191
+
192
+ .sg-number
193
+ float: left
194
+
195
+ a .sg-number:after
196
+ content: '\2192'
197
+ margin-left: 10px
198
+ color: #ddd
199
+
200
+ .sg-name
201
+ float: right
202
+ text-align: right
203
+
204
+ // ----------------------------------------------------------------------------
205
+
206
+ // Layout
207
+ .sg-body .sg-example
208
+ margin-bottom: $pad
209
+
210
+ // ### An example block
211
+
212
+ .sg-example
213
+ position: relative
214
+
215
+ // View code button
216
+ .sg-button
217
+ position: absolute
218
+ right: 10px
219
+ bottom: 10px
220
+ z-index: 10
221
+
222
+ // Filename badge
223
+ .sg-filename
224
+ @extend .sg-badge
225
+ display: none
226
+
227
+ &:hover .sg-filename
228
+ display: block
229
+
230
+ // Description
231
+ .sg-description
232
+ line-height: 1.5
233
+ font-family: $sans
234
+ position: relative
235
+
236
+ code
237
+ @include code
238
+
239
+ > h3 a, > h3 a:visited
240
+ background: transparent
241
+ color: #aaa
242
+ text-align: center
243
+ font-weight: 200
244
+ font-size: 11pt
245
+ font-family: $sans
246
+
247
+ border: solid 1px #ddd
248
+ +box-sizing(border-box)
249
+
250
+ display: block
251
+ width: 50px
252
+ height: 50px
253
+ line-height: 48px
254
+
255
+ float: right
256
+ margin-left: 20px
257
+ border-radius: 25px
258
+
259
+ > h3 a:hover
260
+ color: $blue
261
+ border-color: $blue
262
+
263
+ .sg-description
264
+ padding: 5px 0 25px 0
265
+ font-size: 10pt
266
+ color: #444
267
+
268
+ .sg-description
269
+ p, ul
270
+ margin-top: 5px
271
+
272
+ h1, h2, h3, h4, h5, h6
273
+ color: #222
274
+ margin: 0
275
+ padding: 0
276
+ font-weight: bold
277
+ font-size: 12pt
278
+
279
+ code
280
+ font-size: 0.9em
281
+ color: $blue
282
+ font-weight: normal
283
+ margin-left: 7px
284
+ padding: 0
285
+
286
+ background: transparent
287
+ box-shadow: none
288
+
289
+ font-family: $mono
290
+
291
+ &:before
292
+ content: '\203a'
293
+ margin-right: 10px
294
+ color: #ddd
295
+
296
+ ul.sg-modifiers
297
+ &
298
+ margin: 20px 0 0 25px
299
+ padding: 0
300
+ list-style-type: none
301
+
302
+ li
303
+ margin: 5px 0
304
+ padding: 0
305
+ list-style-type: disc
306
+
307
+ li strong
308
+ @include code
309
+ padding: 1px 5px
310
+ font-weight: bold
311
+
312
+ .sg-html
313
+ &
314
+ display: none
315
+ &.sg-expanded
316
+ display: block
317
+
318
+ border: solid 1px #ccc
319
+ border-top: 0
320
+ position: relative
321
+
322
+ background: $bluish
323
+
324
+ pre
325
+ padding: 20px !important
326
+ line-height: 1.5
327
+ border: 0 !important
328
+ color: #30305a
329
+ text-shadow: 0 1px 0 rgba(white, 0.6)
330
+ font-size: 8pt
331
+ font-family: $mono
332
+
333
+ overflow-y: scroll
334
+
335
+ .sg-canvases
336
+ border: solid 4px #f0f0f0
337
+ border-radius: 2px
338
+
339
+ // ## Canvas
340
+ .sg-canvas
341
+ &
342
+ overflow: hidden
343
+ overflow-x: auto
344
+ border: solid 1px #ccc
345
+
346
+ position: relative
347
+ z-index: 0
348
+
349
+ // Collapse
350
+ & + .sg-canvas
351
+ margin-top: -1px
352
+
353
+ &::-webkit-scrollbar
354
+ width: 10px
355
+ height: 10px
356
+
357
+ &::-webkit-scrollbar-thumb
358
+ background: rgba(0, 0, 0, 0.05)
359
+ border-radius: 5px
360
+ border: solid 3px #f4f4f4
361
+
362
+ &:hover::-webkit-scrollbar-thumb
363
+ background: rgba(0, 0, 0, 0.3)
364
+
365
+ & > div
366
+ padding: 25px
367
+ zoom: 1
368
+
369
+ & > div:after
370
+ content: ''
371
+ clear: both
372
+ display: table
373
+
374
+ // Reset the inside elements of the canvas.
375
+ & > div > *
376
+ margin: 0 auto !important
377
+ float: none !important
378
+ position: relative !important
379
+ bottom: inherit
380
+ right: inherit
381
+ left: inherit
382
+ top: inherit
383
+
384
+ &.align-center > div
385
+ text-align: center
386
+
387
+ &.align-left > div
388
+ text-align: left
389
+
390
+ &.align-right > div
391
+ text-align: right
392
+
393
+ // Light
394
+ &.bg-clear
395
+ background: transparent
396
+
397
+ &.bg-light
398
+ background: url($checkerboard)
399
+
400
+ &.bg-white
401
+ background: #fff
402
+ border: solid 10px #ddd
403
+
404
+ &.bg-black
405
+ background: #000
406
+
407
+ &.bg-dark
408
+ background: url($dark-checkerboard)
409
+
410
+ // Canvas modifier
411
+ & > .sg-modifier-name
412
+ @extend .sg-badge
413
+ bottom: auto
414
+ top: 0
415
+
416
+ border-bottom: solid 1px #ddd
417
+ border-top: 0
418
+ border-right: 0
419
+ border-radius: 0
420
+ border-bottom-left-radius: 3px
421
+
422
+ font-weight: bold
423
+ color: #222
424
+ padding: 3px 15px
425
+
426
+ // ----------------------------------------------------------------------------
427
+
428
+ // Scroll
429
+ .sg-html pre
430
+ &::-webkit-scrollbar
431
+ width: 15px
432
+ height: 15px
433
+
434
+ &::-webkit-scrollbar-thumb
435
+ background: rgba(0, 0, 0, 0.1)
436
+ border-radius: 8px
437
+ border: solid 3px $bluish
438
+
439
+ // ### Type specimens
440
+
441
+ .sg-specimen
442
+ margin: 0 auto
443
+ width: 600px
444
+ padding: 40px
445
+ background: white
446
+ box-shadow: 0 0 3px rgba(0, 0, 0, 0.1)
447
+ color: #333
448
+
449
+ .sg-drop
450
+ font-size: 4em
451
+ display: block
452
+ float: right
453
+ margin: -40px 0px 30px 30px
454
+ background: #f0f0f0
455
+ padding: 20px
456
+
457
+ h3
458
+ font-size: 1.8em
459
+ white-space: wrap
460
+
461
+ p
462
+ margin-top: 0.9em
463
+
464
+ p.sg-small
465
+ color: #aaa
466
+ text-transform: uppercase
467
+ padding-bottom: 0.5em
468
+ margin-bottom: 2.1em
469
+ border-bottom: solid 1px #eee
470
+
471
+ p strong
472
+ font-weight: bold
473
+ display: block
474
+ font-size: 1.2em
475
+
476
+ // ### Color swatches
477
+
478
+ .sg-canvas .sg-swatch
479
+ &
480
+ background: white
481
+ font-size: 8pt
482
+ line-height: 1.3
483
+ padding: 3px
484
+ box-shadow: 0 0 3px rgba(black, 0.2)
485
+ position: relative
486
+
487
+ display: inline-block
488
+ vertical-align: top
489
+
490
+ margin: 10px !important
491
+
492
+ text-align: left
493
+
494
+ strong
495
+ display: block
496
+ color: #333
497
+ font-size: 1.1em
498
+ font-weight: bold
499
+
500
+ small
501
+ display: block
502
+ border-top: solid 1px rgba(black, 0.05)
503
+ margin-top: 5px
504
+ padding-top: 5px
505
+
506
+ .sg-text
507
+ font-weight: bold
508
+ padding: 2px 5px
509
+ background: white
510
+ position: absolute
511
+ bottom: 0px
512
+ right: 0px
513
+ border-top-left-radius: 2px
514
+
515
+ .sg-background
516
+ width: 100px
517
+ height: 100px
518
+ padding: 10px
519
+ +box-sizing(border-box)
520
+
521
+ &
522
+ color: rgba(black, 0.5)
523
+ text-shadow: 0 1px 0 rgba(white, 0.2)
524
+
525
+ &.sg-dark
526
+ .sg-background
527
+ color: rgba(#fff, 0.5)
528
+ text-shadow: 0 1px 0 rgba(black, 0.2)
529
+
530
+ strong
531
+ color: #fff
532
+
533
+ small
534
+ border-top-color: rgba(white, 0.05)
535
+
536
+ &:hover
537
+ .sg-text
538
+ color: #222 !important
539
+
540
+ .sg-page-title
541
+ font-size: 28pt
542
+ line-height: 36pt
543
+ font-weight: bold
544
+ color: #999
545
+
546
+ margin: 0 0 30px 0
547
+ padding: 13px 0 20px 0
548
+ border-bottom: solid 1px #eee
549
+
550
+ font-family: $sans
551
+ font-weight: 200
552
+
553
+ overflow: hidden
554
+
555
+ // Number
556
+ strong
557
+ color: #ccc
558
+
559
+ display: inline-block
560
+ width: 60px
561
+ margin-left: -60px
562
+ text-align: right
563
+ float: right
564
+
565
+ font-weight: 700
566
+ font-size: 0.5em
567
+
568
+ // ----------------------------------------------------------------------------
569
+
570
+ .sg-button
571
+ margin: 0
572
+ padding: 0
573
+ border: 0
574
+ display: inline-block
575
+
576
+ background: #f0fafa
577
+ border-radius: 4px
578
+ box-shadow: inset 0 0 0 1px rgba(black, 0.1), inset 0 2px 0 rgba(white, 0.2)
579
+
580
+ height: 24px
581
+ line-height: 24px
582
+ padding: 0 15px
583
+
584
+ font-size: 9pt
585
+ font-weight: bold
586
+ font-family: $sans
587
+
588
+ color: #555
589
+ text-shadow: 0 1px 0 rgba(white, 0.9)
590
+
591
+ cursor: pointer
592
+
593
+ &:hover
594
+ background: #f0fafa
595
+ color: #509090
596
+ // Glyph
597
+ &:after
598
+ content: '\25bc'
599
+ margin-left: 6px
600
+ font-size: 0.6em
601
+ color: #a0afaf
602
+
603
+ &.sg-expanded
604
+ background: #f0fafa * 0.95
605
+
606
+ &.sg-expanded:after
607
+ content: '\25b2'
608
+
609
+ // Clickity
610
+ &:active
611
+ background: #509090
612
+ color: #eee
613
+ text-shadow: 0 1px 0 rgba(black, 0.3)
614
+ box-shadow: inset 0 0 0 1px rgba(black, 0.1)
615
+
@@ -0,0 +1,52 @@
1
+ class StyleguidesController < ApplicationController
2
+
3
+ helper :styleguide
4
+
5
+ helper_method :styleguide_options
6
+ helper_method :styleguide_title
7
+ helper_method :styleguide_sections
8
+ helper_method :styleguide_root
9
+ helper_method :styleguide_include_js
10
+
11
+ before_filter :set_styleguide, :only => [ :show, :all ]
12
+
13
+ def show
14
+ @section = params[:section].to_i
15
+
16
+ render template: "styleguides/#{@section}", layout: 'styleguide_page'
17
+ end
18
+
19
+ def all
20
+ @sections = styleguide_sections
21
+ @single_page = true
22
+ render template: "styleguides/all", layout: 'styleguide_page'
23
+ end
24
+
25
+ private
26
+
27
+ def set_styleguide
28
+ require 'kss'
29
+ @styleguide = Kss::Parser.new(styleguide_root)
30
+ end
31
+
32
+ def styleguide_options
33
+ @styleguide_options ||= YAML::load_file("#{Rails.root}/config/styleguides.yml")
34
+ end
35
+
36
+ def styleguide_title
37
+ styleguide_options['title']
38
+ end
39
+
40
+ def styleguide_sections
41
+ styleguide_options['sections']
42
+ end
43
+
44
+ def styleguide_root
45
+ path = styleguide_options['root'] || '/app/assets/stylesheets'
46
+ File.join Rails.root, path
47
+ end
48
+
49
+ def styleguide_include_js
50
+ styleguide_options['include_js'] || 'application'
51
+ end
52
+ end