Skip to content

Commit f6b8c69

Browse files
committed
🐛 seperated elements library from main UI
1 parent 8cb6514 commit f6b8c69

File tree

2 files changed

+136
-82
lines changed

2 files changed

+136
-82
lines changed

src/UI.php

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Leaf;
44

5-
require __DIR__ . "/UI/Elements.php";
6-
75
/**
86
* Leaf UI
97
* ---------------------
@@ -17,6 +15,11 @@ class UI
1715
public const SINGLE_TAG = "single-tag";
1816
public const SELF_CLOSING = "self-closing";
1917

18+
public static function elements()
19+
{
20+
return require __DIR__ . "/UI/Elements.php";
21+
}
22+
2023
/**
2124
* Create an HTML element
2225
*
@@ -115,11 +118,11 @@ public static function createStyles(array $styles, array $props = [])
115118
if (is_array($value)) {
116119
if (strpos($key, "@") !== 0) {
117120
$parsed_styles .= "$key { ";
118-
121+
119122
foreach ($value as $selector => $styling) {
120123
$parsed_styles .= "$selector: $styling; ";
121124
}
122-
125+
123126
$parsed_styles .= "} ";
124127
} else {
125128
foreach ($value as $selector => $styling) {
@@ -232,38 +235,4 @@ public static function Vendor($file = null)
232235
{
233236
return "vendor\\leafs\\ui\\src\\UI\\$file";
234237
}
235-
236-
/**
237-
* Import/Use a styleheet
238-
*
239-
* @param string|array $src The styles/stylesheet to apply
240-
* @param array $props The attributes for style/link tag
241-
*/
242-
public static function Style($src, array $props = [])
243-
{
244-
if (!is_array($src)) {
245-
return self::createElement("link", ["href" => $src, "rel" => "stylesheet"], [], self::SINGLE_TAG);
246-
}
247-
248-
return self::createStyles($src, $props);
249-
}
250-
251-
/**
252-
* Import/Use a script
253-
*
254-
* @param string|array $src The internal/external scripts to apply
255-
* @param array $props The attributes for style/link tag
256-
*/
257-
public static function Script($src, array $props = [])
258-
{
259-
if (is_string($src)) {
260-
$props["src"] = $src;
261-
return self::createElement("script", $props);
262-
}
263-
264-
return self::createElement("script", array_merge(
265-
$props,
266-
["children" => $src]
267-
));
268-
}
269238
}

0 commit comments

Comments
 (0)