Merge pull request #11823 from lex111/fix-illegible-text-color-in-size-and-modified-columns
Fix illegible text color in columns Size and Modified on dark theme
This commit is contained in:
commit
6a979a0ba0
|
@ -28,3 +28,4 @@ $app = new \OCA\Accessibility\AppInfo\Application();
|
||||||
// 1. create the app
|
// 1. create the app
|
||||||
// 2. generate css route and inject
|
// 2. generate css route and inject
|
||||||
$app->injectCss();
|
$app->injectCss();
|
||||||
|
$app->injectJavascript();
|
|
@ -22,8 +22,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'routes' => [
|
'routes' => [
|
||||||
['name' => 'accessibility#getCss', 'url' => '/css/user-{md5}.css', 'verb' => 'GET'],
|
['name' => 'accessibility#getCss', 'url' => '/css/user-{md5}.css', 'verb' => 'GET'],
|
||||||
|
['name' => 'accessibility#getJavascript', 'url' => '/js/accessibility', 'verb' => 'GET'],
|
||||||
],
|
],
|
||||||
'ocs' => [
|
'ocs' => [
|
||||||
[
|
[
|
||||||
|
|
|
@ -60,4 +60,22 @@ class Application extends App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function injectJavascript() {
|
||||||
|
$linkToJs = $this->urlGenerator->linkToRoute(
|
||||||
|
$this->appName . '.accessibility.getJavascript',
|
||||||
|
[
|
||||||
|
'v' => \OC::$server->getConfig()->getAppValue('accessibility', 'cachebuster', '0'),
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
\OCP\Util::addHeader(
|
||||||
|
'script',
|
||||||
|
[
|
||||||
|
'src' => $linkToJs,
|
||||||
|
'nonce' => \OC::$server->getContentSecurityPolicyNonceManager()->getNonce()
|
||||||
|
],
|
||||||
|
''
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ use Leafo\ScssPhp\Formatter\Crunched;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataDisplayResponse;
|
use OCP\AppFramework\Http\DataDisplayResponse;
|
||||||
|
use OCP\AppFramework\Http\DataDownloadResponse;
|
||||||
use OCP\AppFramework\Utility\ITimeFactory;
|
use OCP\AppFramework\Utility\ITimeFactory;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\IConfig;
|
use OCP\IConfig;
|
||||||
|
@ -184,6 +185,24 @@ class AccessibilityController extends Controller {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @NoCSRFRequired
|
||||||
|
* @PublicPage
|
||||||
|
*
|
||||||
|
* @return DataDownloadResponse
|
||||||
|
*/
|
||||||
|
public function getJavascript(): DataDownloadResponse {
|
||||||
|
$responseJS = '(function() {
|
||||||
|
OCA.Accessibility = {
|
||||||
|
theme: ' . json_encode($this->config->getUserValue($this->userSession->getUser()->getUID(), $this->appName, 'theme', false)) . ',
|
||||||
|
|
||||||
|
};
|
||||||
|
})();';
|
||||||
|
$response = new DataDownloadResponse($responseJS, 'javascript', 'text/javascript');
|
||||||
|
$response->cacheFor(3600);
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an array with the user theme & font settings
|
* Return an array with the user theme & font settings
|
||||||
*
|
*
|
||||||
|
|
|
@ -1384,6 +1384,10 @@
|
||||||
// rgb(118, 118, 118) / #767676
|
// rgb(118, 118, 118) / #767676
|
||||||
// min. color contrast for normal text on white background according to WCAG AA
|
// min. color contrast for normal text on white background according to WCAG AA
|
||||||
sizeColor = Math.round(118-Math.pow((fileData.size/(1024*1024)),2));
|
sizeColor = Math.round(118-Math.pow((fileData.size/(1024*1024)),2));
|
||||||
|
|
||||||
|
if (OCA.Accessibility && OCA.Accessibility.theme === 'themedark') {
|
||||||
|
sizeColor = Math.abs(sizeColor);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
simpleSize = t('files', 'Pending');
|
simpleSize = t('files', 'Pending');
|
||||||
}
|
}
|
||||||
|
@ -1403,6 +1407,16 @@
|
||||||
if (modifiedColor >= '118') {
|
if (modifiedColor >= '118') {
|
||||||
modifiedColor = 118;
|
modifiedColor = 118;
|
||||||
}
|
}
|
||||||
|
if (OCA.Accessibility && OCA.Accessibility.theme === 'themedark') {
|
||||||
|
modifiedColor = Math.abs(modifiedColor);
|
||||||
|
|
||||||
|
// ensure that the dimmest color is still readable
|
||||||
|
// rgb(130, 130, 130) / #828282
|
||||||
|
// min. color contrast for normal text on black background according to WCAG AA
|
||||||
|
if (modifiedColor < 130) {
|
||||||
|
modifiedColor = 130;
|
||||||
|
}
|
||||||
|
}
|
||||||
var formatted;
|
var formatted;
|
||||||
var text;
|
var text;
|
||||||
if (mtime > 0) {
|
if (mtime > 0) {
|
||||||
|
|
Loading…
Reference in New Issue