Skip to content

Commit

Permalink
use config for username max string length to truncate
Browse files Browse the repository at this point in the history
  • Loading branch information
butburg committed Sep 4, 2024
1 parent 0b52612 commit 1bcd30b
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .timetracker

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
return [

'posts_per_page' => 15,
'truncate_name' => 40,

/*
|--------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/resources/views/admin/partials/user-list.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<tbody>
@foreach ($users->sortByDesc('created_at') as $user)
<tr>
<td class="border px-4 py-2" title="{{ $user->name }}">{{ Str::limit($user->name, 30, '...') }}</td>
<td class="border px-4 py-2" title="{{ $user->name }}">{{ Str::limit($user->name, config('app.truncate_name'), '...') }}</td>
<td class="border px-4 py-2">{{ $user->email }}</td>
<td class="border px-4 py-2">{{ $user->usertype }}</td>
<td class="border px-4 py-2">{{ $user->posts_count }}</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@if ($comment->user)
<a class="text-title-text flex-grow cursor-pointer text-sm font-semibold hover:underline"
href="{{ route('profile.show', $comment->user) }}">
{{ Auth::id() === $comment->user_id ? 'You' : Str::limit($comment->user?->name ?? 'Unknown', 30, '...') }}
{{ Auth::id() === $comment->user_id ? 'You' : Str::limit($comment->user?->name, config('app.truncate_name'), '...') }}
</a>
@else
<a class="text-title-text flex-grow cursor-pointer text-sm font-semibold text-gray-800 hover:underline"
Expand Down
6 changes: 3 additions & 3 deletions src/resources/views/components/gallery/gallery.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class="text-content-bg break-words text-lg font-semibold md:text-2xl">
title="{{ $post->user->name }}">
<a class="cursor-pointer hover:underline"
href="{{ route('profile.show', $post->user) }}">
{{ Str::limit($post->user->name, 40, '...') }}
{{ Str::limit($post->user->name, config('app.truncate_name'), '...') }}
</a>
{{-- Display former name if applicable --}}
@php
Expand All @@ -48,14 +48,14 @@ class="text-content-bg break-words text-lg font-semibold md:text-2xl">
@if ($formerName)
<span
class="text-xs text-gray-500">(Formerly:
{{ Str::limit($formerName, 40, '...') }})</span>
{{ Str::limit($formerName, config('app.truncate_name'), '...') }})</span>
@endif
</p>
@else
{{-- no user found --}}
<p class="text-nav-bg text-sm text-gray-500 font-medium"
title="{{ $post->username }}">
{{ Str::limit($post->username, 40, '...') }}
{{ Str::limit($post->username, config('app.truncate_name'), '...') }}
</p>
@endif

Expand Down
2 changes: 1 addition & 1 deletion src/resources/views/components/profile/user-name.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
</p>
@endif
<h4 class="text-xl font-bold text-c-text" title="{{ $user->name }}">
{{ Str::limit($user->getFormerNameIfApplicable(), 30, '...') }}
{{ Str::limit($user->name, config('app.truncate_name'), '...') }}
</h4>
38 changes: 26 additions & 12 deletions src/resources/views/layouts/navigation.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<nav class="border-b border-gray-100 bg-c-background text-c-text" x-data="{ open: false }">
<nav class="border-b border-gray-100 bg-c-background text-c-text"
x-data="{ open: false }">
<!-- Navigation Headbar -->
<div class="mx-auto max-w-screen-2xl px-4 sm:px-6 lg:px-8">
<div class="flex h-16 justify-between">
Expand Down Expand Up @@ -44,25 +45,34 @@
@auth
<!-- Hamburger for small screen -->
<div class="ms-6 flex items-center sm:hidden">
<x-dropdown align="right" width="48" contentClasses="py-1 bg-c-primary">
<x-dropdown align="right" width="48"
contentClasses="py-1 bg-c-primary">
<x-slot name="trigger">
<button
class="inline-flex items-center justify-center rounded-md p-2 text-c-text transition duration-150 ease-in-out hover:bg-c-background hover:text-gray-500 focus:bg-gray-100 focus:text-gray-500 focus:outline-none">
<svg class="h-6 w-6" stroke="currentColor" fill="none" viewBox="0 0 24 24">
<path class="inline-flex" :class="{ 'hidden': open, 'inline-flex': !open }"
stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
<svg class="h-6 w-6" stroke="currentColor"
fill="none" viewBox="0 0 24 24">
<path class="inline-flex"
:class="{ 'hidden': open, 'inline-flex': !open }"
stroke-linecap="round"
stroke-linejoin="round" stroke-width="2"
d="M4 6h16M4 12h16M4 18h16" />
<path class="hidden" :class="{ 'hidden': !open, 'inline-flex': open }"
stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
<path class="hidden"
:class="{ 'hidden': !open, 'inline-flex': open }"
stroke-linecap="round"
stroke-linejoin="round" stroke-width="2"
d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</x-slot>

<x-slot name="content">
<div class="space-y-1">
<div class="block w-full border-b-2 py-2 pe-4 ps-3 text-start text-base font-medium">
<div class="text-base font-medium">{{ Str::limit(Auth::user()->name, 30, '...') }}</div>
<div
class="block w-full border-b-2 py-2 pe-4 ps-3 text-start text-base font-medium">
<div class="text-base font-medium">
{{ Str::limit(Auth::user()->name, config('app.truncate_name'), '...') }}
</div>
</div>
@if (Auth::user()->usertype == 'admin')
<x-responsive-nav-link :href="route('admin.index')">
Expand All @@ -89,14 +99,18 @@ class="inline-flex items-center justify-center rounded-md p-2 text-c-text transi

{{-- user menu for desktop --}}
<div class="hidden sm:ms-6 sm:flex sm:items-center">
<x-dropdown align="right" width="48" contentClasses="py-1 bg-c-primary">
<x-dropdown align="right" width="48"
contentClasses="py-1 bg-c-primary">
<x-slot name="trigger">
<button
class="inline-flex items-center rounded-md border border-transparent px-3 py-2 text-sm font-medium leading-4 text-c-text transition duration-150 ease-in-out hover:bg-c-primary/20 focus:outline-none">
<div>{{ Str::limit(Auth::user()->name, 30, '...') }}</div>
<div>
{{ Str::limit(Auth::user()->name, config('app.truncate_name'), '...') }}
</div>

<div class="ms-1">
<svg class="h-4 w-4 fill-current" xmlns="http://www.w3.org/2000/svg"
<svg class="h-4 w-4 fill-current"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 20">
<path fill-rule="evenodd"
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
Expand Down

0 comments on commit 1bcd30b

Please sign in to comment.