Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rindula/cake-luminance
https://github.com/rindula/cake-luminance
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/rindula/cake-luminance
- Owner: Rindula
- Created: 2021-03-26T10:13:40.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-30T12:23:27.000Z (over 2 years ago)
- Last Synced: 2024-12-08T09:47:33.301Z (about 2 months ago)
- Language: PHP
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Luminance plugin for CakePHP
[![Release](https://github.com/Rindula/cake-luminance/actions/workflows/release.yml/badge.svg)](https://github.com/Rindula/cake-luminance/actions/workflows/release.yml)## Installation
You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).
The recommended way to install composer packages is:
```
composer require rindula/luminance
```## Setup
To activate the Plugin in CakePHP, you have to add the following to the end of `config/bootstrap.php`:
```php
Plugin::load('Luminance');
```### In a View
To use this Helper in a view, you have two options:
1. Add the Helper to one Controller only
add the following code to your controller:
```php
public $helpers = ['Luminance'];
```2. Add it globally to your AppView
Add the following to the initialize method of `src/View/AppView.php`:
```php
$this->loadHelper('Luminance.Luminance');
```### In a Controller
Add this to the initialize function of the Controller you need the Component in, below `parent::initialize()`:
```php
$this->loadComponent('Luminance.Luminance')
```## Usage
Once the respective setup is done you can use it like this:
### View and Controller
```php
$color = $this->Luminance->getContrastColor($hexColor);
```
`$color` then contains the hex color of the contrast color, which is either black (#000000) or white (#FFFFFF).