Skip to content

Commit

Permalink
Merge pull request #26 from genomic-medicine-sweden/add-frontend-app
Browse files Browse the repository at this point in the history
Add Base React App with Ant Design UI Library and React Router v6
  • Loading branch information
moedarrah authored Sep 9, 2024
2 parents 24a5ebd + 3111f09 commit 0b77980
Show file tree
Hide file tree
Showing 23 changed files with 2,529 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
test.py
__pycache__/
*.csv
node_modules
24 changes: 24 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
14 changes: 14 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Metagenomic Visualization

Welcome to the **Meta Vis**. This application provides an interactive platform for visualizing results from metagenomic analysis.

**Note**: This README is for the front-end application.

The front-end is built using the following technologies:

- **React**: A popular JavaScript library for building user interfaces, allowing for the creation of reusable components and a responsive user experience.
- **Vite**: A modern build tool that offers fast development and optimized production builds, enhancing the development experience with instant hot module replacement and quick builds.
- **TypeScript**: A statically typed superset of JavaScript that improves code quality and maintainability through type checking and advanced editor features.
- **Ant Design (antd)**: A comprehensive design system and UI component library that provides a set of high-quality React components out-of-the-box, facilitating the creation of a consistent and professional user interface.

---
28 changes: 28 additions & 0 deletions frontend/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'

export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
)
13 changes: 13 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/meta-vis-logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Meta Vis</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
34 changes: 34 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "meta-vis",
"private": false,
"license": "MIT",
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.26.1"
},
"devDependencies": {
"@types/react-router-dom": "^5.3.3",
"@ant-design/icons": "^5.4.0",
"@eslint/js": "^9.9.0",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.1",
"antd": "^5.20.5",
"eslint": "^9.9.0",
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.9",
"globals": "^15.9.0",
"typescript": "^5.5.3",
"typescript-eslint": "^8.0.1",
"vite": "^5.4.1"
}
}
1 change: 1 addition & 0 deletions frontend/public/meta-vis-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added frontend/src/App.css
Empty file.
8 changes: 8 additions & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

import './App.css';
import { AppRouter } from './routes/AppRouter';
export const App = () => {
return (
<AppRouter />
);
};
26 changes: 26 additions & 0 deletions frontend/src/appLayout/AppLayout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.header {
position: sticky;
top: 0;
z-index: 1;
width: 100%;
display: flex;
align-items: center;
}

.logo {
margin-right: 50px;
}

.logo img {
height: 50px;
}

.content {
padding: 24px;
min-height: calc(100vh - 108px);
padding-bottom: 0;
}

.footer {
text-align: center;
}
46 changes: 46 additions & 0 deletions frontend/src/appLayout/AppLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Layout, Menu } from 'antd';
import { Link, Outlet, useLocation } from 'react-router-dom';
import './AppLayout.css';

const { Header, Content, Footer } = Layout;

const appMenuItems = () => [
{
key: '/',
label: <Link to="/">Home</Link>,
},
{
key: '/about',
label: <Link to="/about">About</Link>,
}
];

export const AppLayout = () => {
const menuItems = appMenuItems();
const location = useLocation();

return (
<Layout>
<Header className="header">
<div className="logo">
<img src="/meta-vis-logo.svg" alt="logo" />
</div>
<Menu
theme="dark"
mode="horizontal"
items={menuItems}
style={{ flex: 1, minWidth: 0 }}
defaultSelectedKeys={[location.pathname]}
/>
</Header>
<Content className="content">
<div>
<Outlet /> {/* This is where your routed components will be rendered */}
</div>
</Content>
<Footer className="footer">
Meta Vis {new Date().getFullYear()}
</Footer>
</Layout>
);
};
1 change: 1 addition & 0 deletions frontend/src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added frontend/src/index.css
Empty file.
12 changes: 12 additions & 0 deletions frontend/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import {App} from './App.tsx'
import './index.css'
import 'antd/dist/reset.css';


createRoot(document.getElementById('root')!).render(
<StrictMode>
<App />
</StrictMode>,
)
5 changes: 5 additions & 0 deletions frontend/src/pages/About.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const About = () => {
return (
<div>About</div>
)
}
5 changes: 5 additions & 0 deletions frontend/src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const Home = () => {
return (
<div>Home</div>
)
}
20 changes: 20 additions & 0 deletions frontend/src/routes/AppRouter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createBrowserRouter, createRoutesFromElements, Route, RouterProvider } from 'react-router-dom';
import { Home } from '../pages/Home';
import { About } from '../pages/About';
import { AppLayout } from '../appLayout/AppLayout';


const router = createBrowserRouter(
createRoutesFromElements(
<Route element={<AppLayout />}>
<Route path="/" element={<Home />} />
<Route path="/about" element={<About />} />
<Route path="*" element={<div>404 Not Found</div>} />
</Route>
)
);


export const AppRouter = () => {
return <RouterProvider router={router} />;
};
1 change: 1 addition & 0 deletions frontend/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
24 changes: 24 additions & 0 deletions frontend/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}
Loading

0 comments on commit 0b77980

Please sign in to comment.