| Current Path : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/Html/ |
| Current File : /home/juvelize/saulnois/tmp/install_695d2cf0b4957/src/View/Html/TColor.php |
<?php
/*
* @package Tech Fry Library
* @license https://www.gnu.org/licenses/gpl-3.0.en.html
*/
namespace TechFry\Library\View\Html;
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
class TColor
{
public $color; // Name of color
public $head;
public $rgbs = []; // RGB Values
public function __construct($color)
{
/*
17 colors
gray, red, green, blue, yellow, purple, orange
pink, lime, teal, violet, indigo, cyan
choco, brown, sand, jungle
*/
$this->color = $color;
$this->head = new THead();
$this->get_rgbs();
}
// https://open-props.style/
public function get_rgbs()
{
// 1 - light; 11 - dark
switch ($this->color)
{
case 'blue' :
$this->rgbs = array(
1 => '208,235,255',
3 => '116,192,252',
9 => '24,100,171',
11 => '17,70,120',
);
break;
case 'brown' :
$this->rgbs = array(
1 => '237,224,209',
3 => '211,183,158',
9 => '111,75,45',
11 => '78,43,21',
);
break;
case 'choco' :
$this->rgbs = array(
1 => '252,225,188',
3 => '241,178,128',
9 => '138,69,19',
11 => '87,47,18',
);
break;
case 'cyan' :
$this->rgbs = array(
1 => '197,246,250',
3 => '102,217,232',
9 => '11,114,133',
11 => '7,70,82',
);
break;
case 'gray' :
$this->rgbs = array(
1 => '241,243,245',
3 => '222,226,230',
9 => '33,37,41',
11 => '13,15,18',
);
break;
case 'green' :
$this->rgbs = array(
1 => '211,249,216',
3 => '140,233,154',
9 => '43,138,62',
11 => '27,87,39',
);
break;
case 'indigo' :
$this->rgbs = array(
1 => '219,228,255',
3 => '145,167,255',
9 => '54,79,199',
11 => '40,58,148',
);
break;
case 'jungle' :
$this->rgbs = array(
1 => '222,243,154',
3 => '194,221,110',
9 => '122,153,8',
11 => '81,102,5',
);
break;
case 'lime' :
$this->rgbs = array(
1 => '233,250,200',
3 => '192,235,117',
9 => '92,148,13',
11 => '60,97,9',
);
break;
case 'orange' :
$this->rgbs = array(
1 => '255,232,204',
3 => '255,192,120',
9 => '217,72,15',
11 => '153,51,11',
);
break;
case 'pink' :
$this->rgbs = array(
1 => '255,222,235',
3 => '250,162,193',
9 => '166,30,77',
11 => '115,21,54',
);
break;
case 'purple' :
$this->rgbs = array(
1 => '243,217,250',
3 => '229,153,247',
9 => '134,46,156',
11 => '90,30,105',
);
break;
case 'red' :
$this->rgbs = array(
1 => '255,227,227',
3 => '255,168,168',
9 => '201,42,42',
11 => '150,32,32',
);
break;
case 'teal' :
$this->rgbs = array(
1 => '195,250,232',
3 => '99,230,190',
9 => '8,127,91',
11 => '5,77,55',
);
break;
case 'sand' :
$this->rgbs = array(
1 => '230,228,220',
3 => '194,185,160',
9 => '75,70,57',
11 => '37,37,33',
);
break;
case 'violet' :
$this->rgbs = array(
1 => '229,219,255',
3 => '177,151,252',
9 => '95,61,196',
11 => '70,45,145',
);
break;
case 'yellow' :
$this->rgbs = array(
1 => '255,243,191',
3 => '255,224,102',
9 => '230,119,0',
11 => '128,66,0',
);
break;
}
}
public function get_primary_css()
{
$css = '';
$root = array(
'--bs-link-color-rgb' => $this->rgbs[9],
'--bs-link-hover-color-rgb' => $this->rgbs[11],
'--bs-link-color' => 'rgb(' . $this->rgbs[9] . ')',
'--bs-link-hover-color' => 'rgb(' . $this->rgbs[11] . ')',
'--bs-primary-rgb' => $this->rgbs[9],
'--bs-primary-text-emphasis' => 'rgb(' . $this->rgbs[11] . ')',
'--bs-primary-bg-subtle' => 'rgb(' . $this->rgbs[1] . ')',
'--bs-primary-border-subtle' => 'rgb(' . $this->rgbs[3] . ')',
);
$css .= $this->head->css(':root', $root);
// Button
$button = array(
'--bs-btn-color' => '#fff',
'--bs-btn-bg' => 'rgb(' . $this->rgbs[9] . ')',
'--bs-btn-border-color' => 'rgb(' . $this->rgbs[9] . ')',
'--bs-btn-hover-color' => '#fff',
'--bs-btn-hover-bg' => 'rgb(' . $this->rgbs[11] . ')',
'--bs-btn-hover-border-color' => 'rgb(' . $this->rgbs[11] . ')',
);
$css .= $this->head->css('.btn-primary', $button);
// Outline Button
$outline_button = array(
'--bs-btn-color' => 'rgb(' . $this->rgbs[9] . ')',
'--bs-btn-border-color' => 'rgb(' . $this->rgbs[9] . ')',
'--bs-btn-hover-color' => '#fff',
'--bs-btn-hover-bg' => 'rgb(' . $this->rgbs[9] . ')',
'--bs-btn-hover-border-color' => 'rgb(' . $this->rgbs[9] . ')',
);
$css .= $this->head->css('.btn-outline-primary', $outline_button);
// Pagination
$pagination = array(
'background-color' => 'rgb(' . $this->rgbs[9] . ')',
'border-color' => 'rgb(' . $this->rgbs[9] . ')',
);
$css .= $this->head->css('.active>.page-link,.page-link.active', $pagination);
return $css;
}
public function get_secondary_css()
{
$css = '';
$root = array(
'--bs-secondary-rgb' => $this->rgbs[9],
'--bs-secondary-text-emphasis' => 'rgb(' . $this->rgbs[11] . ')',
'--bs-secondary-bg-subtle' => 'rgb(' . $this->rgbs[1] . ')',
'--bs-secondary-border-subtle' => 'rgb(' . $this->rgbs[3] . ')',
);
$css .= $this->head->css(':root', $root);
// Button
$button = array(
'--bs-btn-color' => '#fff',
'--bs-btn-bg' => 'rgb(' . $this->rgbs[9] . ')',
'--bs-btn-border-color' => 'rgb(' . $this->rgbs[9] . ')',
'--bs-btn-hover-color' => '#fff',
'--bs-btn-hover-bg' => 'rgb(' . $this->rgbs[11] . ')',
'--bs-btn-hover-border-color' => 'rgb(' . $this->rgbs[11] . ')',
);
$css .= $this->head->css('.btn-secondary', $button);
// Outline Button
$outline_button = array(
'--bs-btn-color' => 'rgb(' . $this->rgbs[9] . ')',
'--bs-btn-border-color' => 'rgb(' . $this->rgbs[9] . ')',
'--bs-btn-hover-color' => '#fff',
'--bs-btn-hover-bg' => 'rgb(' . $this->rgbs[9] . ')',
'--bs-btn-hover-border-color' => 'rgb(' . $this->rgbs[9] . ')',
);
$css .= $this->head->css('.btn-outline-secondary', $outline_button);
return $css;
}
public function hex_to_rgb($hex)
{
if (\is_array($hex))
{
$return = array();
foreach ($hex as $h)
{
$h = str_replace('#', '', $h);
list($r, $g, $b) = array_map('hexdec', str_split($h, 2));
$return[] = $r . ',' . $g . ',' . $b;
}
return $return;
}
$hex = str_replace('#', '', $hex);
list($r, $g, $b) = array_map('hexdec', str_split($hex, 2));
return $r . ',' . $g . ',' . $b;
}
}