diff --git a/src/App.tsx b/src/App.tsx index f587aebf0..ca8eb676b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,56 +1,38 @@ import 'bulma/css/bulma.css'; import '@fortawesome/fontawesome-free/css/all.css'; import './App.scss'; +import { Outlet, NavLink } from 'react-router-dom'; +import classNames from 'classnames'; -// const tabs = [ -// { id: 'tab-1', title: 'Tab 1', content: 'Some text 1' }, -// { id: 'tab-2', title: 'Tab 2', content: 'Some text 2' }, -// { id: 'tab-3', title: 'Tab 3', content: 'Some text 3' }, -// ]; +const getLinkClass = ({ isActive }: { isActive: boolean }) => + classNames('navbar-item', { + 'is-active': isActive, + }); export const App = () => ( <> - {/* Also requires */} - - -
-
-

Home page

-

Tabs page

-

Page not found

- -
- + + -
- Please select a tab +
+
+
-
+ ); diff --git a/src/Root.tsx b/src/Root.tsx new file mode 100644 index 000000000..7381d8fb9 --- /dev/null +++ b/src/Root.tsx @@ -0,0 +1,25 @@ +import { HashRouter, Navigate } from 'react-router-dom'; +import { App } from './App'; +import { Route, Routes } from 'react-router-dom'; +import { Tabs } from './pages/Tabs'; +import { Home } from './pages/Home'; +import { NotFound } from './pages/NotFound'; + +export const Root = () => { + return ( + + + }> + } /> + } /> + + + } /> + + + } /> + + + + ); +}; diff --git a/src/constants/tabs.ts b/src/constants/tabs.ts new file mode 100644 index 000000000..1f1650725 --- /dev/null +++ b/src/constants/tabs.ts @@ -0,0 +1,5 @@ +export const tabs = [ + { id: 'tab-1', title: 'Tab 1', content: 'Some text 1' }, + { id: 'tab-2', title: 'Tab 2', content: 'Some text 2' }, + { id: 'tab-3', title: 'Tab 3', content: 'Some text 3' }, +]; diff --git a/src/index.tsx b/src/index.tsx index 53697a9fb..35dd772f7 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,9 +1,6 @@ import { createRoot } from 'react-dom/client'; -import { HashRouter } from 'react-router-dom'; -import { App } from './App'; +import { Root } from './Root'; -createRoot(document.getElementById('root') as HTMLElement).render( - - - , -); +const container = document.getElementById('root') as HTMLElement; + +createRoot(container).render(); diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx new file mode 100644 index 000000000..78229fbeb --- /dev/null +++ b/src/pages/Home.tsx @@ -0,0 +1,5 @@ +export const Home = () => ( +
+

Home page

+
+); diff --git a/src/pages/NotFound.tsx b/src/pages/NotFound.tsx new file mode 100644 index 000000000..e55f6bcfa --- /dev/null +++ b/src/pages/NotFound.tsx @@ -0,0 +1,5 @@ +export const NotFound = () => ( +
+

Page not found

+
+); diff --git a/src/pages/Tabs.tsx b/src/pages/Tabs.tsx new file mode 100644 index 000000000..8933df91a --- /dev/null +++ b/src/pages/Tabs.tsx @@ -0,0 +1,30 @@ +import { Link, useParams } from 'react-router-dom'; +import { tabs } from '../constants/tabs'; + +export const Tabs = () => { + const { tabId } = useParams(); + const selectedTab = tabs.find(tab => tab.id === tabId); + + return ( +
+

Tabs page

+
+
    + {tabs.map(tab => ( +
  • + {tab.title} +
  • + ))} +
+
+ +
+ {selectedTab ? selectedTab.content : 'Please select a tab'} +
+
+ ); +};