venca-x/latte-contrast-yiq

Plugin for Nette. Default usage is for Latte templates. From RGB color return contrast color black/white

dev-master 2018-01-05 11:15 UTC

This package is auto-updated.

Last update: 2024-11-07 05:29:02 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Plugin for Nette. Default usage is for Latte templates. From RGB color return contrast color black/white. Typical set contrast text color for dynamic color background.

Installation

  1. Add the bundle to your dependencies:

Install with composer:

	composer require venca-x/latte-contrast-yiq:~0.2
	
	
// composer.json

    {
       // ...
       "require": {
           // ...
		   "venca-x/latte-contrast-yiq": "@dev",
       }
    }
  1. Use Composer to download and install the bundle:

    composer update
    

Configuration

BasePresenter.php

protected function beforeRender()
{
    parent::beforeRender();

    $this->template->addFilter('contrastYIQ', function ($text) {
        $contrastYIQ = new \ContrastYIQ();
        return $contrastYIQ->getContrastYIQ($text);
    });
}

Usage

{$o->color|contrastYIQ}