Skip to content

Commit

Permalink
Minor visual tweaks
Browse files Browse the repository at this point in the history
- Show product number on item cards, and give brand and categories more space
- Don't show items without images or tagged partial or sensitive content on home page
  • Loading branch information
momijizukamori committed Jun 12, 2024
1 parent 99669ee commit a8483db
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
7 changes: 6 additions & 1 deletion app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Database\Eloquent\Builder;
use App\Models\Brand;
use App\Models\Category;
use App\Models\Item;
Expand All @@ -28,8 +29,12 @@ public function homepage()
$brands = Brand::all();
$categories = Category::all();
$recent = Item::with(Item::PARTIAL_LOAD)
->drafts(false)
->whereNotNull('published_at')
->orderBy('published_at', 'desc')
->whereNotNull('image')
->whereDoesntHave('tags', function (Builder $query) {
$query->whereIn('slug', ['partial', 'sensitive-content']);
})
->take(15)
->get();

Expand Down
4 changes: 4 additions & 0 deletions resources/sass/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@
.card .category:not(:last-child)::after {
content: ", ";
margin-left: -.25em;
}

.itemnum {
font-size: 0.7em;
}
27 changes: 15 additions & 12 deletions resources/views/items/card.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
style="white-space: nowrap; overflow-x: hidden; text-overflow: ellipsis;">
{{ $item->english_name }}
</p>
<p class="text-muted small"
<p class="text-muted small mb-0"
title="{{ $item->foreign_name }}"
style="white-space: nowrap; overflow-x: hidden; text-overflow: ellipsis;">
@if ($item->foreign_name)
Expand All @@ -14,6 +14,15 @@
&nbsp;
@endif
</p>
<p class="text-muted itemnum mb-0"
title="{{ $item->product_number }}"
style="white-space: nowrap; overflow-x: hidden; text-overflow: ellipsis;">
@if ($item->product_number)
{{ $item->product_number }}
@else
&nbsp;
@endif
</p>

<div style="height: {{ ($type ?? null) === 'small' ? '7rem' : '14rem' }}" class="text-center">
<a href="{{ $item->url }}">
Expand All @@ -24,22 +33,16 @@
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item py-1 px-3">
<div class="row small text-muted">
<p class="col m-0 text-left">
{{ __('ui.item.brand') }}
</p>
<p class="col m-0 text-right">
{{ __('ui.item.category') }}
</p>
</div>
<div class="d-flex small">
<p class="p-0 m-0 text-left flex-fill" style="white-space: nowrap; overflow-x: ellipsis;">
<p class="p-0 m-0 text-center font-weight-bolder flex-fill" style="white-space: nowrap; overflow-x: ellipsis;">
<a href="{{ $item->brand->url }}" title="{{ $item->brand->name }}">
{{ Str::limit($item->brand->name, 21) }}
{{$item->brand->name}}
{{-- deliberately chose 21 as the cutoff since lots of brand names fit on word boundaries. --}}
</a>
</p>
<p class="p-0 m-0 text-right flex-fill" style="white-space: nowrap; overflow-x: hidden">
</div>
<div class="d-flex small">
<p class="p-0 m-0 text-center flex-fill" style="white-space: nowrap; overflow-x: hidden">
@foreach($item->categories as $category)
<a href="{{ $category->url }}" class="category">
{{ $category->name }}
Expand Down

0 comments on commit a8483db

Please sign in to comment.