Make note color palette a configurable setting

master
Skylar Ittner 5 years ago
parent c24c2ad403
commit 7ec301bb19

@ -0,0 +1,52 @@
<?php
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
class Colors {
static $colors = [
// Pastel colors
"EF9A9A", // red
"FFCC80", // orange
"FFF59D", // yellow
"E6EE9C", // lime
"A5D6A7", // green
"80CBC4", // teal
"81D4FA", // light blue
"90CAF9", // blue
"B39DDB", // purple
"F48FB1", // pink
// Bright colors
"F44336", // red
"FF9800", // orange
"FFEB3B", // yellow
"8BC34A", // light green
"4CAF50", // green
"009688", // teal
"03A9F4", // light blue
"2196F3", // blue
"673AB7", // purple
"E91E63", // pink
// Other colors
"FFFFFF", // white
"E0E0E0", // pastel gray
"9E9E9E", // gray
"BCAAA4", // pastel brown
"795548", // brown
"000000", // black
];
static function init() {
global $SETTINGS;
if (!empty($SETTINGS['note_colors']) && is_array($SETTINGS['note_colors']) && count($SETTINGS['note_colors']) > 0) {
Colors::$colors = $SETTINGS['note_colors'];
}
}
}
Colors::init();

@ -31,38 +31,6 @@ if ($notequotaset) {
<style nonce="<?php echo $SECURE_NONCE; ?>">
<?php
$colors = [
// Pastel colors
"EF9A9A", // red
"FFCC80", // orange
"FFF59D", // yellow
"E6EE9C", // lime
"A5D6A7", // green
"80CBC4", // teal
"81D4FA", // light blue
"90CAF9", // blue
"B39DDB", // purple
"F48FB1", // pink
// Bright colors
"F44336", // red
"FF9800", // orange
"FFEB3B", // yellow
"8BC34A", // light green
"4CAF50", // green
"009688", // teal
"03A9F4", // light blue
"2196F3", // blue
"673AB7", // purple
"E91E63", // pink
// Other colors
"FFFFFF", // white
"E0E0E0", // pastel gray
"9E9E9E", // gray
"BCAAA4", // pastel brown
"795548", // brown
"000000", // black
];
foreach ($notes as $note) {
echo "#notecard_" . $note->getID() . ", #notecard_" . $note->getID() . " .card-body a {\n"
. " background-color: #" . $note->getColor() . ";\n"
@ -77,7 +45,7 @@ foreach ($notes as $note) {
. "}\n";
}
foreach ($colors as $c) {
foreach (Colors::$colors as $c) {
echo ".bg_$c {\n"
. " background-color: #$c !important;\n"
. " border: 1px solid #$c !important;\n"
@ -269,7 +237,7 @@ foreach ($colors as $c) {
<div class="modal-body">
<div class="d-flex flex-wrap justify-content-center">
<?php
foreach ($colors as $c) {
foreach (Colors::$colors as $c) {
?>
<button type="submit" name="color" value="<?php echo $c; ?>" class="btn bg_<?php echo $c; ?> m-1">
&nbsp;

@ -49,6 +49,38 @@ $SETTINGS = [
// HTML to show when the quota is reached. "{{notecount}}" and "{{notelimit}}"
// will be replaced with the number of notes the user has and the note_limit.
"quota_msg_content" => "",
// List of background colors available for users to pick from.
"note_colors" => [
// Pastel colors
"EF9A9A", // red
"FFCC80", // orange
"FFF59D", // yellow
"E6EE9C", // lime
"A5D6A7", // green
"80CBC4", // teal
"81D4FA", // light blue
"90CAF9", // blue
"B39DDB", // purple
"F48FB1", // pink
// Bright colors
"F44336", // red
"FF9800", // orange
"FFEB3B", // yellow
"8BC34A", // light green
"4CAF50", // green
"009688", // teal
"03A9F4", // light blue
"2196F3", // blue
"673AB7", // purple
"E91E63", // pink
// Other colors
"FFFFFF", // white
"E0E0E0", // pastel gray
"9E9E9E", // gray
"BCAAA4", // pastel brown
"795548", // brown
"000000", // black
],
// For supported values, see http://php.net/manual/en/timezones.php
"timezone" => "America/Denver",
// Language to use for localization. See langs folder to add a language.

Loading…
Cancel
Save