-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ui): enhance media list views display #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,4 +11,5 @@ | |
| "prettier.tabWidth": 2, | ||
| "editor.tabSize": 2 | ||
| }, | ||
| "djlint.ignore": "H006" | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| """Custom template tags for media-related functionality.""" | ||
|
|
||
| from django import template | ||
|
|
||
| register = template.Library() | ||
|
|
||
|
|
||
| MEDIA_TYPE_ICONS = { | ||
| "BOOK": "book-open", | ||
| "GAME": "computer-desktop", | ||
| "MUSIC": "musical-note", | ||
| "COMIC": "book-open", | ||
| "FILM": "film", | ||
| "TV": "tv", | ||
| "PERF": "ticket", | ||
| "BROADCAST": "microphone", | ||
| } | ||
|
|
||
| SIZE_CLASSES = { | ||
| "sm": "w-4 h-4", | ||
| "md": "w-6 h-6", | ||
| "lg": "w-8 h-8", | ||
| } | ||
|
|
||
| STATUS_CLASSES = { | ||
| "PLANNED": "badge-info", | ||
| "IN_PROGRESS": "badge-accent", | ||
| "COMPLETED": "badge-success", | ||
| "PAUSED": "badge-neutral", | ||
| "DNF": "badge-error", | ||
| } | ||
|
|
||
|
|
||
| @register.inclusion_tag("partials/media-icon.html") | ||
| def media_icon(media_type, size="sm"): | ||
| """ | ||
| Render a heroicon based on media type. | ||
|
|
||
| Args: | ||
| media_type: The type of media (BOOK, GAME, MUSIC, etc.) | ||
| size: Icon size (sm, md, lg) - default 'sm' | ||
|
|
||
| Returns: | ||
| Context dict with icon_name and size_class | ||
|
|
||
| Example usage: | ||
| {% load media_tags %} | ||
| {% media_icon media.media_type size="md" %} | ||
| """ | ||
|
|
||
| icon_name = MEDIA_TYPE_ICONS.get(media_type, "question-mark-circle") | ||
| size_class = SIZE_CLASSES.get(size, "w-4 h-4") | ||
|
|
||
| return { | ||
| "icon_name": icon_name, | ||
| "size_class": size_class, | ||
| } | ||
|
|
||
|
|
||
| @register.filter | ||
| def status_badge_class(status): | ||
| """ | ||
| Return the appropriate DaisyUI badge class for a given status. | ||
|
|
||
| Args: | ||
| status: The media status (PLANNED, IN_PROGRESS, etc.) | ||
|
|
||
| Returns: | ||
| String with DaisyUI badge class name | ||
|
|
||
| Example usage: | ||
| <span class="badge {{ media.status|status_badge_class }}"> | ||
| """ | ||
|
|
||
| return STATUS_CLASSES.get(status, "badge-ghost") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| {# Renders the list of contributors with HTMX links #} | ||
| {# Parameters: media #} | ||
| {% if media.contributors.all %} | ||
| {% for contributor in media.contributors.all %} | ||
| <a href="#" | ||
| class="link link-hover contributor-link" | ||
| data-contributor-id="{{ contributor.id }}" | ||
| data-contributor-name="{{ contributor.name }}" | ||
| hx-get="{% url 'home' %}?contributor={{ contributor.id }}" | ||
| hx-target="#media-list" | ||
| hx-include="#view-mode-input, #sort, #type, #status, #score, #review-from, #review-to" | ||
| hx-push-url="true">{{ contributor.name }}</a>{% if not forloop.last %};{% endif %} | ||
| {% endfor %} | ||
| {% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| {% load i18n %} | ||
| {% load media_tags %} | ||
| <div class="relative w-24 h-32 bg-base-300 rounded"> | ||
| {% if media.cover %} | ||
| <img src="{{ media.cover.url }}" | ||
| alt="{% translate "Cover of" %} {{ media.title }}" | ||
| class="w-full h-full object-contain rounded"> | ||
| {% else %} | ||
| <div class="w-full h-full flex items-center justify-center text-base-content/30"> | ||
| {% heroicon_outline "photo" class="w-12 h-12" %} | ||
| </div> | ||
| {% endif %} | ||
| <div class="absolute top-1 left-1"> | ||
| <span class="badge badge-neutral badge-sm" aria-label="{{ media.get_media_type_display }}">{% media_icon media.media_type size="sm" %}</span> | ||
| </div> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| {% load i18n %} | ||
| {# Renders the edit button for a media #} | ||
| {# Parameters: media #} | ||
| <a href="{% url 'media_edit' media.id %}" | ||
| class="btn btn-outline btn-sm btn-primary tooltip" | ||
| data-tip="{% translate "Edit" %}" | ||
| aria-label="{% translate "Edit" %} {{ media.title }}">{% heroicon_outline "pencil-square" %}</a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {% heroicon_outline icon_name class=size_class %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,104 +1,85 @@ | ||
| {% load i18n %} | ||
| {% load media_tags %} | ||
| {# This partial renders only the media items without the container #} | ||
| {% if view_mode == 'grid' %} | ||
| {# Grid items #} | ||
| {# Grid view - Cards #} | ||
| {% for media in media_list %} | ||
| <div class="card lg:card-side bg-base-200 shadow-md hover:shadow-lg transition-shadow"> | ||
| <figure class="basis-1/4 shrink-0 grow-0 h-full bg-base-300"> | ||
| <div class="card bg-base-200 shadow-sm"> | ||
| <figure class="relative w-full h-64 bg-base-300"> | ||
| {% if media.cover %} | ||
| <img src="{{ media.cover.url }}" | ||
| alt="{{ media.title }}" | ||
| width="200" | ||
| height="300" | ||
| class="w-full h-full object-cover"> | ||
| alt="{% translate "Cover of" %} {{ media.title }}" | ||
| class="w-full h-full object-contain"> | ||
| {% else %} | ||
| <div class="w-full h-full flex items-center justify-center text-base-content/30"> | ||
| {% heroicon_outline "photo" class="w-16 h-16" %} | ||
| {% heroicon_outline "photo" class="w-24 h-24" %} | ||
| </div> | ||
| {% endif %} | ||
| <div class="absolute top-2 left-2"> | ||
| <span class="badge badge-neutral badge-lg" | ||
| aria-label="{{ media.get_media_type_display }}">{% media_icon media.media_type size="md" %}</span> | ||
| </div> | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| {% if media.score %} | ||
| <div class="absolute top-2 right-2">{% include "partials/media-score-badge.html" %}</div> | ||
| {% endif %} | ||
| </figure> | ||
| <div class="card-body basis-3/4 p-3 h-full"> | ||
| <h3 class="card-title text-sm line-clamp-2"> | ||
| <a href="{% url 'media_edit' media.id %}" class="link link-hover">{{ media.title }}</a> | ||
| </h3> | ||
| <div class="text-xs space-y-1"> | ||
| {% for contributor in media.contributors.all %} | ||
| <a href="#" | ||
| class="link link-secondary contributor-link" | ||
| data-contributor-id="{{ contributor.id }}" | ||
| data-contributor-name="{{ contributor.name }}" | ||
| hx-get="{% url 'home' %}?contributor={{ contributor.id }}" | ||
| hx-target="#media-list" | ||
| hx-include="#view-mode-input, #sort, #type, #status, #score, #review-from, #review-to" | ||
| hx-push-url="true">{{ contributor.name }}</a> | ||
| {% if not forloop.last %};{% endif %} | ||
| {% endfor %} | ||
| <div class="flex items-center gap-2 mt-1"> | ||
| <span class="badge badge-sm">{{ media.get_media_type_display }}</span> | ||
| {% include "partials/status-editable.html" with status_choices=status_choices %} | ||
| <div class="card-body p-3"> | ||
| <div class="flex justify-between gap-2"> | ||
| <div> | ||
| <h3 class="card-title inline">{{ media.title }}</h3> | ||
| {% if media.pub_year %}<span class="opacity-70">({{ media.pub_year }})</span>{% endif %} | ||
| <div>{% include "partials/media-contributors.html" %}</div> | ||
| </div> | ||
| {% include "partials/score-editable.html" %} | ||
| {% if media.review %} | ||
| <div id="review-cell-{{ media.id }}" class="text-sm review-text mt-2"> | ||
| {% include "partials/media-review-clamped.html" %} | ||
| </div> | ||
| {% endif %} | ||
| {% if media.review_date %} | ||
| <div class="text-xs opacity-70 mt-1">{{ media.review_date }}</div> | ||
| {% endif %} | ||
| {% include "partials/media-edit-button.html" %} | ||
| </div> | ||
| {% include "partials/media-status-badge.html" %} | ||
| {% if media.review %} | ||
| <div id="review-cell-{{ media.id }}" class="text-sm review-text"> | ||
| {% include "partials/media-review-clamped.html" %} | ||
| </div> | ||
| {% endif %} | ||
| </div> | ||
| </div> | ||
| {% endfor %} | ||
| {% else %} | ||
| {# Table rows #} | ||
| {# List view - Table rows #} | ||
| {% for media in media_list %} | ||
| <tr> | ||
| <td> | ||
| {% if media.cover %} | ||
| <img src="{{ media.cover.url }}" | ||
| alt="{% translate "Cover" %}" | ||
| width="64" | ||
| height="96" | ||
| class="w-16 h-24 object-cover"> | ||
| {% else %} | ||
| <div class="w-16 h-24 bg-gray-200 flex items-center justify-center text-xs">No cover</div> | ||
| {% endif %} | ||
| </td> | ||
| <td> | ||
| <a href="{% url 'media_edit' media.id %}" class="link link-secondary">{{ media.title }}</a> | ||
| </td> | ||
| <td class="max-w-xs"> | ||
| {% for contributor in media.contributors.all %} | ||
| <a href="#" | ||
| class="link link-secondary contributor-link" | ||
| data-contributor-id="{{ contributor.id }}" | ||
| data-contributor-name="{{ contributor.name }}" | ||
| hx-get="{% url 'home' %}?contributor={{ contributor.id }}" | ||
| hx-target="#media-list" | ||
| hx-include="#view-mode-input, #sort, #type, #status, #score, #review-from, #review-to" | ||
| hx-push-url="true">{{ contributor.name }}</a> | ||
| {% if not forloop.last %};{% endif %} | ||
| {% endfor %} | ||
| </td> | ||
| <td>{{ media.get_media_type_display }}</td> | ||
| <td> | ||
| {% include "partials/status-editable.html" with status_choices=status_choices %} | ||
| {# Cover with media type badge #} | ||
| <td class="align-top p-2">{% include "partials/media-cover.html" %}</td> | ||
| {# Title, contributors #} | ||
| <td class="align-top p-2"> | ||
| <div class="flex flex-col gap-1"> | ||
| <h3 class="font-bold text-base"> | ||
| {{ media.title }} | ||
| {% if media.pub_year %}<span class="opacity-70 text-sm font-normal">({{ media.pub_year }})</span>{% endif %} | ||
| </h3> | ||
| {% if media.contributors.all %} | ||
| <div class="text-sm opacity-70">{% include "partials/media-contributors.html" %}</div> | ||
| {% endif %} | ||
| </div> | ||
| </td> | ||
| <td>{{ media.pub_year | default:"" }}</td> | ||
| <td class="max-w-md"> | ||
| {% include "partials/score-editable.html" %} | ||
| {# Review #} | ||
| <td class="align-top p-2 hidden md:table-cell"> | ||
| {% include "partials/media-score-badge.html" with size="sm" extra_class="mb-2" %} | ||
| {% if media.review %} | ||
| <div id="review-cell-{{ media.id }}" class="text-sm review-text mt-2"> | ||
| <div id="review-cell-{{ media.id }}" class="text-sm max-w-200 review-text"> | ||
|
PascalRepond marked this conversation as resolved.
|
||
| {% include "partials/media-review-clamped.html" %} | ||
| </div> | ||
| {% endif %} | ||
| </td> | ||
| <td> | ||
| {# Status #} | ||
| <td class="align-top p-2 hidden sm:table-cell">{% include "partials/media-status-badge.html" %}</td> | ||
| {# Review date #} | ||
| <td class="align-top p-2 hidden lg:table-cell"> | ||
| {% if media.review_date %} | ||
| <div class="text-xs opacity-70">{{ media.review_date }}</div> | ||
| <span class="text-sm">{{ media.review_date }}</span> | ||
| {% else %} | ||
| <span class="text-sm opacity-50">—</span> | ||
| {% endif %} | ||
| </td> | ||
| {# Actions #} | ||
| <td class="align-top p-2">{% include "partials/media-edit-button.html" %}</td> | ||
| </tr> | ||
| {% endfor %} | ||
| {% endif %} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.