Skip to content

Commit

Permalink
Merge branch 'dev' into hotfix-optional-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
francisli committed Apr 4, 2024
2 parents 5cd04d9 + aaee521 commit 24b106d
Show file tree
Hide file tree
Showing 11 changed files with 208 additions and 86 deletions.
4 changes: 4 additions & 0 deletions client/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
'plugin:react-hooks/recommended',
'plugin:storybook/recommended',
'plugin:react/recommended',
'plugin:jsdoc/recommended',
'prettier',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
Expand All @@ -19,5 +20,8 @@ module.exports = {
'warn',
{ allowConstantExport: true },
],
'jsdoc/require-returns-description': 'off',
'jsdoc/require-param-description': 'off',
'jsdoc/require-returns': 'off',
},
};
1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@vitejs/plugin-react-swc": "^3.6.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsdoc": "^48.2.1",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
Expand Down
3 changes: 3 additions & 0 deletions client/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import Index from './pages';
import Login from './pages/login';
import NavBar from './components/NavBar';

/**
* Top-level application component.
*/
function App() {
return (
<>
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/NavBar.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react';

/**
* Primary navigation component.
*/
function NavBar() {
return (
<nav>
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import React from 'react';
import { useQuery } from '@tanstack/react-query';

/**
* Home page component.
*/
function Index() {
const { isFetching, error } = useQuery({
queryKey: ['users'],
Expand Down
3 changes: 3 additions & 0 deletions client/src/pages/login.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import React from 'react';

/**
* Login page component.
*/
function Login() {
return <div>Login page works</div>;
}
Expand Down
5 changes: 4 additions & 1 deletion client/src/stories/Button/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import './button.css';

/**
* Primary UI component for user interaction
* @param {PropTypes.InferProps<typeof ButtonProps> & React.ButtonHTMLAttributes<HTMLButtonElement>} props extends HTMLButtonElement
*/
export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
const mode = primary
Expand All @@ -23,7 +24,7 @@ export const Button = ({ primary, backgroundColor, size, label, ...props }) => {
);
};

Button.propTypes = {
const ButtonProps = {
/**
* Is this the principal call to action on the page?
*/
Expand All @@ -46,6 +47,8 @@ Button.propTypes = {
onClick: PropTypes.func,
};

Button.propTypes = ButtonProps;

Button.defaultProps = {
backgroundColor: null,
primary: false,
Expand Down
9 changes: 7 additions & 2 deletions client/src/stories/Header/Header.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';

import { Button } from '../Button/Button';
import { Button } from '../Button/Button.jsx';
import './header.css';

/**
* Main Header
* @param {PropTypes.InferProps<typeof HeaderProps>} props MainHeader props
*/
export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (
<header>
<div className="storybook-header">
Expand Down Expand Up @@ -55,7 +59,7 @@ export const Header = ({ user, onLogin, onLogout, onCreateAccount }) => (
</header>
);

Header.propTypes = {
const HeaderProps = {
user: PropTypes.shape({
name: PropTypes.string.isRequired,
}),
Expand All @@ -64,6 +68,7 @@ Header.propTypes = {
onCreateAccount: PropTypes.func.isRequired,
};

Header.propTypes = HeaderProps;
Header.defaultProps = {
user: null,
};
11 changes: 8 additions & 3 deletions client/src/stories/Page/Page.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import React from 'react';

import { Header } from '../Header/Header';
import { Header } from '../Header/Header.jsx';
import './page.css';

/**
* Storybook demo page component.
* @typedef User
* @property {string} name Full name of the User.
*/
export const Page = () => {
const [user, setUser] = React.useState();
const [user, setUser] = React.useState(/** @type {?User} */ (null));

return (
<article>
<Header
user={user}
onLogin={() => setUser({ name: 'Jane Doe' })}
onLogout={() => setUser(undefined)}
onLogout={() => setUser(null)}
onCreateAccount={() => setUser({ name: 'Jane Doe' })}
/>

Expand Down
9 changes: 9 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
// "checkJs": true,
"jsx": "react",
"noImplicitAny": false,
"strictNullChecks": true
},
"exclude": ["node_modules", "**/node_modules/*"]
}
Loading

0 comments on commit 24b106d

Please sign in to comment.