summaryrefslogtreecommitdiff
path: root/client/src/routes/app/components/content/content.jsx
diff options
context:
space:
mode:
authorLieuwe Rooijakkers <lieuwerooijakkers@gmail.com>2025-01-19 22:21:32 +0100
committerLieuwe Rooijakkers <lieuwerooijakkers@gmail.com>2025-01-19 22:21:46 +0100
commit93552152be180766fda08b1bd7ccefc4d26065ff (patch)
treef9f1e19372995729adc7e1c79f16c27acd9625be /client/src/routes/app/components/content/content.jsx
parent6841765fcbfadbd4e3006f5fbcea45194c92e5a1 (diff)
client advancements
Diffstat (limited to 'client/src/routes/app/components/content/content.jsx')
-rw-r--r--client/src/routes/app/components/content/content.jsx32
1 files changed, 32 insertions, 0 deletions
diff --git a/client/src/routes/app/components/content/content.jsx b/client/src/routes/app/components/content/content.jsx
new file mode 100644
index 0000000..42ecb8a
--- /dev/null
+++ b/client/src/routes/app/components/content/content.jsx
@@ -0,0 +1,32 @@
+import {useLayoutEffect, useRef, useState} from 'react';
+
+import './content.css';
+
+import Entry from '../../../../components/entry';
+
+export default function Content({ title, setTitle, items, setItems }) {
+ const [focused, setFocused] = useState(null);
+
+ const children = items.map((item, i) => {
+ return <Entry
+ item={item}
+ isFocused={i === focused}
+ onSelect={delta => setFocused(i + delta)}
+ onRemove={refocus => setItems(a => {
+ if (refocus) {
+ setFocused(i-1);
+ }
+ return [...a.slice(0, i), ...a.slice(i + 1)]
+ })}
+ onEnter={type => setItems(a => {
+ setFocused(i+1);
+ return a.toSpliced(i+1, 0, { type, text: '' });
+ })}
+ />;
+ });
+
+ return <div className="content">
+ <h1 className='title' contentEditable="true">{title}</h1>
+ {children}
+ </div>;
+}