Files
python-tdd/src/templates/apps/gameboard/_partials/_applet-my-sea.html
Disco DeDisco dd99364b78 A.6 + A.7 billboard My Sign applet + gameboard My Sea applet image-rendering + applet-level FLIP-to-back — TDD. Sprints A.6 + A.7 of [[project-image-based-deck-face-rendering]]: rolls image-mode out to the two card-rendering applets (My Sign on /billboard/, My Sea on /gameboard/). Both reuse the shared .sig-stage-card.sig-stage-card--image SCSS contract via a comma-list selector extension covering the parallel container classes (.my-sign-applet-card.my-sign-applet-card--image + .my-sea-slot.my-sea-slot--image) — single source of truth for the contour-stroke drop-shadow chain + tray-card silhouette black depth shadow + .is-flipped-to-back visibility toggle + the --img-stroke-color arcana-keyed CSS prop. Templates branch server-side on card.deck_variant.has_card_images: image-mode renders <img class="sig-stage-card-img" src="{{ card.image_url }}"> w. the marker class + data-arcana-key attr; text mode keeps the existing fan-card-corner + fan-card-face scaffold unchanged. SCSS import-order quirk: _card-deck.scss imports BEFORE both _billboard.scss (which nests .my-sign-applet-card inside .my-sign-applet-body for container queries) and _gameboard.scss (which nests .my-sea-slot--filled.--gravity/--levity inside #id_applet_my_sea w. specificity 1,2,0). The shared top-level image-mode rule at 0,2,0 loses on bg/border/padding to those nested base rules, so each app's stylesheet gets a parallel &.--image { background: transparent; border: 0; padding: 0 } override inside its own nest. The filter-chain rules on .sig-stage-card-img (descendant selector inside the shared rule) DO win since the apps don't restyle that class — only the outer container needs the parallel override. Sprint A.6 bonus: applet-level FLIP btn for non-polarized image-equipped decks (Minchiate today). Mirrors the my_sign.html main page A.5-polish-2 FLIP-to-back contract — .my-sign-applet-flip-btn nested inside the .--image card so absolute positioning anchors to the card bounds; inline <script> IIFE (gated inside the sig-present {% with card %} scope to keep card in lexical reach + prevent the JS selector string leaking into the no-sig DOM where assertNotContains "my-sign-applet-card" ITs catch it) attaches a click handler that runs the same rotateY 0→90→0 animation, toggles .is-flipped-to-back at the halfway point, and clears data-flipping at end; SCSS .my-sign-applet-card[data-flipping] .my-sign-applet-flip-btn { opacity: 0; pointer-events: none } hides the btn mid-spin. Critical scope bug caught + fixed during browser verify: initial draft had the script BLOCK + its {% if card.deck_variant.has_card_images %} gate placed AFTER the {% endwith %} closing tag — card was out of scope at the {% if %} evaluation, Django treats undefined vars as empty string, the gate evaluated falsy, and the script NEVER rendered (the FLIP btn rendered fine since it was inside the with block, but no JS handler → click did nothing but the CSS depress animation). Fix: move {% endwith %} to AFTER the script gate so card is still in scope. 7 new ITs total: 2 in BillboardAppletMySignTest (image-equipped Minchiate renders --image class + img + correct asset URL + lacks text scaffold; Earthman keeps the text scaffold + lacks --image); 3 in BillboardMySignViewTest (data-deck-polarized attr present; back-img element renders for non-polarized image deck; polarized deck omits it); 1 in GameboardViewTest (image-equipped Minchiate slot renders --image + img + lacks text scaffold); plus regression coverage on the no-sig empty-state assertion that originally caught the script-scope bug (assertNotContains validates the script doesn't leak in the no-sig case). Tests: 6 new ITs green; 1306/1306 IT+UT total green (72s; +6 from bdf6a25's 1303 — minus 3 dups since some ITs were counted across both A.6 + A.5-polish-2 runs). Visual verify by user 2026-05-25 PM: stage card image renders cleanly; FLIP cycles to back image + back via animation; FLIP btn hides during 500ms spin; placeholder dim styling correctly distinguishes no-deck state
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-25 01:58:36 -04:00

91 lines
6.0 KiB
HTML

<section
id="id_applet_my_sea"
style="--applet-cols: {{ entry.applet.grid_cols }}; --applet-rows: {{ entry.applet.grid_rows }};"
>
<h2><a href="{% url 'my_sea' %}">My Sea</a></h2>
{# `my_sea_slots` (built by `latest_draw_slots()` in `gameboard.models`) #}
{# carries one entry per spread position in DRAW_ORDER — filled slots #}
{# render the drawn card, empty slots render as labelled placeholders. #}
{# Spread lock-in: the row is created at first card draw, so the moment #}
{# 1+ cards exist all the spread's positions show in the applet. The #}
{# scroll container handles overflow (mirrors the Palettes applet). #}
{# Slot display is INDEPENDENT of `request.user.significator_id` — the #}
{# MySeaDraw row snapshots the sig at first-draw time (see #}
{# `gameboard.models.MySeaDraw` doc lines 130-132), so a subsequent #}
{# my-sign DEL doesn't invalidate the saved draw. The sig-gate Brief #}
{# banner only shows when the user has NO draws AND no sig — once draws #}
{# exist, they render regardless of current sig state (user spec #}
{# 2026-05-25 PM bug-report). #}
{% if my_sea_slots %}
<div class="my-sea-scroll">
{% for slot in my_sea_slots %}
{% if slot.card %}
<div class="my-sea-slot-wrap">
{# Mirrors the my_sign.html `.sig-stage-card` layout — #}
{# corner top-left, face w. name + arcana, mirror corner #}
{# bottom-right. Label is a SIBLING of the slot inside #}
{# the wrap so it sits BELOW the slot box (user-spec #}
{# 2026-05-23: same position as the my_sea.html picker's #}
{# `.sea-pos-label`). #}
<div class="my-sea-slot my-sea-slot--filled my-sea-slot--{{ slot.polarity }}{% if slot.reversed %} my-sea-slot--reversed{% endif %}{% if slot.card.deck_variant.has_card_images %} my-sea-slot--image{% endif %}"
data-position="{{ slot.position }}"
data-card-id="{{ slot.card.id }}"
data-arcana-key="{{ slot.card.arcana }}">
{% if slot.card.deck_variant.has_card_images %}
{# Sprint A.7 — image-mode slot render. Shares the #}
{# `.sig-stage-card-img` SCSS rule via the #}
{# `.my-sea-slot--image` comma-list addition in #}
{# `_card-deck.scss`. Contour stroke + depth shadow #}
{# scale w. the slot's smaller dimensions. #}
<img class="sig-stage-card-img" src="{{ slot.card.image_url }}" alt="{{ slot.card.name }}">
{% else %}
<div class="fan-card-corner fan-card-corner--tl">
<span class="fan-corner-rank">{{ slot.card.corner_rank }}</span>
{% if slot.card.suit_icon %}<i class="fa-solid {{ slot.card.suit_icon }}"></i>{% endif %}
</div>
<div class="fan-card-face">
{# `slot.face` is the rendering payload from `TarotCard. #}
{# applet_face()` — mirrors `populateCard` in #}
{# `stage-card.js`: #}
{# • Polarity-split (cards 19-21, 48-49): single-line #}
{# title, qualifier blank. #}
{# • Pattern B Major (2-5, 10-15, 22-35, 41): swapped #}
{# reversal name + polarity qualifier carried. #}
{# • Pattern B' Major (16-18): swapped reversal name, #}
{# no qualifier on reversal. #}
{# • Non-Major: qualifier ABOVE the title. #}
{# Empty `.fan-card-qualifier` is hidden by `:empty` CSS. #}
{% if slot.face.qualifier_first %}
<p class="fan-card-qualifier">{{ slot.face.qualifier }}</p>
<p class="fan-card-name">{{ slot.face.title }}</p>
{% else %}
<p class="fan-card-name">{{ slot.face.title }}</p>
<p class="fan-card-qualifier">{{ slot.face.qualifier }}</p>
{% endif %}
<p class="fan-card-arcana">{{ slot.card.get_arcana_display }}</p>
</div>
<div class="fan-card-corner fan-card-corner--br">
<span class="fan-corner-rank">{{ slot.card.corner_rank }}</span>
{% if slot.card.suit_icon %}<i class="fa-solid {{ slot.card.suit_icon }}"></i>{% endif %}
</div>
{% endif %}
</div>
<span class="my-sea-slot-label">{{ slot.label }}</span>
</div>
{% else %}
<div class="my-sea-slot-wrap">
<div class="my-sea-slot my-sea-slot--empty"
data-position="{{ slot.position }}"></div>
<span class="my-sea-slot-label my-sea-slot-label--empty">{{ slot.label }}</span>
</div>
{% endif %}
{% endfor %}
</div>
{% else %}
{% if not request.user.significator_id %}
{% include "apps/gameboard/_partials/_my_sea_sign_gate_brief.html" %}
{% endif %}
<p class="my-sea-empty">No draws yet.</p>
{% endif %}
</section>