Skip to content

Commit 0c9a9c1

Browse files
feat: improve lining + popular openings
1 parent 4a6ded7 commit 0c9a9c1

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/components/Openings/EcoTreeView.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,16 @@ const TreeNode: React.FC<{
8989
style={{ marginLeft: `${(level + 1) * 20}px` }}
9090
>
9191
{/* Expand/collapse button */}
92-
{hasChildren && (
92+
{hasChildren ? (
9393
<button
9494
onClick={onToggle}
9595
className="mr-1 flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-xs text-secondary/70 hover:bg-secondary/10 hover:text-primary"
9696
>
9797
{isExpanded ? '−' : '+'}
9898
</button>
99+
) : (
100+
// Placeholder to keep alignment consistent for leaf nodes
101+
<span className="mr-1 h-3 w-3 flex-shrink-0" />
99102
)}
100103

101104
{/* Node content */}

src/lib/openings/ecoProcessor.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,25 @@ export function processEcoDatabase(ecoDatabase: EcoDatabase): {
7474
// Create popular openings list
7575
const popularOpenings: PopularOpening[] = []
7676

77+
const toSlug = (text: string) =>
78+
text
79+
.toLowerCase()
80+
.trim()
81+
.replace(/[^a-z0-9]+/g, '-')
82+
.replace(/(^-|-$)+/g, '')
83+
7784
POPULAR_OPENING_IDS.forEach((popularId) => {
7885
// Find opening in all sections
79-
const opening = allOpenings.find((o) => o.id === popularId.id)
86+
const opening = allOpenings.find(
87+
(o) => o.id === popularId.id || toSlug(o.name) === popularId.id,
88+
)
8089
if (opening) {
8190
const variation = popularId.variationId
82-
? opening.variations.find((v) => v.id === popularId.variationId)
91+
? opening.variations.find(
92+
(v) =>
93+
v.id === popularId.variationId ||
94+
toSlug(v.name) === popularId.variationId,
95+
)
8396
: undefined
8497

8598
popularOpenings.push({

0 commit comments

Comments
 (0)