Improve script, make BS4 CSS
This commit is contained in:
parent
a21a5ffb2f
commit
557a7956b2
92
generate.php
92
generate.php
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
$use_variables = false;
|
||||||
|
|
||||||
$classes = ["alert", "badge", "btn", "bg", "list-group-item"];
|
$classes = ["alert", "badge", "btn", "bg", "list-group-item"];
|
||||||
|
|
||||||
$colors = [
|
$colors = [
|
||||||
@ -20,45 +22,81 @@ $colors = [
|
|||||||
"deep-orange" => "#ff5722",
|
"deep-orange" => "#ff5722",
|
||||||
"brown" => "#795548",
|
"brown" => "#795548",
|
||||||
"grey" => "#9e9e9e",
|
"grey" => "#9e9e9e",
|
||||||
"blue-grey" => "#607d8b",
|
"blue-grey" => "#607d8b"
|
||||||
];
|
];
|
||||||
|
|
||||||
$texts = [
|
$texts = [
|
||||||
"red" => "white",
|
"red" => "white",
|
||||||
"pink" => "white",
|
"pink" => "white",
|
||||||
"purple" => "white",
|
"purple" => "white",
|
||||||
"deep-purple" => "white",
|
"deep-purple" => "white",
|
||||||
"indigo" => "white",
|
"indigo" => "white",
|
||||||
"blue" => "white",
|
"blue" => "white",
|
||||||
"light-blue" => "black",
|
"light-blue" => "black",
|
||||||
"cyan" => "black",
|
"cyan" => "black",
|
||||||
"teal" => "white",
|
"teal" => "white",
|
||||||
"green" => "white",
|
"green" => "white",
|
||||||
"light-green" => "black",
|
"light-green" => "black",
|
||||||
"lime" => "black",
|
"lime" => "black",
|
||||||
"yellow" => "black",
|
"yellow" => "black",
|
||||||
"amber" => "black",
|
"amber" => "black",
|
||||||
"orange" => "black",
|
"orange" => "black",
|
||||||
"deep-orange" => "white",
|
"deep-orange" => "white",
|
||||||
"brown" => "white",
|
"brown" => "white",
|
||||||
"grey" => "black",
|
"grey" => "black",
|
||||||
"blue-grey" => "white"
|
"blue-grey" => "white"
|
||||||
];
|
];
|
||||||
|
|
||||||
echo ":root {\n";
|
|
||||||
foreach ($colors as $k => $v) {
|
/* License header */
|
||||||
if (strpos($k, "text-") !== FALSE) {
|
$year = date('Y');
|
||||||
continue;
|
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 ($classes as $c) {
|
||||||
foreach ($colors as $k => $v) {
|
foreach ($colors as $k => $v) {
|
||||||
$textcolor = $texts[$k];
|
$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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
2357
material-color.css
2357
material-color.css
File diff suppressed because it is too large
Load Diff
4
material-color.min.css
vendored
4
material-color.min.css
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user