ui(badges): add background image bleed support (cfg_json, PVC layout)

- Add `bleed` field to BadgeTemplateCfg (CSS length, e.g. "0.125in")
- Badge view: derive bleed_offset, move bg-image to absolute positioned div
  that extends past card edges; add isolation:isolate to badge_front stacking context
- Template form: add bleed input in Advanced > Appearance; wire to cfg_json save/load
- PVC layout CSS: change overflow:hidden → overflow:visible in print rule to allow
  bleed div to render at physical card boundary (Zebra driver clips at card edge)
- Prevents white borders on PVC cards when printer has slight alignment variance.
  Screen preview shows bleed visually extending past the card outline.
This commit is contained in:
Scott Idem
2026-04-10 14:25:08 -04:00
parent cfdec1e305
commit c7fa75afc7
4 changed files with 55 additions and 5 deletions

View File

@@ -309,6 +309,15 @@ let body_text_color_style = $derived.by(() => {
return 'color: #000000;';
});
// Background image bleed: template cfg_json.bleed is a CSS length like "0.125in" or "3mm".
// We negate it here so it can be used as a CSS inset value on the bleed container div.
// "0px" means no bleed — the bg image is flush with the badge edges (same as before).
let bleed_offset = $derived.by(() => {
const b = template_cfg?.bleed;
if (!b || b === '0' || b === '0px') return '0px';
return `-${b}`;
});
/**
* Layout-aware section heights for Element_fit_text.
*
@@ -615,9 +624,7 @@ const code_to_icon: {
text-center hover:outline-2 hover:outline-red-500/75
hover:outline-dashed
"
style="{bg_image_path
? `background-image: url('${bg_image_path}'); background-size: cover; background-position: top center; background-repeat: no-repeat;`
: ''}{demo_bg_style ? ` ${demo_bg_style}` : ''}">
style="isolation: isolate;{demo_bg_style ? ` ${demo_bg_style}` : ''}">
<span
class="
absolute top-1 left-4 text-xs
@@ -628,6 +635,20 @@ const code_to_icon: {
{#if show_badge_back}Front of badge{:else}Badge preview{/if}
</span>
<!-- Background image bleed container.
Absolutely positioned so it can extend past badge_front's edges by bleed_offset
(e.g. "-0.125in" on all sides). z-index: -1 keeps it behind all badge content.
badge_front has isolation: isolate so the negative z-index stays within its
stacking context and doesn't punch through parent backgrounds.
When bleed_offset is "0px" this is flush with the badge edges (same as before). -->
{#if bg_image_path}
<div
class="pointer-events-none absolute"
aria-hidden="true"
style="top: {bleed_offset}; right: {bleed_offset}; bottom: {bleed_offset}; left: {bleed_offset}; z-index: -1; background-image: url('{bg_image_path}'); background-size: cover; background-position: top center; background-repeat: no-repeat;">
</div>
{/if}
<!-- Header: controlled by per-template cfg_json (hide_badge_header).
If cfg.hide_badge_header is set, it overrides the default. By default
a background image will hide the header unless explicitly overridden. -->
@@ -1310,7 +1331,7 @@ const code_to_icon: {
}
.name_pad_long {
/* padding-left: 2%; */
/* padding-right: 0%; */
padding-right: 0%;
}
/*