File: prefix.grid.styl

package info (click to toggle)
node-stylus 0.54.5-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 5,392 kB
  • ctags: 913
  • sloc: makefile: 38
file content (92 lines) | stat: -rw-r--r-- 2,794 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Modified version of Bootstrap3's grid generation code

// Number of columns in the grid.
grid-columns = 12
// Padding between columns. Gets divided in half for the left and right.
grid-gutter-width = 30px

lesscss-percentage(n)
  (n * 100)%

// Framework grid generation
//
// Used only by Bootstrap to generate the correct number of grid classes given
// any value of `@grid-columns`.
make-grid-columns()
  // Common styles for all sizes of grid columns, widths 1-12
  // recursive method
  col(index, list)
    if index <= grid-columns
      // general
      item = unquote(".col-xs-" + index + ", .col-sm-" + index + ", .col-md-" + index + ", .col-lg-" + index + "")
      col((index + 1), unquote("" + list + ", " + item + ""))
    else
      // terminal
      {list}
        position relative
        // Prevent columns from collapsing when empty
        min-height 1px
        // Inner gutter via padding
        padding-left (grid-gutter-width / 2)
        padding-right (grid-gutter-width / 2)

  // initial method
  col_start(index)
    item = unquote(".col-xs-" + index + ", .col-sm-" + index + ", .col-md-" + index + ", .col-lg-" + index + "")
    col((index + 1), item)
  col_start(1)  // kickstart it

float-grid-columns(class)
  // recursive method
  col(index, list)
    if index <= grid-columns
      item = unquote(".col-" + class + "-" + index + "")
      col((index + 1), unquote("" + list + ", " + item + ""))
    else
      {list}
        float left
  // initial
  col_start(index)
    item = unquote(".col-" + class + "-" + index + "")
    col((index + 1), item)
  col_start(1)  // kickstart it


calc-grid-column(index, class, type)
  if index > 0 and type == width
    item = unquote(".col-" + class + "-" + index + "")
    {item}
      width lesscss-percentage((index / grid-columns))
  else if type == push
    item = unquote(".col-" + class + "-push-" + index + "")
    {item}
      left lesscss-percentage((index / grid-columns))
  else if type == pull
    item = unquote(".col-" + class + "-pull-" + index + "")
    {item}
      right lesscss-percentage((index / grid-columns))
  else if type == offset
    item = unquote(".col-" + class + "-offset-" + index + "")
    {item}
      margin-left lesscss-percentage((index / grid-columns))

// Looping
loop-grid-columns(index, class, type)
  if index >= 0
    calc-grid-column(index, class, type)
    // next iteration
    loop-grid-columns((index - 1), class, type)

// Create grid for specific class
make-grid(class)
  float-grid-columns(class)
  loop-grid-columns(grid-columns, class, width)
  loop-grid-columns(grid-columns, class, pull)
  loop-grid-columns(grid-columns, class, push)
  loop-grid-columns(grid-columns, class, offset)

make-grid-columns()
make-grid(lg)
make-grid(md)
make-grid(sm)
make-grid(xs)