-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create skeleton for component hierarchy with page layout (#184)
- Loading branch information
Sean Scully
authored and
Sean Scully
committed
Feb 5, 2024
1 parent
7bfc8d7
commit af32c07
Showing
9 changed files
with
59 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
import { QueryClient, QueryClientProvider } from 'react-query'; | ||
import { HelloWorld } from './components/HelloWorld/HelloWorld.tsx'; | ||
import styles from './app.module.css' | ||
|
||
const queryClient = new QueryClient(); | ||
import { Route, Routes } from "react-router-dom"; | ||
import { HelloWorld } from "./components/HelloWorld"; | ||
import { PageNotFound } from "./pages/PageNotFound"; | ||
import { PageLayout } from "./pages/PageLayout"; | ||
import styles from "./app.module.css"; | ||
|
||
function App() { | ||
return (<QueryClientProvider client={queryClient}> | ||
<section data-testid="app" className={styles.app}> | ||
<HelloWorld /> | ||
</section> | ||
</QueryClientProvider>); | ||
return ( | ||
<div className={styles.app} role="main"> | ||
<Routes> | ||
<Route element={<PageLayout />}> | ||
<Route path="/" element={<HelloWorld />} /> | ||
<Route path="*" element={<PageNotFound />} /> | ||
</Route> | ||
</Routes> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
17 changes: 9 additions & 8 deletions
17
packages/frontend-design-poc/src/components/HelloWorld/HelloWorld.tsx
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,11 +1,12 @@ | ||
import styles from './helloWorld.module.css'; | ||
import { useQuery } from 'react-query'; | ||
import { getUser } from '../../api/queries.ts'; | ||
import styles from "./helloWorld.module.css"; | ||
import { useQuery } from "react-query"; | ||
import { getUser } from "../../api/queries.ts"; | ||
|
||
export const HelloWorld = () => { | ||
const { isLoading, data } = useQuery('user', getUser); | ||
|
||
return (<section className={styles.helloWorld}> | ||
const { isLoading, data } = useQuery("user", getUser); | ||
return ( | ||
<section className={styles.helloWorld}> | ||
{isLoading ? <span>Loading ...</span> : <h1>Hello, {data?.name}!</h1>} | ||
</section>); | ||
}; | ||
</section> | ||
); | ||
}; |
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 @@ | ||
export { HelloWorld } from "./HelloWorld.tsx"; |
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,17 +1,27 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import App from './App.tsx'; | ||
import React from "react"; | ||
import ReactDOM from "react-dom/client"; | ||
import App from "./App.tsx"; | ||
import { QueryClient, QueryClientProvider } from "react-query"; | ||
import { BrowserRouter } from "react-router-dom"; | ||
|
||
async function enableMocking() { | ||
if (import.meta.env.MODE === 'development') { | ||
const { worker } = await import('./mocks/browser'); | ||
if (import.meta.env.MODE === "development") { | ||
const { worker } = await import("./mocks/browser"); | ||
return worker.start(); | ||
} | ||
} | ||
|
||
const root = ReactDOM.createRoot(document.getElementById("root")!); | ||
const queryClient = new QueryClient(); | ||
|
||
enableMocking().then(() => { | ||
ReactDOM.createRoot(document.getElementById('root')!).render(<React.StrictMode> | ||
<App /> | ||
</React.StrictMode>); | ||
root.render( | ||
<React.StrictMode> | ||
<QueryClientProvider client={queryClient}> | ||
<BrowserRouter> | ||
<App /> | ||
</BrowserRouter> | ||
</QueryClientProvider> | ||
</React.StrictMode>, | ||
); | ||
}); | ||
|
20 changes: 2 additions & 18 deletions
20
packages/frontend-design-poc/src/pages/PageLayout/PageLayout.tsx
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,7 @@ | ||
export const PageNotFound = () => { | ||
return ( | ||
<div> | ||
<h1>Ooops... page not found :(</h1> | ||
</div> | ||
); | ||
}; |
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 @@ | ||
export { PageNotFound } from "./PageNotFound.tsx"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.