-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa3451b
commit c72905f
Showing
4 changed files
with
85 additions
and
8 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 |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
namespace Hyde\Framework\Concerns\Internal; | ||
|
||
use function config; | ||
use Hyde\Framework\Services\AssetService; | ||
|
||
/** | ||
* AssetManager for the Hyde Facade. | ||
|
@@ -14,24 +14,22 @@ trait AssetManager | |
*/ | ||
public static function tailwind(): string|false | ||
{ | ||
return config('hyde.loadTailwindFromCDN') | ||
? 'https://cdn.jsdelivr.net/gh/hydephp/[email protected]/dist/app.css' | ||
: false; | ||
return (new AssetService)->tailwindPath(); | ||
} | ||
|
||
/** | ||
* Return the Hyde stylesheet. | ||
*/ | ||
public static function styles(): string | ||
{ | ||
return 'https://cdn.jsdelivr.net/gh/hydephp/[email protected]/dist/hyde.css'; | ||
return (new AssetService)->stylePath(); | ||
} | ||
|
||
/** | ||
* Return the Hyde scripts. | ||
*/ | ||
public static function scripts(): string | ||
{ | ||
return 'https://cdn.jsdelivr.net/gh/hydephp/[email protected]/dist/hyde.js'; | ||
return (new AssetService)->scriptPath(); | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Contracts; | ||
|
||
interface AssetServiceContract | ||
{ | ||
/** | ||
* The HydeFront version to load. | ||
*/ | ||
public function version(): string; | ||
|
||
/** | ||
* Return the Tailwind CDN if enabled in the config, else false. | ||
*/ | ||
public function tailwindPath(): string|false; | ||
|
||
|
||
/** | ||
* Return the main Hyde stylesheet location/path. | ||
*/ | ||
public function stylePath(): string; | ||
|
||
|
||
/** | ||
* Return the main Hyde script location/path. | ||
*/ | ||
public function scriptPath(): string; | ||
|
||
/** | ||
* Construct a URI path for the CDN using the static dist version. | ||
*/ | ||
public function cdnPathConstructor(string $file): string; | ||
} |
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,41 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Services; | ||
|
||
use Hyde\Framework\Contracts\AssetServiceContract; | ||
|
||
class AssetService implements AssetServiceContract | ||
{ | ||
/** | ||
* The HydeFront version to load. | ||
* @property string $version | ||
*/ | ||
public string $version = 'v1.3.1'; | ||
|
||
public function version(): string | ||
{ | ||
return config('hyde.cdnHydeFrontVersionOverride', $this->version); | ||
} | ||
|
||
public function tailwindPath(): string|false | ||
{ | ||
return config('hyde.loadTailwindFromCDN', false) | ||
? $this->cdnPathConstructor('app.css') | ||
: false; | ||
} | ||
|
||
public function stylePath(): string | ||
{ | ||
return $this->cdnPathConstructor('hyde.css'); | ||
} | ||
|
||
public function scriptPath(): string | ||
{ | ||
return $this->cdnPathConstructor('hyde.js'); | ||
} | ||
|
||
public function cdnPathConstructor(string $file): string | ||
{ | ||
return 'https://cdn.jsdelivr.net/gh/hydephp/hydefront@' . $this->version() . '/dist/' . $file; | ||
} | ||
} |