diff --git a/app/src/components/layout/sidebarLeft/Assets.tsx b/app/src/components/layout/sidebarLeft/Assets.tsx index b863500..677090b 100644 --- a/app/src/components/layout/sidebarLeft/Assets.tsx +++ b/app/src/components/layout/sidebarLeft/Assets.tsx @@ -90,24 +90,7 @@ const Assets: React.FC = () => { useEffect(() => { setCategoryList([ - { - assetName: "Doors", - assetImage: "", - category: "Feneration", - categoryImage: feneration, - }, - { - assetName: "Windows", - assetImage: "", - category: "Feneration", - categoryImage: feneration, - }, - { - assetName: "Pillars", - assetImage: "", - category: "Feneration", - categoryImage: feneration, - }, + { category: "Fenestration", categoryImage: feneration }, { category: "Vehicles", categoryImage: vehicle }, { category: "Workstation", categoryImage: workStation }, { category: "Machines", categoryImage: machines }, @@ -121,44 +104,15 @@ const Assets: React.FC = () => { const fetchCategoryAssets = async (asset: any) => { setisLoading(true); setSelectedCategory(asset); - if (asset === "Feneration") { - const localAssets: AssetProp[] = [ - { - filename: "arch", - category: "Feneration", - url: arch, - thumbnail: archThumbnail, - tags: "arch", - }, - { - filename: "door", - category: "Feneration", - url: door, - thumbnail: feneration, - tags: "door", - }, - { - filename: "window", - category: "Feneration", - url: window, - thumbnail: windowThumbnail, - tags: "window", - }, - ]; - setCategoryAssets(localAssets); - setFiltereredAssets(localAssets); + try { + const res = await getCategoryAsset(asset); + setCategoryAssets(res); + setFiltereredAssets(res); + setisLoading(false); // End loading + // eslint-disable-next-line + } catch (error) { + echo.error("failed to fetch assets"); setisLoading(false); - } else { - try { - const res = await getCategoryAsset(asset); - setCategoryAssets(res); - setFiltereredAssets(res); - setisLoading(false); // End loading - // eslint-disable-next-line - } catch (error) { - echo.error("failed to fetch assets"); - setisLoading(false); - } } }; @@ -167,62 +121,19 @@ const Assets: React.FC = () => {
- {isLoading ? ( - // Show skeleton when loading - ) : searchValue ? ( -
-
-
-

Results for {searchValue}

-
-
- {categoryAssets?.map((asset: any, index: number) => ( -
- {asset.filename} - -
- {asset.filename - .split("_") - .map( - (word: any) => - word.charAt(0).toUpperCase() + word.slice(1) - ) - .join(" ")} -
+ {(() => { + if (isLoading) { + return ; // Show skeleton when loading + } + if (searchValue) { + return ( +
+
+
+

Results for {searchValue}

- ))} -
-
-
- ) : ( - <> - {selectedCategory ? ( -
-

- {selectedCategory}{" "} -
{ - setSelectedCategory(null); - setCategoryAssets([]); - }} - > - ← Back -
-

-
- {categoryAssets && - categoryAssets?.map((asset: any, index: number) => ( +
+ {categoryAssets?.map((asset: any, index: number) => (
{ src={asset?.thumbnail} alt={asset.filename} className="asset-image" - onPointerDown={() => { - setSelectedItem({ - name: asset.filename, - id: asset.AssetID, - type: - asset.type === "undefined" - ? undefined - : asset.type, - }); - }} /> +
{asset.filename .split("_") @@ -255,40 +157,104 @@ const Assets: React.FC = () => {
))} +
- ) : ( + ); + } + + if (selectedCategory) { + return (
-

Categories

-
- {Array.from( - new Set(categoryList.map((asset) => asset.category)) - ).map((category, index) => { - const categoryInfo = categoryList.find( - (asset) => asset.category === category - ); - return ( -
fetchCategoryAssets(category)} - > - {category} -
{category}
+

+ {selectedCategory} + +

+
+ {categoryAssets?.map((asset: any, index: number) => ( +
+ {asset.filename} { + setSelectedItem({ + name: asset.filename, + id: asset.AssetID, + type: + asset.type === "undefined" + ? undefined + : asset.type, + }); + }} + /> +
+ {asset.filename + .split("_") + .map( + (word: any) => + word.charAt(0).toUpperCase() + word.slice(1) + ) + .join(" ")}
- ); - })} +
+ ))} + {categoryAssets.length === 0 && ( +
+ 🚧 The asset shelf is empty. We're working on filling it + up! +
+ )}
- )} - - )} + ); + } + + return ( +
+

Categories

+
+ {Array.from( + new Set(categoryList.map((asset) => asset.category)) + ).map((category, index) => { + const categoryInfo = categoryList.find( + (asset) => asset.category === category + ); + return ( +
fetchCategoryAssets(category)} + > + {category} +
{category}
+
+ ); + })} +
+
+ ); + })()}
diff --git a/app/src/components/templates/SkeletonUI.tsx b/app/src/components/templates/SkeletonUI.tsx index 76c3fbd..2928916 100644 --- a/app/src/components/templates/SkeletonUI.tsx +++ b/app/src/components/templates/SkeletonUI.tsx @@ -7,7 +7,6 @@ interface SkeletonUIProps { // Define the SkeletonUI component const SkeletonUI: React.FC = ({ type }) => { - // Function to render skeleton content based on 'type' const renderSkeleton = () => { switch (type) { @@ -38,17 +37,28 @@ const SkeletonUI: React.FC = ({ type }) => { case "asset": return ( <> -
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
); - + default: return (
diff --git a/app/src/styles/layout/sidebar.scss b/app/src/styles/layout/sidebar.scss index defa660..e6b8f10 100644 --- a/app/src/styles/layout/sidebar.scss +++ b/app/src/styles/layout/sidebar.scss @@ -1278,7 +1278,7 @@ } } .toggle-sidebar-ui-button { - svg{ + svg { transform: scaleX(-1); } .tooltip { @@ -1455,7 +1455,11 @@ height: 100%; gap: 6px; padding: 2px; - + .no-asset { + text-align: center; + margin: 12px; + width: 100%; + } .assets { width: 122px; height: 95px; diff --git a/app/src/styles/layout/skeleton.scss b/app/src/styles/layout/skeleton.scss index 2b3e759..3f4fe24 100644 --- a/app/src/styles/layout/skeleton.scss +++ b/app/src/styles/layout/skeleton.scss @@ -1,18 +1,8 @@ .skeleton-wrapper { - // max-width: 600px; - display: flex; - margin: 0 auto; - width: 100%; - - .asset-name { - width: 40%; - height: 10px; - } - - .asset { - width: 100%; - height: 100%; - } + // max-width: 600px; + margin: 0 auto; + width: 100%; + .skeleton { background: var(--background-color-gray); @@ -31,7 +21,7 @@ 90deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.2) 20%, - rgba(255, 255, 255, 0.5) 60%, + rgba(255, 255, 255, 0.39) 60%, rgba(255, 255, 255, 0) 100% ); transform: translateX(-100%); @@ -66,6 +56,34 @@ } } +.asset-category-title{ + width: 60%; + height: 12px; + margin-bottom: 12px; + margin-top: 4px; +} +.skeleton-content-asset{ + display: flex; + height: calc(95px * 2 + 10px); + gap: 10px; + flex-wrap: wrap; + .skeleton-content { + gap: 8px; + flex-direction: column; + min-width: 122px; + min-height: 95px; + .asset-name { + width: 40%; + height: 10px; + } + .asset { + flex: 1; + width: 100%; + height: 100%; + } + } +} + @keyframes shimmer { 100% { transform: translateX(100%);