Browse Source

shipbuilding: improve formatting

raylu 1 tuần trước cách đây
mục cha
commit
dcbde38fb7
2 tập tin đã thay đổi với 14 bổ sung9 xóa
  1. 10 9
      ts/shipbuilding.ts
  2. 4 0
      www/style.css

+ 10 - 9
ts/shipbuilding.ts

@@ -135,17 +135,18 @@ function renderAnalysis(nodes: AnalysisNode[]): HTMLElement {
 }
 
 function renderAnalysisNode(node: AnalysisNode, level = 0): HTMLElement {
+	let el;
 	if (node.children.length === 0) {
-		const div = element('div', {textContent: node.text, className: 'analysis-node'});
-		return div;
+		el = element('div', {textContent: node.text, className: 'analysis-node'});
+	} else {
+		el = element('details', {className: 'analysis-node', open: true});
+		el.append(element('summary', {textContent: node.text}));
+		for (const child of node.children)
+			el.append(renderAnalysisNode(child, level + 1));
 	}
-	const details = element('details', {className: 'analysis-node'});
-	details.open = true;
-	const summary = element('summary', {textContent: node.text});
-	details.append(summary);
-	for (const child of node.children)
-		details.append(renderAnalysisNode(child, level + 1));
-	return details;
+	if (level === 0)
+		el.classList.add('root');
+	return el;
 }
 
 function renderProduction(expertiseGroups: Record<string, string[]>, production: Production,

+ 4 - 0
www/style.css

@@ -161,6 +161,10 @@ main.shipbuilding {
 	.analysis-node {
 		padding-left: 40px;
 	}
+	.analysis-node.root {
+		margin-top: 2em;
+		padding-left: 0;
+	}
 	div.building-row > div {
 		display: inline-block;
 		margin-left: 10px;