|
1 | 1 | import {renderer} from "./project-data-cube.ts";
|
2 | 2 |
|
3 |
| -export type OutsideLink = [ |
4 |
| - name: string, |
5 |
| - path: string, |
6 |
| -] |
7 |
| - |
8 |
| -export type LinkCollection = [ |
9 |
| - title: string, |
10 |
| - links: OutsideLink[], |
11 |
| -] |
12 | 3 |
|
13 |
| -export type LinkButton = [ |
| 4 | +export type ButtonLink = [ |
14 | 5 | label: string,
|
| 6 | + path: string, |
| 7 | + highlight: boolean, |
15 | 8 | ]
|
16 | 9 |
|
17 | 10 | //-----------------------------------------------------------------------
|
18 | 11 |
|
19 |
| -export function projectInfo(collections: LinkCollection[], buttons: LinkButton[]) { |
| 12 | +export function projectInfo(buttons: ButtonLink[]) { |
20 | 13 | const container = document.createElement('div');
|
| 14 | + const buttonList = document.createElement('ul'); |
| 15 | + |
21 | 16 | container.className = "project-info";
|
| 17 | + buttonList.className = "button-list"; |
22 | 18 | container.appendChild(dataSection());
|
23 |
| - |
24 |
| - collections.forEach(collection => { |
25 |
| - const [title, links] = collection; |
26 |
| - container.appendChild(linkSection(title, links)); |
27 |
| - }) |
| 19 | + container.appendChild(buttonList); |
28 | 20 |
|
29 | 21 | buttons.forEach(button => {
|
30 |
| - const [label] = button; |
31 |
| - container.appendChild(buttonSection(label)); |
| 22 | + buttonList.appendChild(createButton(button)); |
32 | 23 | })
|
33 | 24 |
|
34 | 25 | return container;
|
35 | 26 | }
|
36 | 27 |
|
37 | 28 | //-----------------------------------------------------------------------
|
38 | 29 |
|
39 |
| -function linkSection(title: string, links: OutsideLink[]) { |
40 |
| - const section = document.createElement('section'); |
41 |
| - const sectionTitle = document.createElement("h4"); |
42 |
| - const linkList = document.createElement('ul'); |
43 |
| - |
44 |
| - sectionTitle.textContent = title; |
45 |
| - |
46 |
| - section.appendChild(sectionTitle); |
47 |
| - section.appendChild(linkList); |
48 |
| - |
49 |
| - links.forEach(link => { |
50 |
| - const [name, path] = link; |
51 |
| - const linkLine = document.createElement('li'); |
52 |
| - const linkElement = document.createElement("a"); |
53 |
| - |
54 |
| - linkElement.href = path; |
55 |
| - linkElement.target = "_blank"; |
56 |
| - linkElement.textContent = name; |
57 |
| - |
58 |
| - linkList.appendChild(linkLine); |
59 |
| - linkLine.appendChild(linkElement); |
60 |
| - }) |
61 |
| - |
62 |
| - return section; |
63 |
| -} |
64 | 30 |
|
65 |
| -function buttonSection(label: string) { |
66 |
| - const section = document.createElement('section'); |
67 |
| - const buttonLine = document.createElement('button'); |
| 31 | +function createButton(newButton: ButtonLink) { |
| 32 | + const btn = document.createElement('li'); |
| 33 | + const btnLine = document.createElement('a'); |
| 34 | + const [label, path, highlight] = newButton; |
68 | 35 |
|
69 |
| - buttonLine.type = "button"; |
70 |
| - buttonLine.textContent = label; |
| 36 | + if (highlight) { |
| 37 | + btn.className = "btn-highlight"; |
| 38 | + } |
71 | 39 |
|
72 |
| - section.appendChild(buttonLine); |
| 40 | + btnLine.type = "button"; |
| 41 | + btnLine.textContent = label; |
| 42 | + btnLine.href = path; |
| 43 | + btnLine.target = "_blank"; |
73 | 44 |
|
74 |
| - return section; |
| 45 | + btn.appendChild(btnLine); |
| 46 | + return btn; |
75 | 47 | }
|
76 | 48 |
|
77 | 49 | function dataSection() {
|
78 | 50 | const detailSection = document.createElement("section");
|
79 | 51 | const detailTitle = document.createElement("h4");
|
80 |
| - detailTitle.textContent = "Tech Distribution"; |
| 52 | + detailTitle.textContent = "Made with"; |
81 | 53 |
|
82 | 54 | detailSection.appendChild(detailTitle);
|
83 | 55 | detailSection.appendChild(renderer.domElement);
|
|
0 commit comments