Skip to content

Commit

Permalink
[frontend] Split AppNavigation from App
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Aug 31, 2024
1 parent 2618e81 commit 10b7e38
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 16 deletions.
15 changes: 15 additions & 0 deletions packages/frontend/__tests__/components/AppNavigation.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { render } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";

import { AppNavigation } from "../../src/components/AppNavigation";

describe("AppNavigation component", () => {
test("should render correctly", () => {
const { container } = render(
<MemoryRouter>
<AppNavigation />
</MemoryRouter>,
);
expect(container.firstChild).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AppNavigation component should render correctly 1`] = `
.emotion-0 {
list-style: none;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
margin-bottom: 24px;
padding: 0 16px;
border-bottom: 1px solid #294885;
}
.emotion-1 {
display: block;
padding: 0.2em 0.8em;
margin-bottom: -1px;
border: 1px solid transparent;
border-radius: 5px 5px 0 0;
}
.emotion-1.active {
border-top: 1px solid #294885;
border-right: 1px solid #294885;
border-left: 1px solid #294885;
background-color: #fff;
}
<nav>
<div
class="emotion-0"
>
<a
aria-current="page"
class="emotion-1 active"
href="/"
>
Poptávky
</a>
<a
class="emotion-1"
href="/projekty"
>
Projekty
</a>
</div>
</nav>
`;
17 changes: 1 addition & 16 deletions packages/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,14 @@ import useSWR from "swr";

import type { ProjectListings } from "./interfaces/ProjectListings";

import { AppNavigation } from "./components/AppNavigation";
import { Container } from "./components/Container";
import { Navigation } from "./components/Navigation";
import { config } from "./config";
import { IssueDetail } from "./pages/IssueDetail";
import { IssuesList } from "./pages/IssuesList";
import { ProjectDetail } from "./pages/ProjectDetail";
import { ProjectsList } from "./pages/ProjectsList";

const AppNavigation = (): React.JSX.Element => (
<Navigation
items={[
{
link: "/",
title: "Poptávky",
},
{
link: "/projekty",
title: "Projekty",
},
]}
/>
);

export const App = (): React.JSX.Element => {
const { data, error } = useSWR<ProjectListings, unknown>(
config.dataApiUrl,
Expand Down
18 changes: 18 additions & 0 deletions packages/frontend/src/components/AppNavigation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type React from "react";

import { Navigation } from "./Navigation";

export const AppNavigation = (): React.JSX.Element => (
<Navigation
items={[
{
link: "/",
title: "Poptávky",
},
{
link: "/projekty",
title: "Projekty",
},
]}
/>
);

0 comments on commit 10b7e38

Please sign in to comment.