public static function CornersModifier::modification in Modifiers Pack 8
1 call to CornersModifier::modification()
- CornersModifierTest::testModification in modules/
modifiers_corners/ tests/ src/ Unit/ CornersModifierTest.php - @covers ::modification
File
- modules/
modifiers_corners/ src/ Plugin/ modifiers/ CornersModifier.php, line 22
Class
- CornersModifier
- Provides a Modifier to set the corners on an element.
Namespace
Drupal\modifiers_corners\Plugin\modifiersCode
public static function modification($selector, array $config) {
$media = parent::getMediaQuery($config);
if (!empty($config['corners_tl_size']) && !empty($config['corners_tl_units'])) {
$css[$media][$selector][] = 'border-top-left-radius:' . $config['corners_tl_size'] . $config['corners_tl_units'];
$css[$media][$selector . ':after'][] = 'border-top-left-radius:' . $config['corners_tl_size'] . $config['corners_tl_units'];
$css[$media][$selector . ':before'][] = 'border-top-left-radius:' . $config['corners_tl_size'] . $config['corners_tl_units'];
}
if (!empty($config['corners_tr_size']) && !empty($config['corners_tr_units'])) {
$css[$media][$selector][] = 'border-top-right-radius:' . $config['corners_tr_size'] . $config['corners_tr_units'];
$css[$media][$selector . ':after'][] = 'border-top-right-radius:' . $config['corners_tr_size'] . $config['corners_tr_units'];
$css[$media][$selector . ':before'][] = 'border-top-right-radius:' . $config['corners_tr_size'] . $config['corners_tr_units'];
}
if (!empty($config['corners_br_size']) && !empty($config['corners_br_units'])) {
$css[$media][$selector][] = 'border-bottom-right-radius:' . $config['corners_br_size'] . $config['corners_br_units'];
$css[$media][$selector . ':after'][] = 'border-bottom-right-radius:' . $config['corners_br_size'] . $config['corners_br_units'];
$css[$media][$selector . ':before'][] = 'border-bottom-right-radius:' . $config['corners_br_size'] . $config['corners_br_units'];
}
if (!empty($config['corners_bl_size']) && !empty($config['corners_bl_units'])) {
$css[$media][$selector][] = 'border-bottom-left-radius:' . $config['corners_bl_size'] . $config['corners_bl_units'];
$css[$media][$selector . ':after'][] = 'border-bottom-left-radius:' . $config['corners_bl_size'] . $config['corners_bl_units'];
$css[$media][$selector . ':before'][] = 'border-bottom-left-radius:' . $config['corners_bl_size'] . $config['corners_bl_units'];
}
if (!empty($css)) {
return new Modification($css);
}
return NULL;
}