verbb / color-mixer

A set of Twig filters for modifying hex colors in Craft CMS.
MIT License
12 stars 4 forks source link

FR: Gradients #1

Closed richhayler closed 4 years ago

richhayler commented 5 years ago

Would be great to control to direction of the gradients - e.g. verticalUp and verticalDown (or vertical and verticalReverse), horizontalLeft and horizontalRight (or horizontal and horizontalReverse), radialIn and radialOut (or radial and radialReverse)...

... unless there is an alternative way to achieve this?

whoisjuan commented 5 years ago

I just ported the extension from the Craft 2 version, but after a little inspection, I think you can achieve what you want without adding new directions.

The gradient function actually takes a color param (it receives it as the pre-filter param)

public function gradient($color, $direction = 'horizontal', $amount = self::DEFAULT_ADJUST, $threshold = 130 ) 

So let's assume the following declaration: #FFFFFF|gradient(horizontal, #00000)

The theoretical horizontal reverse would be: #00000|gradient(horizontal, #FFFFFF)

Haven't tested but I think that would work.

whoisjuan commented 5 years ago

@richhayler I actually just tested this, and the approach explained above works as expected. You can check it here where I test the CSS generated by the first declaration and the second declaration from my previous comment: https://jsfiddle.net/bt074rm1/8/

richhayler commented 5 years ago

Awesome! Thank you @whoisjuan I really appreciate you testing this and providing me with a solution. Love this plugin and the functionality it provides to manipulate colours for CraftCMS.