From 6ed9667dfbbbc9701f043720ea1df01044a77107 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Mon, 9 Oct 2017 00:46:58 -0400 Subject: [PATCH] Editor: hide things as per input JSON --- js/editor.js | 12 ++++++++-- template/environment/deck.svg | 45 +++++++++++++++++++---------------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/js/editor.js b/js/editor.js index 000965d..64bfe25 100644 --- a/js/editor.js +++ b/js/editor.js @@ -142,8 +142,16 @@ function makeCardSVG(deck, cardInputTemplate, templateSVG, card) { selected = {svg: cardSVG, json: card}; setForm(cardInputTemplate, card); }, true); - Object.keys(cardInputTemplate.inputs).forEach(prop => - wrapSVGText(cardSVG.querySelector('#' + prop), String(card[prop] || ""))); + Object.keys(cardInputTemplate.inputs).forEach( + prop => wrapSVGText(cardSVG.querySelector('#' + prop), String(card[prop] || ""))); + Object.entries(cardInputTemplate.hide).forEach(hidable => { + if (hidable[1] in card) { + cardSVG.querySelector('#' + hidable[0]).setAttribute('display', ''); + } + else { + cardSVG.querySelector('#' + hidable[0]).setAttribute('display', 'none'); + } + }); } function upload() { diff --git a/template/environment/deck.svg b/template/environment/deck.svg index 754cf2a..a10ce7a 100644 --- a/template/environment/deck.svg +++ b/template/environment/deck.svg @@ -324,21 +324,26 @@ - - - - - - - + Header + - Keywords + + + + + + + + + Keywords + Text Here Text Here art by + @@ -346,18 +351,18 @@ - - - + + + + + + + + + + + + 3 - - - - - - - -3 -