class CustomRadialGradientModifier in Modifiers Pack 8
Provides a Modifier to set the radial gradient on an element.
Plugin annotation
@Modifier(
id = "custom_radial_gradient_modifier",
label = @Translation("Custom Radial Gradient Modifier"),
description = @Translation("Provides a Modifier to set the radial gradient on an element using custom colors."),
)
Hierarchy
- class \Drupal\modifiers_custom_radial_gradient\Plugin\modifiers\CustomRadialGradientModifier extends \Drupal\modifiers\ModifierPluginBase
Expanded class hierarchy of CustomRadialGradientModifier
1 file declares its use of CustomRadialGradientModifier
- CustomRadialGradientModifierTest.php in modules/
modifiers_custom_radial_gradient/ tests/ src/ Unit/ CustomRadialGradientModifierTest.php
1 string reference to 'CustomRadialGradientModifier'
- CustomRadialGradientModifier::modification in modules/
modifiers_custom_radial_gradient/ src/ Plugin/ modifiers/ CustomRadialGradientModifier.php
File
- modules/
modifiers_custom_radial_gradient/ src/ Plugin/ modifiers/ CustomRadialGradientModifier.php, line 17
Namespace
Drupal\modifiers_custom_radial_gradient\Plugin\modifiersView source
class CustomRadialGradientModifier extends ModifierPluginBase {
/**
* {@inheritdoc}
*/
public static function modification($selector, array $config) {
if (!empty($config['cr_gradient_colors'])) {
$media = parent::getMediaQuery($config);
$args['colors'] = $config['cr_gradient_colors'];
$args['shape'] = 'ellipse';
$args['size'] = 'farthest-corner';
$args['x'] = 50;
$args['y'] = 50;
if (!empty($config['cr_gradient_shape'])) {
$args['shape'] = $config['cr_gradient_shape'];
}
if (!empty($config['cr_gradient_size'])) {
$args['size'] = $config['cr_gradient_size'];
}
if (!empty($config['cr_gradient_position'][0])) {
$args['x'] = (double) $config['cr_gradient_position'][0];
}
if (!empty($config['cr_gradient_position'][1])) {
$args['y'] = (double) $config['cr_gradient_position'][1];
}
$libraries = [
'modifiers_custom_radial_gradient/apply',
];
$settings = [
'namespace' => 'CustomRadialGradientModifier',
'callback' => 'apply',
'selector' => $selector,
'media' => $media,
'args' => $args,
];
$attributes[$media][$selector]['class'][] = 'modifiers-has-background';
return new Modification([], $libraries, $settings, $attributes);
}
return NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CustomRadialGradientModifier:: |
public static | function |