summaryrefslogtreecommitdiff
path: root/plugins/Customizer/vendor/luizbills
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Customizer/vendor/luizbills')
-rw-r--r--plugins/Customizer/vendor/luizbills/css-generator/.gitignore2
-rw-r--r--plugins/Customizer/vendor/luizbills/css-generator/LICENSE21
-rw-r--r--plugins/Customizer/vendor/luizbills/css-generator/README.md102
-rw-r--r--plugins/Customizer/vendor/luizbills/css-generator/composer.json21
-rw-r--r--plugins/Customizer/vendor/luizbills/css-generator/demo/demo.php41
-rw-r--r--plugins/Customizer/vendor/luizbills/css-generator/src/Generator.php102
6 files changed, 289 insertions, 0 deletions
diff --git a/plugins/Customizer/vendor/luizbills/css-generator/.gitignore b/plugins/Customizer/vendor/luizbills/css-generator/.gitignore
new file mode 100644
index 00000000..55940e57
--- /dev/null
+++ b/plugins/Customizer/vendor/luizbills/css-generator/.gitignore
@@ -0,0 +1,2 @@
+/vendor/
+composer.lock \ No newline at end of file
diff --git a/plugins/Customizer/vendor/luizbills/css-generator/LICENSE b/plugins/Customizer/vendor/luizbills/css-generator/LICENSE
new file mode 100644
index 00000000..7f9fca91
--- /dev/null
+++ b/plugins/Customizer/vendor/luizbills/css-generator/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2018 Luiz Bills
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/plugins/Customizer/vendor/luizbills/css-generator/README.md b/plugins/Customizer/vendor/luizbills/css-generator/README.md
new file mode 100644
index 00000000..28dee232
--- /dev/null
+++ b/plugins/Customizer/vendor/luizbills/css-generator/README.md
@@ -0,0 +1,102 @@
+# CSS Generator
+
+Write CSS programatically using PHP.
+
+## Install
+
+```php
+composer require luizbills/css-generator
+```
+
+## Usage
+
+```php
+use luizbills\CSS_Generator\Generator as CSS_Generator;
+
+$options = [
+ // default values
+ // 'indentation' => ' ', // 4 spaces
+];
+$css = new CSS_Generator( $options );
+
+// single selector
+$css->add_rule( '.color-white', [ 'color' => '#fff' ] );
+
+$css->open_block( 'media', 'screen and (min-width: 30em)' );
+
+// multiple selectors
+$css->add_rule( [ 'html', 'body' ], [
+ 'background-color' => 'black',
+ 'color' => 'white'
+] );
+
+$css->close_block(); // close a block
+
+$css->open_block( 'supports', '(display: grid)' );
+
+$css->add_rule( '.grid', [
+ 'display' => 'grid',
+] );
+
+// nested block
+$css->open_block( 'media', 'screen and (max-width: 30em)' );
+
+$css->add_rule( '.grid-sm', [
+ 'display' => 'grid',
+] );
+
+$css->close_blocks(); // close all blocks
+
+$minify = false;
+echo $css->get_output( $minify );
+```
+
+output:
+```css
+.color-white {
+ color: #fff;
+}
+@media screen and (min-width: 30em) {
+ html,
+ body {
+ background-color: black;
+ color: white;
+ }
+}
+@supports (display: grid) {
+ .grid {
+ display: grid;
+ }
+ @media screen and (max-width: 30em) {
+ .grid-sm {
+ display: grid;
+ }
+ }
+}
+```
+
+Changing `$minify` to `true` will outputs:
+```css
+.color-white{color:#fff}@media screen and (min-width:30em){body,html{background-color:#000;color:#fff}}@supports (display:grid){.grid{display:grid}@media screen and (max-width:30em){.grid-sm{display:grid}}}
+```
+
+There is also a method `add_raw` that adds any string to your css. Useful to comments or include a framework.
+```php
+$css = new CSS_Generator();
+
+$css->add_rule( '.color-white', [ 'color' => '#fff' ] );
+$css->add_raw('/* my comment */ a { text-decoration: none }');
+
+echo $css->get_output();
+```
+
+output:
+```css
+.color-white{
+ color:#fff;
+}
+/* my comment */ a { text-decoration: none }
+```
+
+## License
+MIT License © 2018 Luiz Bills
diff --git a/plugins/Customizer/vendor/luizbills/css-generator/composer.json b/plugins/Customizer/vendor/luizbills/css-generator/composer.json
new file mode 100644
index 00000000..c6e9417c
--- /dev/null
+++ b/plugins/Customizer/vendor/luizbills/css-generator/composer.json
@@ -0,0 +1,21 @@
+{
+ "name": "luizbills/css-generator",
+ "description": "Write CSS programatically using PHP.",
+ "type": "package",
+ "require": {
+ "php": ">=5.4.0",
+ "matthiasmullie/minify": "^1.3"
+ },
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Luiz Bills",
+ "email": "luizpbills@gmail.com"
+ }
+ ],
+ "autoload": {
+ "psr-4": {
+ "luizbills\\CSS_Generator\\": "src"
+ }
+ }
+}
diff --git a/plugins/Customizer/vendor/luizbills/css-generator/demo/demo.php b/plugins/Customizer/vendor/luizbills/css-generator/demo/demo.php
new file mode 100644
index 00000000..69e6a4a1
--- /dev/null
+++ b/plugins/Customizer/vendor/luizbills/css-generator/demo/demo.php
@@ -0,0 +1,41 @@
+<?php
+
+require_once __DIR__ . '/../vendor/autoload.php';
+
+use luizbills\CSS_Generator\Generator as CSS_Generator;
+
+$options = [
+ 'indentation' => ' ', // 2 spaces
+];
+$css = new CSS_Generator( $options );
+
+// single selector
+$css->add_rule( '.color-white', [ 'color' => '#fff' ] );
+
+$css->open_block( 'media', 'screen and (min-width: 30em)' );
+
+// multiple selectors
+$css->add_rule( [ 'html', 'body' ], [
+ 'background-color' => 'black',
+ 'color' => 'white'
+] );
+
+$css->close_block(); // close a block
+
+$css->open_block( 'supports', '(display: grid)' );
+
+$css->add_rule( '.grid', [
+ 'display' => 'grid',
+] );
+
+// nested block
+$css->open_block( 'media', 'screen and (max-width: 30em)' );
+
+$css->add_rule( '.grid-sm', [
+ 'display' => 'grid',
+] );
+
+$css->close_blocks(); // close all blocks
+
+$minify = false;
+echo $css->get_output( $minify ); \ No newline at end of file
diff --git a/plugins/Customizer/vendor/luizbills/css-generator/src/Generator.php b/plugins/Customizer/vendor/luizbills/css-generator/src/Generator.php
new file mode 100644
index 00000000..6ef80f00
--- /dev/null
+++ b/plugins/Customizer/vendor/luizbills/css-generator/src/Generator.php
@@ -0,0 +1,102 @@
+<?php
+/**
+ * CSS Generator
+ * Write css programatically using PHP.
+ *
+ * @author Luiz Bills <luizpbills@gmail.comm>
+ * @copyright 2018 Luiz Bills
+ * @license MIT
+*/
+namespace luizbills\CSS_Generator;
+
+use MatthiasMullie\Minify;
+
+class Generator {
+ const VERSION = '3.1.0';
+
+ protected $raw = '';
+ protected $block_level = 0;
+ protected $linebreak = "\n";
+ protected $minified = null; // for cache
+ protected $options = null;
+ protected $default_options = [
+ 'indentation' => ' ', // 4 spaces
+ ];
+
+ public function __construct ( $options = [] ) {
+ $this->options = array_merge( $this->default_options, $options );
+ }
+
+ public function get_output ( $compress = false ) {
+ $this->close_blocks();
+ if ( $compress ) {
+ return $this->minify();
+ }
+ return $this->raw;
+ }
+
+ protected function minify () {
+ if ( ! is_null( $this->minified ) ) {
+ return $this->minified;
+ }
+
+ $minifier = new Minify\CSS( $this->raw );
+ $this->minified = $minifier->minify();
+ return $this->minified;
+ }
+
+ public function add_raw ( $string ) {
+ $this->raw .= $string;
+ $this->clear_cache();
+ }
+
+ public function add_rule ( $selectors, $declarations_array ) {
+ $declarations = [];
+ $selector_indentation = str_repeat( $this->options['indentation'], $this->block_level );
+ $declaration_indentation = str_repeat( $this->options['indentation'], $this->block_level + 1 );
+
+ if ( ! is_array( $selectors ) ) {
+ $selectors = [ $selectors ];
+ }
+
+ foreach ( $selectors as $key => $value ) {
+ $selectors[ $key ] = $selector_indentation . trim( $value );
+ }
+
+ foreach ( $declarations_array as $key => $value ) {
+ $declarations[] = $declaration_indentation . trim( $key ) . ': ' . trim( $value ) . ';' . $this->linebreak;
+ }
+
+ $this->raw .= implode( ',' . $this->linebreak, $selectors ) . ' {';
+ $this->raw .= $this->linebreak . implode( '', $declarations );
+ $this->raw .= $selector_indentation . '}' . $this->linebreak;
+
+ $this->clear_cache();
+ }
+
+ public function open_block ( $type, $props = '' ) {
+ $block_indentation = str_repeat( $this->options['indentation'], $this->block_level );
+ $this->raw .= $block_indentation . '@' . $type . ' ' . trim( $props ) . ' {' . $this->linebreak;
+ $this->block_level++;
+ $this->clear_cache();
+ }
+
+ public function close_block () {
+ if ( $this->block_level > 0 ) {
+ $this->block_level--;
+ $block_indentation = str_repeat( $this->options['indentation'], $this->block_level );
+ $this->raw .= $block_indentation . '}' . $this->linebreak;
+ $this->clear_cache();
+ }
+ }
+
+ public function close_blocks () {
+ while ( $this->block_level > 0 ) {
+ $this->close_block();
+ }
+ }
+
+ protected function clear_cache() {
+ $this->minified = null;
+ }
+}