GithubHelp home page GithubHelp logo

calendar font color about dashboard HOT 3 CLOSED

nextcloud avatar nextcloud commented on August 11, 2024
calendar font color

from dashboard.

Comments (3)

tuxedo-rb avatar tuxedo-rb commented on August 11, 2024

Hello julio1501,

I played a bit with the luminance calculation based on the luminance code snipped from
https://hacks.mozilla.org/2018/07/dark-theme-darkening-better-theming-for-firefox-quantum/
over the weekend.

Open following file in a text editor ./dashboard/lib/Controller/CalendarController.php
and replace the whole foreach loop code (line number 138 until line number 150) with following code:

		foreach ($calendars as $calendar) {
			// luminance threshold source: https://hacks.mozilla.org/2018/07/dark-theme-darkening-better-theming-for-firefox-quantum/
			$lum = 141.0000;
			$lumThreshold = 140.0000;
			$calBackgroundColor = $calendar['{http://apple.com/ns/ical/}calendar-color'];
			if(!isset($calBackgroundColor)) {
				$calBackgroundColor = '#3A87AD'; // standard background color of private events
			}
			// six digit hex notation?
			if (preg_match('/^[#]([0-9A-F]){6}$/i', $calBackgroundColor) === 1) {
				$rColorInt = hexdec(substr($calBackgroundColor, 1, 2));
				$gColorInt = hexdec(substr($calBackgroundColor, 3, 2));
				$bColorInt = hexdec(substr($calBackgroundColor, 5, 2));
				$lum = (0.2125 * $rColorInt) + (0.7154 * $gColorInt) + (0.0721 * $bColorInt);
			}
			$textColor = '#FFFFFF'; // white font color
			// $lum values over 140 will be classified as bright background color
			if ($lum > $lumThreshold) {
				$textColor = '#000000'; // black font color
			}
			$eventSources[] = [
				'url' => $this->urlGenerator->linkToRoute(
					'dashboard.calendar.get_events',
					['calendarid' => $calendar['id']]
				),
				'backgroundColor' => $calendar['{http://apple.com/ns/ical/}calendar-color'],
				'borderColor'     => '#888',
				'textColor'       => $textColor,
				'cache'           => true,
			];
		}

I increased the overall threshold value from 110 to 140.
Tune the overall value if it doesn't hit your taste, or experiment with the rgb multipier values.

from dashboard.

julio1501 avatar julio1501 commented on August 11, 2024

Hello @tuxedo-rb ,

thanks! It´s perfect

from dashboard.

ArtificialOwl avatar ArtificialOwl commented on August 11, 2024

fixed using tuxedo-rb's patch

from dashboard.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.