From f114e5c6e61b72724d978df8cab0a8ff585c1715 Mon Sep 17 00:00:00 2001 From: Aarni Halinen Date: Tue, 29 Dec 2020 20:22:50 +0200 Subject: [PATCH] Fix links --- src/components/AddLink.tsx | 3 ++- src/components/AdminSidebar.tsx | 18 ++++++++-------- src/components/Link.tsx | 24 ++++++++++++--------- src/components/NavbarChildLink.tsx | 2 +- src/components/NavbarDropdownLink.tsx | 1 + src/pages/index.tsx | 8 ++++++- src/views/ContactsPage/ContactsPageView.tsx | 2 +- tests/testcafe/admin.test.ts | 2 +- 8 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/components/AddLink.tsx b/src/components/AddLink.tsx index 6e3a0cc..aa2f195 100644 --- a/src/components/AddLink.tsx +++ b/src/components/AddLink.tsx @@ -2,6 +2,7 @@ import React, { ComponentProps } from "react"; import styled from "styled-components"; import { colors }from "@theme/colors"; import { Link } from "@components/index"; + const AddIcon = "/img/add-icon.png"; const StyledLink = styled(Link)` @@ -26,7 +27,7 @@ type AddLinkProps = ComponentProps & { } const AddLink: React.FC = ({ text, ...props }) => ( - + {text} diff --git a/src/components/AdminSidebar.tsx b/src/components/AdminSidebar.tsx index 0f41615..16d87be 100644 --- a/src/components/AdminSidebar.tsx +++ b/src/components/AdminSidebar.tsx @@ -20,7 +20,7 @@ const SideBar = styled.nav` } `; -const StyledLink = styled(Link)<{path: string}>` +const StyledLink = styled(Link)<{$path: string}>` padding: 1rem 3rem 1rem 1rem; letter-spacing: 3px; text-transform: uppercase; @@ -30,7 +30,7 @@ const StyledLink = styled(Link)<{path: string}>` color: ${colors.white}; border-left: 4px solid transparent; - ${p => p.path === p.to && ` + ${p => p.$path === p.to && ` border-left: 4px solid ${colors.white}; `} @@ -45,13 +45,13 @@ const StyledLink = styled(Link)<{path: string}>` const AdminSidebar: React.FC = ({ path }) => ( - Home › - Events › - Feed › - Signup forms › - Job advertisements › - Files › - Logout › + Home › + Events › + Feed › + Signup forms › + Job advertisements › + Files › + Logout › ); diff --git a/src/components/Link.tsx b/src/components/Link.tsx index 0969ff3..deb09d7 100644 --- a/src/components/Link.tsx +++ b/src/components/Link.tsx @@ -1,29 +1,33 @@ import React from "react"; import NextJSLink, { LinkProps } from "next/link"; -interface Props extends Omit { +interface Props extends Omit { + to: string; template?: string; - to: string; + target?: string; + onClick?: (event: React.MouseEvent) => void; + onMouseEnter?: (event: React.MouseEvent) => void; + onMouseLeave?: (event: React.MouseEvent) => void; } -interface Props extends React.HTMLAttributes { - to: string; -} - -const Link: React.FC = ({ to, template, ...props }) => { +const Link: React.FC = ({ to, template, passHref, onClick, onMouseEnter, onMouseLeave, ...props }) => { if (template) { return ( - + + + ) } if (to.startsWith("/") || to.startsWith("#")) { return ( - + + + ); } else { return ( - + ); } } diff --git a/src/components/NavbarChildLink.tsx b/src/components/NavbarChildLink.tsx index b665126..bd2dc02 100644 --- a/src/components/NavbarChildLink.tsx +++ b/src/components/NavbarChildLink.tsx @@ -29,7 +29,7 @@ const StyledLink = styled(Link)` `; const NavbarChildLink: React.FC = (props) => ( - + ) export default NavbarChildLink; diff --git a/src/components/NavbarDropdownLink.tsx b/src/components/NavbarDropdownLink.tsx index 84aaae0..4450239 100644 --- a/src/components/NavbarDropdownLink.tsx +++ b/src/components/NavbarDropdownLink.tsx @@ -66,6 +66,7 @@ const NavbarDropdownLink: React.FC = ({ to, text, explo diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 7228474..e4ebda4 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -3,9 +3,15 @@ import { NextPage, GetServerSideProps } from "next"; import { getEvents } from "@models/Event"; import { getFeed } from "@models/Feed"; import FrontPageView from "@views/FrontPage/FrontPageView"; +import Header from "@components/Header"; +import Footer from "@components/Footer/Footer"; const FrontPage: NextPage> = (props) => ( - + <> +
+ +