-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance(block): Add inline style support to blocks (#145)
- Loading branch information
Showing
5 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Log1x\AcfComposer\Concerns; | ||
|
||
use Illuminate\Support\Str; | ||
|
||
trait FormatsCss | ||
{ | ||
/** | ||
* Format the given value into a CSS style. | ||
* | ||
* @param string $value | ||
* @param string $side | ||
* @param string $type | ||
* @return string | ||
*/ | ||
public function formatCss($value, $side, $type = 'padding'): string | ||
{ | ||
if (! Str::startsWith($value, 'var:preset|')) { | ||
return sprintf('%s-%s: %s;', $type, $side, $value); | ||
} | ||
|
||
$segments = explode('|', $value); | ||
|
||
array_shift($segments); | ||
|
||
return sprintf('%s-%s: var(--wp--preset--%s);', $type, $side, implode('--', $segments)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters