From d7fe05c42c82baf5b925ac4e14f2b906f1504180 Mon Sep 17 00:00:00 2001 From: Matchu Date: Sat, 13 Mar 2021 01:15:29 -0800 Subject: [PATCH] Refactor: Extract OutfitHTML5Badge I'm gonna add glitch stuff too, and I want all this better encapsulated! --- src/app/WardrobePage/OutfitControls.js | 105 +++++++++++++------------ 1 file changed, 56 insertions(+), 49 deletions(-) diff --git a/src/app/WardrobePage/OutfitControls.js b/src/app/WardrobePage/OutfitControls.js index 7d8e0e9..7da6534 100644 --- a/src/app/WardrobePage/OutfitControls.js +++ b/src/app/WardrobePage/OutfitControls.js @@ -88,17 +88,6 @@ function OutfitControls({ } }; - const petIsUsingHTML5 = appearance.petAppearance?.layers.every( - layerUsesHTML5 - ); - - const itemsNotUsingHTML5 = appearance.items.filter((item) => - item.appearance.layers.some((l) => !layerUsesHTML5(l)) - ); - itemsNotUsingHTML5.sort((a, b) => a.name.localeCompare(b.name)); - - const usesHTML5 = petIsUsingHTML5 && itemsNotUsingHTML5.length === 0; - return ( {({ css, cx }) => ( @@ -194,44 +183,7 @@ function OutfitControls({ align="center" justify="center" > - - This outfit is converted to HTML5, and ready to use on - Neopets.com! - - ) : ( - - - This outfit isn't converted to HTML5 yet, so it might - not appear in Neopets.com customization yet. Once it's - ready, it could look a bit different than our - temporary preview here. It might even be animated! - - {!petIsUsingHTML5 && ( - - This pet is not yet converted. - - )} - {itemsNotUsingHTML5.length > 0 && ( - <> - - The following items aren't yet converted: - - - {itemsNotUsingHTML5.map((item) => ( - {item.name} - ))} - - - )} - - ) - } - /> + @@ -265,6 +217,61 @@ function OutfitControls({ ); } +function OutfitHTML5Badge({ appearance }) { + const petIsUsingHTML5 = appearance.petAppearance?.layers.every( + layerUsesHTML5 + ); + + const itemsNotUsingHTML5 = appearance.items.filter((item) => + item.appearance.layers.some((l) => !layerUsesHTML5(l)) + ); + itemsNotUsingHTML5.sort((a, b) => a.name.localeCompare(b.name)); + + const usesHTML5 = petIsUsingHTML5 && itemsNotUsingHTML5.length === 0; + + let tooltipLabel; + if (usesHTML5) { + tooltipLabel = ( + <>This outfit is converted to HTML5, and ready to use on Neopets.com! + ); + } else { + tooltipLabel = ( + + + This outfit isn't converted to HTML5 yet, so it might not appear in + Neopets.com customization yet. Once it's ready, it could look a bit + different than our temporary preview here. It might even be animated! + + {!petIsUsingHTML5 && ( + + This pet is not yet converted. + + )} + {itemsNotUsingHTML5.length > 0 && ( + <> + + The following items aren't yet converted: + + + {itemsNotUsingHTML5.map((item) => ( + {item.name} + ))} + + + )} + + ); + } + + return ( + + ); +} + /** * BackButton takes you back home, or to Your Outfits if this outfit is yours. */