Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
wizzymore authored and actions-user committed Dec 4, 2021
1 parent 9a8bfb2 commit 8a750d1
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/Helpers/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ final private function __construct()
{
// This is only instantiated using the build factory method.
}
}
}
2 changes: 1 addition & 1 deletion src/Helpers/NameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public static function partialNameFor(Model $model): string

return "pages.{$resource}._partials.{$partial}";
}
}
}
2 changes: 1 addition & 1 deletion src/Helpers/RouteRedirectGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ public function guess(string $routeName): string

return str_replace($lookFor, $replaceWith, $routeName);
}
}
}
4 changes: 2 additions & 2 deletions src/Middleware/TurboMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Eptic\Turbo\Middleware;

use Closure;
use Eptic\Turbo\Helpers\RouteRedirectGuesser;
use Eptic\Turbo\Turbo;
use Closure;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Expand Down Expand Up @@ -83,4 +83,4 @@ private function guessRedirectingRoute(Request $request): ?string

return route($formRouteName, optional($route)->parameters() + request()->query());
}
}
}
4 changes: 2 additions & 2 deletions src/Responses/TurboFrameResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class TurboFrameResponse implements Responsable
private array $partialData = [];
private string $template = '';
public const TEMPLATES = [
'generic' => 'turbo-frame'
'generic' => 'turbo-frame',
];

private function inserted(string $template, string $id, View $partial, string $target = null): self
Expand Down Expand Up @@ -81,4 +81,4 @@ private function render(): string
'partialData' => $this->partialData,
])->render();
}
}
}
2 changes: 1 addition & 1 deletion src/Responses/TurboStreamResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private function render(): string
'target' => $this->useTarget,
'action' => $this->useAction,
'partial' => $this->partialView,
'partialData' => $this->partialData
'partialData' => $this->partialData,
])->render();
}
}
10 changes: 5 additions & 5 deletions src/Turbo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@

class Turbo
{
const TURBO_STREAM_FORMAT = 'text/vnd.turbo-stream.html';
public const TURBO_STREAM_FORMAT = 'text/vnd.turbo-stream.html';

/**
* @param Request $request
* @return bool
*/
static public function turboVisit(Request $request): bool
public static function turboVisit(Request $request): bool
{
return Str::contains($request->header('Accept', ''), static::TURBO_STREAM_FORMAT);
}

static public function makeStream(string $content, $status = 200): Response
public static function makeStream(string $content, $status = 200): Response
{
return response($content, $status, ['Content-Type' => static::TURBO_STREAM_FORMAT]);
}

static public function makeFrame(string $content, $status = 200): Response
public static function makeFrame(string $content, $status = 200): Response
{
return response($content, $status);
}
}
}
12 changes: 7 additions & 5 deletions src/TurboServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
use Eptic\Turbo\Responses\TurboFrameResponse;
use Eptic\Turbo\Responses\TurboStreamResponse;
use Illuminate\Contracts\View\View;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\ResponseFactory;
use Illuminate\Http\Request;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class TurboServiceProvider extends PackageServiceProvider
{
Expand Down Expand Up @@ -45,14 +45,16 @@ private function bindRequestAndResponseMacros()
return TurboStreamResponse::create($target, $action, $partial);
});

ResponseFactory::macro('turboStream',
ResponseFactory::macro(
'turboStream',
function (string $target = null, string $action = null, View $partial = null) {
if ($target === null) {
return new TurboStreamResponse();
}

return TurboStreamResponse::create($target, $action, $partial);
});
}
);

Response::macro('turboFrame', function () {
return new TurboFrameResponse();
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Eptic\Turbo\Tests;

use Eptic\Turbo\TurboServiceProvider;
use Illuminate\Database\Eloquent\Factories\Factory;
use Orchestra\Testbench\TestCase as Orchestra;
use Eptic\Turbo\TurboServiceProvider;

class TestCase extends Orchestra
{
Expand Down

0 comments on commit 8a750d1

Please sign in to comment.