-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ruihang Xia <[email protected]>
- Loading branch information
Showing
5 changed files
with
91 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
function Timeline({ list, currentTimelineHighlight, handleScroll, endYear }) { | ||
const table = Array.from({ length: endYear }).map((_, _index) => { return { color1: 'inactive', color2: 'inactive', should_show_year: false } }) | ||
|
||
if (list.length === 0) | ||
return 'loading' | ||
|
||
for (let curr_index = 0; curr_index < list.length; curr_index++) { | ||
for (let i = list[curr_index].from; i <= list[curr_index].to; i++) { | ||
if (curr_index % 2 === 0) { | ||
table[i].color1 = 'left' | ||
if (table[i].color2 !== 'right') | ||
table[i].color2 = 'white' | ||
} | ||
else { | ||
table[i].color2 = 'right' | ||
if (table[i].color1 !== 'left') | ||
table[i].color1 = 'white' | ||
} | ||
} | ||
table[list[curr_index].from].should_show_year = true | ||
table[list[curr_index].to].should_show_year = true | ||
} | ||
table[0].should_show_year = true | ||
table[currentTimelineHighlight].color1 = 'highlight' | ||
table[currentTimelineHighlight].color2 = 'highlight' | ||
|
||
return ( | ||
<div className="timeline" onScroll={handleScroll}> | ||
<h3 className="sticky">Timeline</h3> | ||
<h3> - </h3> | ||
<div> | ||
<table> | ||
<tbody> | ||
{Array.from({ length: 1000 }).map((_, index) => ( | ||
<tr key={index}> | ||
<td className={table[index].color1} /> | ||
<td className={table[index].color2} /> | ||
<td> | ||
{' '} | ||
{table[index].should_show_year ? index : '' } | ||
{' '} | ||
</td> | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Timeline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { defineConfig } from 'vite' | ||
import UnoCSS from 'unocss/vite' | ||
import react from '@vitejs/plugin-react-swc' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react()], | ||
plugins: [react(), UnoCSS()], | ||
}) |