Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
izica committed Oct 12, 2018
1 parent 9abbc81 commit c416ef5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 18 additions & 3 deletions PhpStyles.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class PhpStyles
* @var string
*/
public $styles = [];
private $classname = '';
private $classname = null;
private $media = false;
private $mediaFrom = '';
private $mediaTo = '';
Expand All @@ -30,7 +30,9 @@ public function render($condition = true)
if (!$condition) {
return '';
}
$this->classname = uniqid('php-styles-');
if(!is_string($this->classname)){
$this->classname = uniqid('php-styles-');
}

$array = [];
foreach ($this->styles as $key => $value) {
Expand All @@ -49,7 +51,10 @@ public function render($condition = true)
}
echo "</style>";

return $this->classname;
$classname = $this->classname;
$this->classname = null;

return $classname;
}

/**
Expand Down Expand Up @@ -86,4 +91,14 @@ public function opacity($value, $condition)
{
return $this->set('opacity', $value, $condition);
}

/**
* @param $value
* @param $condition
* @return $this
*/
public function name($value)
{
return $this->set('opacity', $value, $condition);
}
}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ generate style with class(class styles supports media query)
$sClassname = styles()->media(0, 1024)->opacity(0, $sContact == '')->render();
or
$sClassname = styles()
->name('contact-images')
->media(0, 1024)
->set('display', 'flex'),
->set('align-items', 'center', $itemsCount > 4),
Expand All @@ -51,6 +52,7 @@ insert style
* set(key: string, value: string or number, condition: bool(not required)) - returns $this(if condition == false, not set)
* render(condition: bool(not required))- returns unique class name(if condition == false, returns empty string)
* opacity(value, condition(not required))
* name(className: string)
* PhpStylesInline
* set(key: string, value: string or number, condition: bool(not required)) - returns $this(if condition == false, not set)
* render(condition: bool(not required))- returns unique class name(if condition == false, returns empty string)
Expand Down

0 comments on commit c416ef5

Please sign in to comment.