czproject / css-tools
CSS tools for PHP
Fund package maintenance!
Other
dev-master
2024-05-30 05:35 UTC
Requires
- php: 7.4 - 8.3
Requires (Dev)
- nette/tester: ^2.4
This package is auto-updated.
Last update: 2024-10-30 06:29:38 UTC
README
CSS tools for PHP.
Installation
Download a latest package or use Composer:
composer require czproject/css-tools
CzProject\CssTools requires PHP 7.4 or later.
Usage
CSS compiler
Expands @import
rules in file.
$compiler = new CzProject\CssTools\CssCompiler; $compiler->compileFile(__DIR__ . '/styles.css'); // overwrite styles.css with compiled version $compiledStyles = $compiler->processFile(__DIR__ . '/styles2.css'); $compiledStyles = $compiler->processContent( '@import "mystyles.css";', $stylesheetsRootDirectory );
CSS generator
$file = new CzProject\CssTools\CssFile; $file->addRule('.button', [ 'color' => CssTools\Color::hex('#F8A'), 'font-size' => CssTools\Number::px2rem(48), 'background-color' => NULL, ]); echo $file->render();
CSS minifier
$minifier = new CzProject\CssTools\CssMinifier; $result = $minifier->minify("body { color: #333; background: #fff; }"); var_dump($result); // Output: body{color:#333;background:#fff}
License: New BSD License
Author: Jan Pecha, https://www.janpecha.cz/