-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile-css.php
More file actions
82 lines (69 loc) · 1.75 KB
/
compile-css.php
File metadata and controls
82 lines (69 loc) · 1.75 KB
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
<?php
// Config
$MAX_ITEMS = 80;
$MINIMIZE = true;
$PAD_LENGTH = 0;
// Styling
$COMMENT = "
/*******************************************
* This file creates beautiful binary lists
* Use whenever you feel awesome
* ! This compiled version only features a
* ! maximum of %d rows :(
*******************************************/
";
$SUFFIX = ' .';
$TABULATOR = "\t";
$SPACE = " ";
$DEFINITION_END = ";";
$LAST_DEFINITION_END = ";";
$LINE_SEPARATOR = "\n";
$END_OF_LINE = PHP_EOL;
$DEFINITION_LINE_SPACE = "\n";
// Items
$SELECTOR = 'ol';
$ITEM = 'li';
if($MINIMIZE) {
$COMMENT = "/* Changed numbered lists to binary :). !Max rows: %d */\n";
$TABULATOR = '';
$SPACE = '';
$LINE_SEPARATOR = '';
$END_OF_LINE = '';
}
/**
* Create css
*/
function print_style($selector, $arr) {
global $SPACE,
$TABULATOR,
$DEFINITION_END,
$LINE_SEPARATOR,
$DEFINITION_LINE_SPACE;
echo "{$selector}{$SPACE}{{$LINE_SEPARATOR}";
foreach($arr as $key => $val) {
echo $TABULATOR;
echo "{$key}:{$SPACE}";
echo "{$val}{$DEFINITION_END}";
echo $LINE_SEPARATOR;
}
echo "}";
echo $DEFINITION_LINE_SPACE;
}
// Output comment
printf($COMMENT, $MAX_ITEMS);
// Main style
print_style("{$SELECTOR} {$ITEM}", array(
'list-style-type' => 'none'
));
// Main style for item
print_style("{$SELECTOR} {$ITEM}:before", array(
'display' => 'inline',
'content' => '""'
));
// Create all rows
for($i = 0; $i < $MAX_ITEMS; $i += 1) {
$bin = str_pad(decbin($i), $PAD_LENGTH, '0', STR_PAD_LEFT);
print_style(sprintf("{$SELECTOR} {$ITEM}:nth-child(%d):before", $i), array(
'content' => sprintf('"%s"', $bin) . $SUFFIX
));
}