Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Nov 14, 2023
1 parent 22c5682 commit 67159b4
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 42 deletions.
4 changes: 1 addition & 3 deletions app/Http/Controllers/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,11 @@ public function list(Request $request)
->orderBy('id', 'desc')
->cursorPaginate(3);

$test = view('particles.posts.list', [
return view('particles.posts.list', [
'posts' => $posts,
'isMyProfile' => $request->has('user_id') && $request->user()?->id == $request->get('user_id'),
'action' => $this->action
])->fragmentsIf(!$request->isMethodSafe());

return $test;
}

}
2 changes: 1 addition & 1 deletion app/Policies/OwnerPolicy.php → app/Policies/HasOwner.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Auth\Access\Response;
use Illuminate\Database\Eloquent\Model;

trait OwnerPolicy
trait HasOwner
{
use HandlesAuthorization;

Expand Down
3 changes: 1 addition & 2 deletions app/Policies/PostPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@

class PostPolicy
{
use OwnerPolicy;

use HasOwner;
}
15 changes: 15 additions & 0 deletions resources/css/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -543,3 +543,18 @@ main {
display: block;
}



@keyframes fade-in {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}

.hotwire-frame {
opacity: 0;
animation: fade-in 0.5s ease-in-out forwards;
}
32 changes: 18 additions & 14 deletions resources/views/pages/profile/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="d-sm-flex align-items-start text-center text-sm-start">
<div>
<!-- Avatar -->
<div class="avatar avatar-xxl mt-n5 mb-3">
<div class="avatar avatar-xxl mt-n5 mb-3 mx-auto">
<img class="avatar-img rounded-circle border border-tertiary-subtle border-3"
src="{{ $user->avatar }}" alt="">
</div>
Expand All @@ -28,28 +28,32 @@
<small class="opacity-75">На проекте с 23 мая 2022</small>
</div>

<div class="d-flex flex-column my-3 ms-sm-auto ">

<div class="d-flex flex-column my-3 ms-sm-auto">


@if ($isMyAccount)
<x-logout class="btn btn-link" formId="sign-out">
<x-icon path="bs.logout" class="pe-1" />
Выйти из профиля
</x-logout>
<a href="{{route('my.edit')}}" class="btn btn-danger">
<x-icon path="bs.pencil-fill" class="pe-1"/>
Редактировать
</a>
<div class="d-flex">
<x-logout class="btn btn-link" formId="sign-out" title="Выйти">
<x-icon path="bs.door-closed"/>
</x-logout>
<a href="{{route('my.edit')}}" class="btn btn-danger">
<x-icon path="bs.pencil-fill" class="pe-1"/>
Редактировать
</a>
</div>
@else
<a href="https://github.com/{{$user->nickname}}" class="d-block mb-2">
<x-icon path="bs.github" width="1.5em" height="1.5em" class="pe-1"/>
<a href="https://github.com/{{$user->nickname}}" class="d-block">
<x-icon path="bs.github" width="2em" height="2em"/>
</a>


@endif
</div>
</div>

<div class="">
{!! \Illuminate\Support\Str::of($user->about)->markdown() !!}
</div>

</div>
</div>

Expand Down
31 changes: 15 additions & 16 deletions resources/views/pages/profile/tabs/comments-tab.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@section('tab')
@if($comments->isEmpty())
@if ($isMyAccount)
<div class="bg-body-tertiary rounded p-5">
<div class="bg-body-tertiary rounded p-5 rounded">
<div class="p-5">
<div class="text-center mb-3">
Вы не написали ни одного комментария
Expand All @@ -14,7 +14,7 @@
</div>
</div>
@else
<div class="bg-body-tertiary rounded p-5">
<div class="bg-body-tertiary rounded p-5 rounded">
<div class="p-5">
<div class="text-center mb-3">
Этот пользователь не оставил ни одного комментария
Expand All @@ -24,20 +24,19 @@
@endif
@else


<turbo-frame id="comments-frame">
<x-stream target="comments">
<div class="col-xl-8 col-md-12 mx-auto mt-5 mb-3">
<div class="bg-body-tertiary overflow-hidden px-5 py-3">
@foreach($comments as $comment)
@include('pages.profile.tabs.particles.comments.comment', [
'comment' => $comment,
'edit' => $edit ?? null,
])
@endforeach
</div>
<turbo-frame id="comments-frame">
<x-stream target="comments">
<div class="col-xl-8 col-md-12 mx-auto mb-3">
<div class="bg-body-tertiary overflow-hidden px-5 py-3 rounded">
@foreach($comments as $comment)
@include('pages.profile.tabs.particles.comments.comment', [
'comment' => $comment,
'edit' => $edit ?? null,
])
@endforeach
</div>
</x-stream>
</turbo-frame>
</div>
</x-stream>
</turbo-frame>
@endif
@endsection
10 changes: 5 additions & 5 deletions resources/views/particles/posts/list.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<turbo-frame id="posts-frame" data-turbo-temporary>
<x-stream target="posts" action="{{$action}}" class="col-xl-8 col-md-12 mx-auto">
<x-stream target="posts" action="{{$action}}" class="col-xl-8 col-md-12 mx-auto hotwire-frame">
@if($posts->isEmpty())
<div class="bg-body-tertiary rounded p-5">
<div class="bg-body-tertiary rounded p-5 rounded">
<div class="p-5">
@if ($isMyProfile)
<div class="text-center mb-3">
Expand All @@ -21,7 +21,7 @@
</div>
@else
@foreach ($posts as $post)
<div class="bg-body-tertiary mb-4 px-5 py-4">
<div class="bg-body-tertiary mb-4 px-5 py-4 rounded">

<div class="d-flex align-items-center justify-content-between mb-3">
<div class="d-flex align-items-center">
Expand Down Expand Up @@ -59,13 +59,13 @@ class="text-body-secondary text-decoration-none">{{ $post->user->name }}</a>
</div>
</div>

<div class="position-relative">
<div class="position-relative post">
<a href="{{ route('post.show', $post) }}"
class="position-absolute start-0 end-0 top-0 bottom-0"></a>

<h4 class="mb-3">{{ $post->title }}</h4>

<p>{{ $post->preview() }} </p>
<p>{!! \Illuminate\Support\Str::of($post->content)->markdown() !!}</p>
</div>

<div class="d-flex align-items-center mt-4">
Expand Down
2 changes: 1 addition & 1 deletion resources/views/post/list.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

<div class="container my-5">
<div class="row">
<turbo-frame id="posts-frame" target="_top" src="{{ route('feed.articles') }}"/>
<turbo-frame id="posts-frame" target="_top" src="{{ route('posts') }}"/>
</div>
</div>
@endsection

0 comments on commit 67159b4

Please sign in to comment.