Skip to content

Commit

Permalink
[chore] initial TypeScript setup and migration
Browse files Browse the repository at this point in the history
- Set up TypeScript configuration and dependencies
- Converted all JS files to TS files
- Temporarily resolved type issues using 'any'
  • Loading branch information
barrystone committed Jul 23, 2024
1 parent ed34326 commit f340ef6
Show file tree
Hide file tree
Showing 30 changed files with 10,594 additions and 4,445 deletions.
34 changes: 19 additions & 15 deletions components/AboutSection.js → components/AboutSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ const AboutSection = () => {
}, []);

const aboutAnimation = () => {
const skillsetClasslist = document.querySelector('.skillset').classList;
const skillsetElement = document.querySelector('.skillset');
const skillsetClasslist = skillsetElement
? skillsetElement.classList
: null;

const enterAnimation = () => {
const aboutElement = document
.getElementById('aboutSection')
?.getBoundingClientRect();
if (
aboutElement?.top >= 0 - aboutElement?.height / 4 &&
aboutElement?.top <=
window.innerHeight - aboutElement?.height + aboutElement?.height / 4
aboutElement && // Add null check for aboutElement
aboutElement.top >= 0 - aboutElement.height / 4 &&
aboutElement.top <=
window.innerHeight - aboutElement.height + aboutElement.height / 4
) {
window.requestAnimationFrame(() => {
skillsetClasslist.add('skillset--show');
skillsetClasslist?.add('skillset--show');
});

window.removeEventListener('scroll', enterAnimation);
Expand All @@ -31,38 +35,38 @@ const AboutSection = () => {
window.addEventListener('scroll', enterAnimation);

// skillSet title hover animation
document.getElementById('skill').addEventListener('mouseleave', () => {
document.getElementById('skill')?.addEventListener('mouseleave', () => {
window.requestAnimationFrame(() => {
skillsetClasslist.add('skillset--show');
skillsetClasslist?.add('skillset--show');
});
});
document.getElementById('skill').addEventListener('mouseover', () => {
skillsetClasslist.remove('skillset--show');
document.getElementById('skill')?.addEventListener('mouseover', () => {
skillsetClasslist?.remove('skillset--show');
});

// projectContent title
const projectContentTitle = document.getElementById('collects');
projectContentTitle.addEventListener('click', () => {
projectContentTitle?.addEventListener('click', () => {
window.open('https://github.com/barrystone', '_blank');
});
projectContentTitle.addEventListener('mouseover', () => {
projectContentTitle?.addEventListener('mouseover', () => {
projectContentTitle.innerHTML = 'Github';
});
projectContentTitle.addEventListener('mouseleave', () => {
projectContentTitle?.addEventListener('mouseleave', () => {
projectContentTitle.innerHTML = '我的作品';
projectContentTitle.style.cursor = 'pointer';
});
};

const screwsRotate = () => {
const rotete = (id) => {
const rotete = (id: any) => {
const screws = document.querySelectorAll('.section-about__screwbox');
document.getElementById(id).addEventListener('mouseover', () => {
document.getElementById(id)?.addEventListener('mouseover', () => {
for (let screw of screws) {
screw.classList.add('section-about__screwbox--rotate');
}
});
document.getElementById(id).addEventListener('mouseleave', () => {
document.getElementById(id)?.addEventListener('mouseleave', () => {
for (let screw of screws) {
screw.classList.remove('section-about__screwbox--rotate');
}
Expand Down
11 changes: 6 additions & 5 deletions components/NoteSection.js → components/NoteSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
import analyzeReadme from '../utils/analyzeReadme';

const NoteSection = () => {
const [notes, setNotes] = useState({});
const [notes, setNotes] = useState<{ [key: string]: any }>({});

useEffect(() => {
fetchNotes();
Expand All @@ -23,7 +23,7 @@ const NoteSection = () => {
const serverSideData = await res.json();
setNotes(serverSideData.analyzedData);
}
} catch (err) {
} catch (err: any) {
console.log('error', err.message);
}
};
Expand All @@ -47,7 +47,7 @@ const NoteSection = () => {
<p>{e}</p>
</div>
<ul key={idx}>
{notes[e].splice(0, listNotes).map((f, index) => (
{notes[e].splice(0, listNotes).map((f: any, index: any) => (
<li
key={index}
className={
Expand All @@ -57,18 +57,19 @@ const NoteSection = () => {
''
}
>
<a href={Object.values(f)} target="_blank">
<a href={Object.values(f).toString()} target="_blank">
{Object.keys(f)}
</a>
</li>
))}

{notes[e].length > 0 ? (
<li
style={{
listStyle: 'none',
letterSpacing: '.3rem',
fontSize: '1.8rem',
marginTop: '-1.5rem'
marginTop: '-1.5rem',
}}
>
...
Expand Down
4 changes: 2 additions & 2 deletions components/RepoSection.js → components/RepoSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import languageImg from '../utils/languageImg';

// import ReposDataTesting from '../_data/reposData_210524.json';

const RepoSection = ({ reposData: staticReposData }) => {
const RepoSection = ({ reposData: staticReposData }: { reposData: any[] }) => {
const sliderSettings = {
dots: false,
infinite: true,
Expand All @@ -16,7 +16,7 @@ const RepoSection = ({ reposData: staticReposData }) => {
autoplaySpeed: 3000,
};

const [reposData, setReposData] = useState([]);
const [reposData, setReposData] = useState<any[]>([]);
const [RwdSlideSettings, setRwdSlideSettings] = useState(sliderSettings);

const onRwdSlideSettings = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const ResumeLinkTemplate = ({
achievementData,
language,
projectsSource: { startElement, elementField },
}) => {
}: any) => {
const projectFields = projectsData[0];
const projects = projectsData.slice(1);
const achievements = achievementData.slice(1);
Expand Down Expand Up @@ -51,9 +51,11 @@ const ResumeLinkTemplate = ({
</Head>
<div className="resumelinks">
<div className="switchLang">
<Link href={switchLangURL} as={process.env.BACKEND_URL}>
{switchLangTitle}
</Link>
{switchLangURL && (
<Link href={switchLangURL} as={process.env.BACKEND_URL}>
{switchLangTitle}
</Link>
)}
</div>
<div className="github">
<span>{githubTitle}</span>
Expand All @@ -69,7 +71,7 @@ const ResumeLinkTemplate = ({
<section>
<h2>{projectsTitle}</h2>
<ul>
{projects.map((e, idx) => (
{projects.map((e: any, idx: any) => (
<li>
<img src={e[4]} alt="" className="projectimg" />
<br />
Expand All @@ -81,7 +83,7 @@ const ResumeLinkTemplate = ({
</span>
<br />
{/* project fields */}
{e.slice(1).map((field, index) =>
{e.slice(1).map((field: any, index: any) =>
field && index < 3 ? (
<div className="projectfield">
{/* project field */}
Expand Down Expand Up @@ -113,7 +115,7 @@ const ResumeLinkTemplate = ({
<section>
<h2>{achievementsTitle}</h2>
<ul>
{achievements.map((e) => (
{achievements.map((e: any) => (
<li>
{/* 中文[0] or EN[2] elementField */}
<span>{e[elementField]}:</span>
Expand Down
File renamed without changes.
192 changes: 0 additions & 192 deletions components/VirtualSpaceScene.js

This file was deleted.

Loading

0 comments on commit f340ef6

Please sign in to comment.