feat(badges): cfg_json body_text_color applied in renderer

This commit is contained in:
Scott Idem
2026-04-08 12:32:13 -04:00
parent 56b4e5c627
commit b02843e467
4 changed files with 147 additions and 5 deletions

View File

@@ -4,6 +4,7 @@ import { Loader2 } from '@lucide/svelte';
import type { key_val } from '$lib/stores/ae_stores';
import { events_func } from '$lib/ae_events/ae_events_functions';
import { ae_api } from '$lib/stores/ae_stores';
import type { BadgeTemplateCfg } from '$lib/ae_events/types/ae_badge_template_cfg';
interface Props {
event_id: string;
@@ -56,6 +57,8 @@ let cfg_show_qr_back = $state(true);
let cfg_hide_title = $state(false);
let cfg_hide_affiliations = $state(false);
let cfg_hide_location = $state(false);
// Body text color: Tailwind class (e.g. 'text-black') or hex (e.g. '#000000')
let cfg_body_text_color = $state('text-black');
// Alignment overrides: 'left' | 'center' | 'right' | 'justify'
let cfg_align_name = $state('center');
let cfg_align_title = $state('center');
@@ -125,6 +128,9 @@ async function load_template(id: string) {
cfg_hide_affiliations = parsed_cfg.hasOwnProperty('hide_affiliations') ? !!parsed_cfg.hide_affiliations : false;
cfg_hide_location = parsed_cfg.hasOwnProperty('hide_location') ? !!parsed_cfg.hide_location : false;
// Body text color
cfg_body_text_color = parsed_cfg.body_text_color ?? parsed_cfg.text_color ?? 'text-white';
// Alignment overrides (nested under cfg_json.align and cfg_json.qr_alignment)
cfg_align_name = parsed_cfg?.align?.name ?? parsed_cfg.align_name ?? 'center';
cfg_align_title = parsed_cfg?.align?.title ?? parsed_cfg.align_title ?? 'center';
@@ -152,7 +158,7 @@ async function handle_submit() {
submit_status = 'loading';
// Merge cfg_json preserving unknown keys, then set our cfg flags
let cfg_obj: any = {};
let cfg_obj: BadgeTemplateCfg = {};
try {
cfg_obj = existing_cfg_raw
? typeof existing_cfg_raw === 'string'
@@ -184,6 +190,9 @@ async function handle_submit() {
cfg_obj.qr_alignment.front = cfg_qr_alignment_front;
cfg_obj.qr_alignment.back = cfg_qr_alignment_back;
// Body text color (Tailwind class or hex)
cfg_obj.body_text_color = cfg_body_text_color;
const data_to_save: key_val = {
name,
background_image_path,
@@ -409,6 +418,10 @@ function handle_cancel() {
<option value="justify">Justify</option>
</select>
</label>
<label class="label">
<span>Body Text Color (Tailwind class or #hex)</span>
<input type="text" bind:value={cfg_body_text_color} class="input" placeholder="text-black or #000000" />
</label>
</div>
<p class="text-xs text-surface-400 italic">
These values are saved into <code>cfg_json</code>. Existing cfg_json keys are preserved.