Improve script, make BS4 CSS
This commit is contained in:
parent
a21a5ffb2f
commit
557a7956b2
50
generate.php
50
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,7 +22,7 @@ $colors = [
|
|||||||
"deep-orange" => "#ff5722",
|
"deep-orange" => "#ff5722",
|
||||||
"brown" => "#795548",
|
"brown" => "#795548",
|
||||||
"grey" => "#9e9e9e",
|
"grey" => "#9e9e9e",
|
||||||
"blue-grey" => "#607d8b",
|
"blue-grey" => "#607d8b"
|
||||||
];
|
];
|
||||||
|
|
||||||
$texts = [
|
$texts = [
|
||||||
@ -45,20 +47,56 @@ $texts = [
|
|||||||
"blue-grey" => "white"
|
"blue-grey" => "white"
|
||||||
];
|
];
|
||||||
|
|
||||||
echo ":root {\n";
|
|
||||||
foreach ($colors as $k => $v) {
|
/* 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) {
|
if (strpos($k, "text-") !== FALSE) {
|
||||||
continue;
|
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