From fdd83158200028193e5320293ef8ac112abf352b Mon Sep 17 00:00:00 2001 From: memelotsqui Date: Sat, 21 Oct 2023 22:13:21 -0600 Subject: [PATCH] add json filename as title --- src/components/JsonAttributes.jsx | 65 +++++++++++++++---------------- src/pages/Appearance.jsx | 10 +++-- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/src/components/JsonAttributes.jsx b/src/components/JsonAttributes.jsx index 856bb9d6..ef86f487 100644 --- a/src/components/JsonAttributes.jsx +++ b/src/components/JsonAttributes.jsx @@ -6,38 +6,37 @@ export default function JsonAttributes({jsonSelection}){ return ( jsonSelection != null ? ( - -
- -
- {jsonSelection.thumb && ( - Selection Thumbnail - )} - { - jsonSelection.attributes.map((attribute) =>{ - return ( -
-
- {`${attribute.trait} : ${attribute.id}`} -
-
- ) - }) - } +
+ +
+ {jsonSelection.name && ( +
+
+ {jsonSelection.name} +
-
- ):(<>) - ) + )} + {jsonSelection.thumb && ( + Selection Thumbnail + )} + {jsonSelection.attributes.map((attribute) => ( +
+
+ {`${attribute.trait} : ${attribute.id}`} +
+
+ ))} +
+
+ ) : (<>) + ); } \ No newline at end of file diff --git a/src/pages/Appearance.jsx b/src/pages/Appearance.jsx index 621c2e96..aac28ba4 100644 --- a/src/pages/Appearance.jsx +++ b/src/pages/Appearance.jsx @@ -96,9 +96,9 @@ function Appearance({ if (file && file.name.toLowerCase().endsWith('.json')) { //console.log('Dropped .json file:', file); const reader = new FileReader(); - console.warn(file.name); const thumbLocation = `${templateInfo.assetsLocation}/anata/_thumbnails/t_${file.name.split('_')[0]}.jpg` - console.log(thumbLocation); + const jsonName = file.name.split('.')[0]; + //const thumbnailName = reader.onload = function(e) { try { @@ -108,8 +108,10 @@ function Appearance({ const options = []; const jsonAttributes = jsonContent.attributes.map((attribute) => {return { trait:attribute.trait_type, id:attribute.value }}); - console.log(jsonAttributes); - const jsonSelection = {thumb:thumbLocation,attributes:jsonAttributes} + + + const jsonSelection = {name: jsonName, thumb:thumbLocation,attributes:jsonAttributes} + console.log(jsonSelection); setJsonSelection(jsonSelection); jsonContent.attributes.forEach(attribute => {