Skip to content

Commit

Permalink
Add proptypes definition
Browse files Browse the repository at this point in the history
  • Loading branch information
Elanis committed Feb 8, 2024
1 parent c9ab01e commit 235e8f3
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 5 deletions.
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"astro": "^4.3.5",
"astro-i18next": "^1.0.0-beta.21",
"i18next": "^23.8.2",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-i18next": "^14.0.5"
Expand Down
10 changes: 8 additions & 2 deletions src/components/HomepageProject/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import './index.css';

import { useTranslation } from 'react-i18next';

import ProjectPropsType from '../../data/Project.propsType.js';

import './index.css';

export default function HomepageProject({ project }) {
const { t } = useTranslation("translation");

Expand Down Expand Up @@ -34,3 +36,7 @@ export default function HomepageProject({ project }) {
</div>
);
}

HomepageProject.propTypes = {
project: ProjectPropsType
};
13 changes: 10 additions & 3 deletions src/components/Sidebar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import './index.css';

import PropTypes from 'prop-types';
import { useTranslation } from 'react-i18next';

import ProjectPropsType from '../../data/Project.propsType.js';

import './index.css';

export default function ProjectList({ projects }) {
const { t } = useTranslation("translation");

Expand All @@ -26,4 +29,8 @@ export default function ProjectList({ projects }) {
<a className="sidebar-link" href="/privacy">{t('privacy.mainTitle')}</a>
</div>
);
}
}

ProjectList.propTypes = {
projects: PropTypes.arrayOf(ProjectPropsType).isRequired
};
16 changes: 16 additions & 0 deletions src/data/Project.propsType.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import PropTypes from 'prop-types';

const ProjectPropsType = PropTypes.shape({
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
links: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string.isRequired,
icon: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
})).isRequired,
hasLogo: PropTypes.bool.isRequired,
inSidebar: PropTypes.bool.isRequired,
screenshots: PropTypes.number.isRequired,
});

export default ProjectPropsType;
2 changes: 2 additions & 0 deletions src/data/projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
"url": "https://achieve.games"
}
],
"inSidebar": false,
"hasLogo": false,
"screenshots": 1
},
Expand All @@ -108,6 +109,7 @@
"url": "https://dehash.me"
}
],
"inSidebar": false,
"hasLogo": false,
"screenshots": 1
}
Expand Down

0 comments on commit 235e8f3

Please sign in to comment.