Skip to content

Commit 815f513

Browse files
committed
hide content if locked
1 parent f5867aa commit 815f513

2 files changed

Lines changed: 47 additions & 39 deletions

File tree

.changeset/swift-carrots-buy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@learningmap/learningmap": minor
3+
---
4+
5+
Hide content in the drawer if the node is locked

packages/learningmap/src/Drawer.tsx

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -105,56 +105,59 @@ export function Drawer({ open, onClose, onUpdate, node, nodes, onNodeClick, lang
105105
</button>
106106
</header>
107107
<div className="drawer-content">
108-
{node.data?.description && <div className="drawer-description" style={{ marginBottom: 16 }} dangerouslySetInnerHTML={{ __html: descriptionHtml }} />}
109-
{node.data?.video && <div className="drawer-video" style={{ marginBottom: 16 }}>
110-
<Video url={node.data?.video} />
111-
</div>}
112-
{node.data?.resources && node.data?.resources.length > 0 && (
113-
<div className="drawer-resources" style={{ marginBottom: 16 }}>
114-
<div style={{ fontWeight: 600, marginBottom: 8 }}>{t.resourcesLabel}</div>
115-
<ul>
116-
{node.data?.resources.map((r: Resource, idx: number) => {
117-
if (r.type === "book") {
118-
// Format: 📚 Label (Name, Location)
119-
// If name is empty, no comma should be visible
120-
const bookDetails = [];
121-
if (r.bookName) bookDetails.push(r.bookName);
122-
if (r.bookLocation) bookDetails.push(r.bookLocation);
123-
const detailsText = bookDetails.length > 0 ? ` (${bookDetails.join(', ')})` : '';
124-
125-
return (
126-
<li key={idx}>
127-
📚 <strong>{r.label}</strong>{detailsText}
128-
</li>
129-
);
130-
}
131-
return (
132-
<li key={idx}>
133-
🌐 {r.url ? (
134-
<a href={r.url} target="_blank" rel="noopener noreferrer">{r.label}</a>
135-
) : (
136-
<span>{r.label}</span>
137-
)}
138-
</li>
139-
);
140-
})}
141-
</ul>
142-
</div>
143-
)}
144-
{unlockConditions.length > 0 && (
108+
{unlockConditions.length > 0 ? (
145109
<div className="drawer-unlock-conditions" style={{ marginBottom: 16 }}>
146110
<div style={{ fontWeight: 600, marginBottom: 8 }}>{t.unlockConditionsMessage}</div>
147111
<ul>
148112
{unlockConditions.map(n => (
149113
<li key={n.id}>
150114
<button className="link-button" onClick={() => { onNodeClick(null, n, true); }}>
151-
{n.data?.label || n.id} - {n.data?.state}
115+
{n.data?.label || n.id} - {n.data?.state === "locked" ? "🔒" : "🔓"}
152116
</button>
153117
</li>
154118
))}
155119
</ul>
156120
</div>
157-
)}
121+
) :
122+
<>
123+
{node.data?.description && <div className="drawer-description" style={{ marginBottom: 16 }} dangerouslySetInnerHTML={{ __html: descriptionHtml }} />}
124+
{node.data?.video && <div className="drawer-video" style={{ marginBottom: 16 }}>
125+
<Video url={node.data?.video} />
126+
</div>}
127+
{node.data?.resources && node.data?.resources.length > 0 && (
128+
<div className="drawer-resources" style={{ marginBottom: 16 }}>
129+
<div style={{ fontWeight: 600, marginBottom: 8 }}>{t.resourcesLabel}</div>
130+
<ul>
131+
{node.data?.resources.map((r: Resource, idx: number) => {
132+
if (r.type === "book") {
133+
// Format: 📚 Label (Name, Location)
134+
// If name is empty, no comma should be visible
135+
const bookDetails = [];
136+
if (r.bookName) bookDetails.push(r.bookName);
137+
if (r.bookLocation) bookDetails.push(r.bookLocation);
138+
const detailsText = bookDetails.length > 0 ? ` (${bookDetails.join(', ')})` : '';
139+
140+
return (
141+
<li key={idx}>
142+
📚 <strong>{r.label}</strong>{detailsText}
143+
</li>
144+
);
145+
}
146+
return (
147+
<li key={idx}>
148+
🌐 {r.url ? (
149+
<a href={r.url} target="_blank" rel="noopener noreferrer">{r.label}</a>
150+
) : (
151+
<span>{r.label}</span>
152+
)}
153+
</li>
154+
);
155+
})}
156+
</ul>
157+
</div>
158+
)}
159+
</>
160+
}
158161
{!locked && completionNeeds.length > 0 && (
159162
<div className="drawer-completion-needs" style={{ marginBottom: 16 }}>
160163
<div style={{ fontWeight: 600, marginBottom: 8 }}>{t.completionNeedsMessage}</div>

0 commit comments

Comments
 (0)