Improve script, make BS4 CSS

bootstrap-4
Skylar Ittner 6 years ago
parent a21a5ffb2f
commit 557a7956b2

@ -1,4 +1,6 @@
<?php
$use_variables = false;
$classes = ["alert", "badge", "btn", "bg", "list-group-item"];
$colors = [
@ -20,45 +22,81 @@ $colors = [
"deep-orange" => "#ff5722",
"brown" => "#795548",
"grey" => "#9e9e9e",
"blue-grey" => "#607d8b",
"blue-grey" => "#607d8b"
];
$texts = [
"red" => "white",
"pink" => "white",
"purple" => "white",
"deep-purple" => "white",
"indigo" => "white",
"blue" => "white",
"light-blue" => "black",
"cyan" => "black",
"teal" => "white",
"green" => "white",
"light-green" => "black",
"lime" => "black",
"yellow" => "black",
"amber" => "black",
"orange" => "black",
"deep-orange" => "white",
"brown" => "white",
"grey" => "black",
"red" => "white",
"pink" => "white",
"purple" => "white",
"deep-purple" => "white",
"indigo" => "white",
"blue" => "white",
"light-blue" => "black",
"cyan" => "black",
"teal" => "white",
"green" => "white",
"light-green" => "black",
"lime" => "black",
"yellow" => "black",
"amber" => "black",
"orange" => "black",
"deep-orange" => "white",
"brown" => "white",
"grey" => "black",
"blue-grey" => "white"
];
echo ":root {\n";
foreach ($colors as $k => $v) {
if (strpos($k, "text-") !== FALSE) {
continue;
/* License header */
$year = date('Y');
echo <<<END
/* Material-Color.css
* Copyright (c) $year Netsyms Technologies
* MIT License
* https://source.netsyms.com/Netsyms/Material-Color
*/
END;
/* Make CSS variables */
if ($use_variables) {
echo ":root {\n";
foreach ($colors as $k => $v) {
if (strpos($k, "text-") !== FALSE) {
continue;
}
echo "\t--material-color-$k: $v;\n";
}
echo "\t--material-color-$k: $v;\n";
echo "}\n\n";
}
echo "}\n\n";
/* The fun bit */
foreach ($classes as $c) {
foreach ($colors as $k => $v) {
$textcolor = $texts[$k];
echo ".$c-$k {\n\tbackground-color: var(--material-color-$k);\n\tcolor: $textcolor;\n}\n";
// Save a few bytes
if ($textcolor == "white") {
$textcolor = "#fff";
} else if ($textcolor == "black") {
$textcolor = "#000";
}
// Class and background color
echo ".$c-$k {\n\tbackground-color: ";
if ($use_variables) {
echo "var(--material-color-$k)";
} else {
echo $v;
}
echo ";\n";
// Text color
if ($c != "bg") {
echo "\tcolor: $textcolor;\n";
}
echo "}\n";
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save