vaersaagod / colormate
Color me impressed, mate!
Installs: 479
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 5
Forks: 1
Open Issues: 4
Type:craft-plugin
Requires
- php: ^8.2
- craftcms/cms: ^5.3.0
- ssnepenthe/color-utils: ~0.4
- dev-master
- 3.0.1
- 3.0.0
- 3.0.0-beta.2
- 3.0.0-beta.1
- v2.x-dev
- 2.3.1
- 2.3.0
- 2.2.3.1
- 2.2.3
- 2.2.1.2
- 2.2.1.1
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.0
- v1.x-dev
- 1.1.1.2
- 1.1.1.1
- 1.1.1
- 1.1.0
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1.1
- 1.0.1
- 1.0.0
- dev-dependabot/npm_and_yarn/src/assetbundles/cross-spawn-6.0.6
- dev-dependabot/npm_and_yarn/src/assetbundles/elliptic-6.6.0
- dev-dependabot/npm_and_yarn/src/assetbundles/vue-3.0.0
- dev-dev/craft5
This package is auto-updated.
Last update: 2024-12-20 17:07:24 UTC
README
Color me impressed, mate!
Requirements
This plugin requires Craft CMS 5.0.0 or later.
Installation
To install the plugin, either install it from the plugin store, or follow these instructions:
- Install with composer via
composer require vaersaagod/colormate
from your project directory. - Install the plugin in the Craft Control Panel under Settings → Plugins, or from the command line via
./craft install/plugin colormate
.
Configuring
ToolMate is configured by creating a file named colormate.php
in your Craft config folder,
and configuring as needed. Sample config:
<?php
return [
'*' => [
'presets' => [
'ctaColors' => [
'name' => 'CTA Colors',
'showCustom' => true,
'showOpacity' => true,
'showClear' => false,
'showTooltip' => true,
'colors' => [
'blush' => [
'name' => 'Blush',
'color' => '#eea8bf'
],
'mustard' => [
'name' => 'Mustard',
'color' => '#ead30a'
],
'baby' => [
'name' => 'Baby',
'color' => '#67cdfc'
],
'transred' => [
'name' => 'Lorem',
'color' => 'rgba(255, 0, 0, 0.4)'
],
],
'default' => 'blush'
],
'overlayColors' => [
'name' => 'Overlay Colors',
'showCustom' => false,
'showOpacity' => false,
'showClear' => true,
'colors' => [
'black-10p' => [
'name' => '10% black',
'color' => 'rgba(0, 0, 0, 0.1)',
],
'black-20p' => [
'name' => '20% black',
'color' => 'rgba(0, 0, 0, 0.2)',
],
'black-30p' => [
'name' => '30% black',
'color' => 'rgba(0, 0, 0, 0.3)',
]
]
]
]
]
];
Field type
The field type returns a Color model with the following properties and methods:
handle
Handle of preset color if the chosen color was from a preset.
custom
Custom color value.
opacity
Opacity value.
name
Name of preset color if the chosen color was from a preset.
baseColor
The calculated base color, either the custom one, or the color value from the selected preset color.
preset
The preset that was used for the field.
getColor([format = 'rgb'])
Returns the resulting color, either a custom color value or from a preset, with opacity factored into it.
isCustom()
Is the color a custom one?
hasTransparency()
Does the resulting color have transparency?
Template variables / Service methods
All the following methods are available both as template variables, using
craft.colormate.<method>(<args>)
, and as service methods, using
ColorMate::$plugin->color-><method>(<args>)
.
Most methods are wrappers for [ssnepenthe/color-utils](https://github.com/ssnepenthe/color-utils)
,
refer to it for additional documentation.
getColor(color)
adjustColor(color, adjustment)
getBrightness(color)
getHue(color)
getLightness(color)
isBright(color[, threshold = 127.5])
isLight(color[, threshold = 50])
looksBright(color[, threshold = 127.5])
getPercievedBrightness(color)
getRelativeLuminance(color)
getSaturation(color)
getBrightnessDifference(color1, color2)
getColorDifference(color1, color2)
getContrastRatio(color1, color2)
rgb2hex(color)
hex2rgb(hexValue)
Price, license and support
The plugin is released under the MIT license. It's made for Værsågod and friends, and no support is given. Submitted issues are resolved if it scratches an itch.
Changelog
See CHANGELOG.MD.
Credits
Brought to you by Værsågod
Icon designed by Freepik from Flaticon.