ucraft-com / css-generator
Converts Ucraft variantsStyles into css.
Installs: 1 615
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 1
Requires
- php: >=8.0
Requires (Dev)
- phpunit/phpunit: ^9.5.10
- dev-master
- v1.4.1
- v1.4.0
- v1.3.6
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.16
- v1.0.15
- v1.0.14
- v1.0.13
- v1.0.12
- v1.0.11
- v1.0.10
- v1.0.9
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-refactor
- dev-css-logs
This package is auto-updated.
Last update: 2024-05-22 06:32:22 UTC
README
Introduction
Welcome to the Css Generator! This library helps to generate css string from varaints styles.
Installation
Install the Css Generator using Composer:
composer require ucraft-com/css-generator
StyleCollector
The StyleCollector
is used for collecting all the data that is needed for generating css.
Usage Example
use CssGenerator\StyleCollector\StyleCollector; $styleCollector = new StyleCollector(); $styleCollector ->assignMedia($media, fn (string $filename = null) => storage_url(media_image_path($filename))) ->assignBreakpoints($breakpoints) ->assignVariantsStyles($styleData) //->assignColorMediaQuery('@media (prefers-color-scheme: dark) {') ->build(); // or ->buildWithoutBreakpoint(); which is internal /* will be called automatically when assignBreakpoints($breakpoints) is not called, variants styles data shape in that case is like this $staticGlobalStyles = [ [ 'selector' => 'html', 'styles' => [ 'height' => 'auto', ], ], ] assignMedia - the media that will be used for generating background, and resolver, for resolving media path. assignBreakpoints - all breakpoints sorted by width. assignVariantsStyles - all style data, grouped by selector. ex: loop variants styles and collect - $styleData[$selector][] = $style; assignColorMediaQuery - generate styles for dark or light mode. build - convert data to coresponding data structures. buildWithoutBreakpoint - convert data to coresponding data structures without any breakpoints. */
CssGenerator
use CssGenerator\CssGenerator; $cssGenerator = new CssGenerator($styleCollector); // previously described style collector $cssGenerator->generate(); // generates all css as string based on collected styles.
License
The Css Generator is open-source software licensed under the MIT License.