Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.2] atum light mode - Fix modal window link color #44176

Merged
merged 14 commits into from
Nov 7, 2024
27 changes: 24 additions & 3 deletions administrator/templates/atum/component.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

// phpcs:disable PSR1.Files.SideEffects
defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
RickR2H marked this conversation as resolved.
Show resolved Hide resolved

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
Expand All @@ -26,6 +28,20 @@

$linkColorDark = $this->params->get('link-color-dark', '#6fbfdb');
list($rd, $gd, $bd) = sscanf($linkColorDark, "#%02x%02x%02x");
list($lighterRd, $lighterGd, $lighterBd) = adjustColorLightness($rd, $gd, $bd, 10);

// phpcs:disable PSR1.Files.SideEffects
RickR2H marked this conversation as resolved.
Show resolved Hide resolved
function adjustColorLightness($r, $g, $b, $percent)
{
$adjust = function ($color) use ($percent) {
$newColor = $color + ($color * $percent / 100);
return min(max(0, $newColor), 255);
};
return [$adjust($r), $adjust($g), $adjust($b)];
}
// phpcs:enable PSR1.Files.SideEffects

RickR2H marked this conversation as resolved.
Show resolved Hide resolved
$linkColorDarkHvr = sprintf("%d, %d, %d", $lighterRd, $lighterGd, $lighterBd);
richard67 marked this conversation as resolved.
Show resolved Hide resolved

// Enable assets
$wa->usePreset('template.atum.' . ($this->direction === 'rtl' ? 'rtl' : 'ltr'))
Expand All @@ -40,10 +56,12 @@
--link-color-rgb: ' . $r . ',' . $g . ',' . $b . ';
--template-special-color: ' . $this->params->get('special-color', 'var(--template-special-color)') . ';
}')
->addInlineStyle('@media (prefers-color-scheme: dark) { :root {
->addInlineStyle(':root[data-color-scheme="dark"] {
--link-color: ' . $linkColorDark . ';
--link-color-rgb: ' . $rd . ',' . $gd . ',' . $bd . ';
}}');
--link-color-rgb-hvr: ' . $linkColorDarkHvr . ';
--template-special-color: #6fbfdb;
}');

// No template.js for modals
$wa->disableScript('template.atum');
Expand Down Expand Up @@ -75,14 +93,17 @@
?>

<!DOCTYPE html>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>"<?php echo $themeModeAttr; ?>>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>" <?php echo $themeModeAttr; ?>>

<head>
<jdoc:include type="metas" />
<jdoc:include type="styles" />
<jdoc:include type="scripts" />
</head>

<body class="contentpane component">
<jdoc:include type="message" />
<jdoc:include type="component" />
</body>

</html>