Skip to content

Commit

Permalink
Update Horizon.php
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 2, 2024
1 parent 253c67a commit 2681f62
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions src/Horizon.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,53 @@ public static function use($connection)
config(['database.redis.horizon' => $config]);
}

/**
* Get the CSS for the Horizon dashboard.
*
* @return Illuminate\Contracts\Support\Htmlable
*/
public static function css()
{
if (($light = @file_get_contents(__DIR__.'/../dist/styles.css')) === false) {
throw new RuntimeException('Unable to load the Horizon dashboard light CSS.');
}

if (($dark = @file_get_contents(__DIR__.'/../dist/styles-dark.css')) === false) {
throw new RuntimeException('Unable to load the Horizon dashboard dark CSS.');
}

if (($app = @file_get_contents(__DIR__.'/../dist/app.css')) === false) {
throw new RuntimeException('Unable to load the Horizon dashboard CSS.');
}

return new HtmlString(<<<HTML
<style data-scheme="light">{$light}</style>
<style data-scheme="dark">{$dark}</style>
<style>{$app}</style>
HTML);
}

/**
* Get the JS for the Horizon dashboard.
*
* @return \Illuminate\Contracts\Support\Htmlable
*/
public static function js()
{
if (($js = @file_get_contents(__DIR__.'/../dist/app.js')) === false) {
throw new RuntimeException('Unable to load the Horizon dashboard JavaScript.');
}

$horizon = Js::from(static::scriptVariables());

return new HtmlString(<<<HTML
<script type="module">
window.Horizon = {$horizon};
{$js}
</script>
HTML);
}

/**
* Specifies that Horizon should use the dark theme.
*
Expand Down Expand Up @@ -178,51 +225,4 @@ public static function routeSmsNotificationsTo($number)

return new static;
}

/**
* The CSS for the Horizon dashboard.
*
* @return Htmlable
*/
public static function css()
{
if (($light = @file_get_contents(__DIR__.'/../dist/styles.css')) === false) {
throw new RuntimeException('Unable to load the Horizon dashboard light CSS.');
}

if (($dark = @file_get_contents(__DIR__.'/../dist/styles-dark.css')) === false) {
throw new RuntimeException('Unable to load the Horizon dashboard dark CSS.');
}

if (($app = @file_get_contents(__DIR__.'/../dist/app.css')) === false) {
throw new RuntimeException('Unable to load the Horizon dashboard CSS.');
}

return new HtmlString(<<<HTML
<style data-scheme="light">{$light}</style>
<style data-scheme="dark">{$dark}</style>
<style>{$app}</style>
HTML);
}

/**
* The JS for the Horizon dashboard.
*
* @return Htmlable
*/
public static function js()
{
if (($js = @file_get_contents(__DIR__.'/../dist/app.js')) === false) {
throw new RuntimeException('Unable to load the Horizon dashboard JavaScript.');
}

$horizon = Js::from(static::scriptVariables());

return new HtmlString(<<<HTML
<script type="module">
window.Horizon = {$horizon};
{$js}
</script>
HTML);
}
}

0 comments on commit 2681f62

Please sign in to comment.