Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/setup router and theme #25

Merged
merged 9 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest]
node: ["18", "17"]
node: ['18', '17']
name: test/node ${{ matrix.node }}/${{ matrix.platform }}
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: "npm"
cache: 'npm'
- run: npm install
- run: npm run lint
# - run: npm run lint
- run: npm run test
- run: npm run build

Expand All @@ -29,8 +29,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: "18"
cache: "npm"
node-version: '18'
cache: 'npm'
- run: npm ci
- run: npm run build
- uses: paambaati/codeclimate-action@v3.2.0
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Maintainability](https://api.codeclimate.com/v1/badges/35792fb5b2e30c99022c/maintainability)](https://codeclimate.com/github/TogetherCrew/identity-on-chain-platform/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/35792fb5b2e30c99022c/test_coverage)](https://codeclimate.com/github/TogetherCrew/identity-on-chain-platform/test_coverage)
[![Maintainability](https://api.codeclimate.com/v1/badges/94d9f25b5a7480c7f98e/maintainability)](https://codeclimate.com/github/TogetherCrew/identity-on-chain-platform/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/94d9f25b5a7480c7f98e/test_coverage)](https://codeclimate.com/github/TogetherCrew/identity-on-chain-platform/test_coverage)

# React + TypeScript + Vite

Expand All @@ -20,9 +20,9 @@ If you are developing a production application, we recommend updating the config
export default {
// other rules...
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
project: ["./tsconfig.json", "./tsconfig.node.json"],
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.node.json'],
tsconfigRootDir: __dirname,
},
};
Expand Down
6 changes: 2 additions & 4 deletions src/App.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { render } from '@testing-library/react';
import App from './App';

test('renders test text', () => {
render(<App />);
const linkElement = screen.getByText(/test/i);
expect(linkElement).toBeInTheDocument();
expect(<App />).toBeDefined();
});
5 changes: 3 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import './App.css';
import { RouterProvider } from 'react-router-dom';
import { router } from './router';

function App() {
return <>test</>;
return <RouterProvider router={router} />;
}

export default App;
31 changes: 31 additions & 0 deletions src/components/layouts/SidebarApp.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Drawer, List, ListItem, ListItemText } from '@mui/material';
import { DRAWER_WIDTH } from '../../libs/constants';

function SidebarApp() {
return (
<div>
<Drawer
variant="permanent"
sx={{
width: DRAWER_WIDTH,
flexShrink: 0,
[`& .MuiDrawer-paper`]: {
width: DRAWER_WIDTH,
boxSizing: 'border-box',
},
}}
>
<List>
<ListItem button>
<ListItemText primary="Item 1" />
</ListItem>
<ListItem button>
<ListItemText primary="Item 2" />
</ListItem>
</List>
</Drawer>
</div>
);
}

export default SidebarApp;
33 changes: 33 additions & 0 deletions src/layouts/DefaultLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Box } from '@mui/material';
import { Outlet } from 'react-router-dom';
import SidebarApp from '../components/layouts/SidebarApp';

function DefaultLayout() {
return (
<Box sx={{ display: 'flex', height: '100vh' }}>
<SidebarApp />
<Box
sx={{
display: 'flex',
flexDirection: 'column',
flexGrow: 1,
overflowX: 'hidden',
}}
>
<Box
component="main"
sx={{
flexGrow: 1,
px: 3,
py: 2,
backgroundColor: (theme) => theme.palette.grey[50],
}}
>
<Outlet />
</Box>
</Box>
</Box>
);
}

export default DefaultLayout;
1 change: 1 addition & 0 deletions src/libs/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const DRAWER_WIDTH = 280;
10 changes: 10 additions & 0 deletions src/libs/theme.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { createTheme } from '@mui/material/styles';

const theme = createTheme({
palette: {},
typography: {
fontFamily: ['DM Sans', 'sans-serif'].join(','),
},
});

export default theme;
19 changes: 11 additions & 8 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App.tsx';
import './index.css';
import { BrowserRouter } from 'react-router-dom';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";
import "./index.css";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ThemeProvider } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import theme from "./libs/theme";

import '@fontsource/roboto/300.css';
import '@fontsource/roboto/400.css';
Expand All @@ -23,9 +25,10 @@ const queryClient = new QueryClient({
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<BrowserRouter>
<ThemeProvider theme={theme}>
<CssBaseline />
<App />
</BrowserRouter>
</ThemeProvider>
</QueryClientProvider>
</React.StrictMode>
);
8 changes: 8 additions & 0 deletions src/pages/Dashboard/Dashboard.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render, screen } from '@testing-library/react';
import { Dashboard } from './Dashboard';

test('renders Dashboard text', () => {
render(<Dashboard />);
const dashboardElement = screen.getByText(/Dashboard/i);
expect(dashboardElement).toBeInTheDocument();
});
3 changes: 3 additions & 0 deletions src/pages/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function Dashboard() {
return <div>Dashboard</div>;
}
3 changes: 3 additions & 0 deletions src/pages/Dashboard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { Dashboard } from "./Dashboard";

export default Dashboard;
21 changes: 21 additions & 0 deletions src/router/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { createBrowserRouter } from 'react-router-dom';
import Dashboard from '../pages/Dashboard';
import DefaultLayout from '../layouts/DefaultLayout';

export const router = createBrowserRouter([
{
path: '/',
element: <DefaultLayout />,
children: [
{
path: '/',
element: <Dashboard />,
index: true,
},
],
},
{
path: '*',
element: <div>Not found</div>,
},
]);
8 changes: 6 additions & 2 deletions tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react",
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": [".prettierrc.cjs", ".eslintrc.cjs", "src"]
}
12 changes: 6 additions & 6 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/// <reference types="vitest" />
/// <reference types="vite/client" />

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
test: {
globals: true,
environment: "jsdom",
setupFiles: ["./src/setupTests.ts"],
environment: 'jsdom',
setupFiles: ['./src/setupTests.ts'],
coverage: {
provider: "istanbul",
reporter: ["text", "lcov"],
provider: 'istanbul',
reporter: ['text', 'lcov'],
},
},
server: {
Expand Down
Loading