| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* @copyright © Melograno Venture Studio. All rights reserved. |
| 5 |
* @licence See LICENCE.md for license details. |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace IvyForms\Services\Form\Style; |
| 9 |
|
| 10 |
// phpcs:disable PSR1.Files.SideEffects |
| 11 |
|
| 12 |
if (!defined('ABSPATH')) { |
| 13 |
exit; // Exit if accessed directly |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* Class FieldStyleGenerator |
| 18 |
* |
| 19 |
* Generates CSS for form fields |
| 20 |
* |
| 21 |
* @package IvyForms\Services\Form\StyleHelpers |
| 22 |
*/ |
| 23 |
class FieldStyleGenerator implements StyleGeneratorInterface |
| 24 |
{ |
| 25 |
/** |
| 26 |
* Generate field styles |
| 27 |
* |
| 28 |
* @param CssBuilder $css |
| 29 |
* @param StyleContext $context |
| 30 |
* @return void |
| 31 |
*/ |
| 32 |
public function generate(CssBuilder $css, StyleContext $context): void |
| 33 |
{ |
| 34 |
$baseStylesApplier = new FieldBaseStylesApplier(); |
| 35 |
$stateStylesApplier = new FieldStateStylesApplier(); |
| 36 |
|
| 37 |
$baseStylesApplier->apply( |
| 38 |
$css, |
| 39 |
$context->getBaseSelector(), |
| 40 |
$context->getActiveColors(), |
| 41 |
$context->getActiveStyles() |
| 42 |
); |
| 43 |
|
| 44 |
$stateStylesApplier->apply( |
| 45 |
$css, |
| 46 |
$context->getBaseSelector(), |
| 47 |
$context->getStyleSettings() |
| 48 |
); |
| 49 |
} |
| 50 |
} |
| 51 |
|