This commit is contained in:
2026-07-30 20:02:41 +02:00
parent c6ea67b404
commit 7ee2cf6c13
9 changed files with 99 additions and 42 deletions
+8 -3
View File
@@ -1,10 +1,12 @@
.navbar {
padding: 16px;
color: gray;
display: flex;
background: var(--code-bg);
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
height: 50px;
height: 80px;
}
.navbar h1 {
@@ -100,5 +102,8 @@ footer {
display: flex;
background: var(--code-bg);
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
height: 20px;
}
height: 40px;
}
@import "tailwindcss";
@@ -1,18 +1,22 @@
import React, { Component } from 'react';
import { useState } from 'react';
import { Tree } from 'react-arborist';
import TreeView from './TreeView';
import PropertyTreeView from './PropertyTreeView';
const PropertySideBar = ({ properties, setUpdate }) => {
const PropertySideBar = ({ properties }) => {
return (
<nav className="sidebar">
<div>
<h1>Property Pool:</h1>
</div>
<div className="side-links">
<TreeView data={[properties]} setUpdate={setUpdate} />
</div>
<div className="spacer">...</div>
<ul>
{properties.map((node) => (
<li key={node.id}>
{node.label}
</li>
))}
</ul>
</div><div className="spacer">...</div>
</nav>
);
};
@@ -0,0 +1,47 @@
import React from 'react';
import { useState } from 'react';
import { ChevronRightIcon } from '@heroicons/react/16/solid';
import { DocumentIcon, FolderIcon } from '@heroicons/react/24/solid';
const PropertyTreeView = ({ node, key }) => {
const [expanded, setExpanded] = useState(true);
console.log('node:', key, node.id, node.label, node.subPropertygroups);
return (
<li key={node.id}>
<span className="flex items-center gap-1.5 py-1">
{node.subPropertygroups && node.subPropertygroups.length > 0 && (
<button onClick={() => setExpanded(!expanded)} className="p-1 -m-1">
<ChevronRightIcon
className={`size-4 text-gray-500 ${expanded ? 'rotate-90' : ''}`}
/>
</button>
)}
{node.subPropertygroups ? (
<FolderIcon
className={`size-6 text-sky-500 ${
node.subPropertygroups.length === 0 ? 'ml-[22px]' : ''
}`}
/>
) : (
<DocumentIcon className="ml-[22px] size-6 text-gray-900" />
)}
{node.label}
</span>
{expanded && (
<ul className="pl-6">
{node.subPropertygroups?.map((node) => (
<PropertyTreeView node={node} key={node.id} />
))}
</ul>
)}
</li>
);
};
export default PropertyTreeView;
@@ -1,29 +0,0 @@
import {Tree} from 'react-arborist';
const TreeView = ({ data, setUpdate }) => {
return (
<Tree
initialData={data}
childrenAccessor="subPropertygroups"
width="200px"
openByDefault={true}
>
{Node}
</Tree>
);
};
const Node = ({ node, style, dragHandle, tree }) => {
console.log(node, tree);
return (
<div className="node-container" style={style} ref={dragHandle} onClick={() => {setUpdate(prev => !prev); node.toggle()}}>
{node.isLeaf ? "📄" : node.isOpen ? "📂" : "📁"}
{node.data.label}
</div>
);
};
export default TreeView;
@@ -1,3 +1,4 @@
:root {
--text: #6b6375;
--text-h: #08060d;
@@ -1,6 +1,7 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App.jsx'
createRoot(document.getElementById('root')).render(
@@ -5,15 +5,14 @@ import UseFetch from '../components/tools/UseFetch';
const PropertyPage = () => {
const { data: properties, isLoading, error } = UseFetch(`http://localhost:8088/propertygroup/1`)
const [update, setUpdate] = useState(false)
if (isLoading) return <p>Loading profile...</p>
if (error) return <p>Error: {error}</p>
return (
<div className="content">
<div><PropertySideBar properties={properties} setUpdate={setUpdate} /></div>
<div className="main"></div>
<div><PropertySideBar properties={[properties]} /></div>
<div className="main">{JSON.stringify(properties)}</div>
</div>
);
};
@@ -1,7 +1,8 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
plugins: [react(), tailwindcss()],
})