From 2ad6d8244d988176df4fbaf324d61d04eaff7faa Mon Sep 17 00:00:00 2001 From: Nalvazhuthi Date: Thu, 12 Jun 2025 17:45:54 +0530 Subject: [PATCH] refactor: update material selection styles and improve layout in WallProperties; enhance hover effects --- .../eventProperties/WallProperties.tsx | 94 +++++++++---------- app/src/styles/layout/sidebar.scss | 31 ++++-- 2 files changed, 70 insertions(+), 55 deletions(-) diff --git a/app/src/components/layout/sidebarRight/properties/eventProperties/WallProperties.tsx b/app/src/components/layout/sidebarRight/properties/eventProperties/WallProperties.tsx index 43f1ceb..f3cb792 100644 --- a/app/src/components/layout/sidebarRight/properties/eventProperties/WallProperties.tsx +++ b/app/src/components/layout/sidebarRight/properties/eventProperties/WallProperties.tsx @@ -13,23 +13,26 @@ type Material = { textureName: string; }; -// Initial and default material -const initialMaterial: Material = { - texture: wallTexture1, - textureName: "Grunge Concrete Wall", -}; - +// Default and initial materials const defaultMaterial: Material = { texture: defaultTexture, textureName: "Default Material", }; +const initialMaterial: Material = { + texture: wallTexture1, + textureName: "Grunge Concrete Wall", +}; + const WallProperties = () => { const { wallHeight, wallThickness, setWallHeight, setWallThickness } = useBuilderStore(); const [activeSide, setActiveSide] = useState<"side1" | "side2">("side1"); - const [materials, setMaterials] = useState([initialMaterial]); + const [materials, setMaterials] = useState([ + defaultMaterial, + initialMaterial, + ]); const [selectedMaterials, setSelectedMaterials] = useState<{ side1: Material | null; @@ -39,11 +42,11 @@ const WallProperties = () => { side2: null, }); - // Select initial material for both sides on mount + // Set default material initially for both sides useEffect(() => { setSelectedMaterials({ - side1: initialMaterial, - side2: initialMaterial, + side1: defaultMaterial, + side2: defaultMaterial, }); }, []); @@ -71,21 +74,16 @@ const WallProperties = () => { }; const handleRemoveMaterial = (index: number) => { - const updatedMaterials = materials.filter((_, i) => i !== index); + const removedTexture = materials[index].texture; - // Ensure there's always at least one material - const newMaterials = - updatedMaterials.length === 0 ? [defaultMaterial] : updatedMaterials; + const updatedMaterials = materials.filter((_, i) => i !== index); + const newMaterials = updatedMaterials.length === 0 ? [defaultMaterial] : updatedMaterials; setMaterials(newMaterials); - // Deselect the material if it's the one removed setSelectedMaterials((prev) => { const updated = { ...prev }; ["side1", "side2"].forEach((side) => { - if ( - updated[side as "side1" | "side2"]?.texture === - materials[index].texture - ) { + if (updated[side as "side1" | "side2"]?.texture === removedTexture) { updated[side as "side1" | "side2"] = defaultMaterial; } }); @@ -120,8 +118,7 @@ const WallProperties = () => {
- - ))} + ); + })}
)}
diff --git a/app/src/styles/layout/sidebar.scss b/app/src/styles/layout/sidebar.scss index 62ce571..cf2fbdc 100644 --- a/app/src/styles/layout/sidebar.scss +++ b/app/src/styles/layout/sidebar.scss @@ -1394,16 +1394,20 @@ } &.selected { - background: var(--background-color-accent); - color: var(--text-button-color); + background: var(--highlight-accent-color); + + .aisle-color { + // color: var(--text-button-color); + } &:hover { - background: var(--background-color-accent); + // background: var(--background-color-accent); } } &:hover { - background: var(--background-color-secondary); + background: var(--highlight-accent-color); + // background: var(--background-color-secondary); } } } @@ -1680,6 +1684,7 @@ padding: 0; margin: 0; max-height: 50vh; + overflow: hidden; .header-wrapper { display: flex; @@ -1737,7 +1742,6 @@ .preview { width: 90%; - // width: 100%; height: 111px; img { @@ -1749,9 +1753,10 @@ } .materials { - padding: 6px 12px; max-height: 250px; overflow: auto; + margin-bottom: 6px; + padding: 0 12px; .material-container { display: flex; @@ -1762,6 +1767,16 @@ display: flex; justify-content: space-between; align-items: center; + padding: 4px 6px; + border-radius: 12px; + + &:hover { + background: var(--highlight-accent-color); + } + + &.selectedMaterial { + background: var(--highlight-accent-color); + } .material-property { display: flex; @@ -1769,8 +1784,8 @@ gap: 6px; .material-image { - width: 30px; - height: 30px; + width: 34px; + height: 34px; border-radius: 6px; overflow: hidden;