Skip to content
Snippets Groups Projects
Commit 1673b25a authored by Tore.Brede's avatar Tore.Brede
Browse files

Merge branch 'fix_linting_errors' into 'master'

Fix linting errors

See merge request !60
parents ad3353db 2c8dce3f
No related branches found
No related tags found
1 merge request!60Fix linting errors
Pipeline #93518 passed
import styled, {css, DefaultTheme} from 'styled-components/macro'
import React from 'react'
import styled, { css } from 'styled-components/macro'
interface IStyledLink {
theme: DefaultTheme
external?: boolean
underline?: boolean
marginRight?: boolean
inheritColor?: boolean
noUnderline?: boolean
external?: boolean
underline?: boolean
marginRight?: boolean
inheritColor?: boolean
noUnderline?: boolean
}
......@@ -38,19 +37,22 @@ const ExternalIcon = styled.span`
margin-left: 1.2rem;
position: relative;
top: 1px;
zIndex: -1;
z-index: -1;
`
const baseInputStyles = css<IStyledLink>`
display: inline-flex;
align-items: center;
color: ${props => props.external ? props.theme.linkExternalColor : props.theme.linkInternalColor};
color: ${(props) =>
props.external
? props.theme.linkExternalColor
: props.theme.linkInternalColor};
${props => props.marginRight ? "margin-right: 3rem;" : ""}
${props => props.inheritColor ? "color: inherit;" : ""}
${props => props.underline ? "text-decoration: underline;" : ""}
${props => props.noUnderline ? ":hover { text-decoration: none };" : ""}
${(props) => (props.marginRight ? 'margin-right: 3rem;' : '')}
${(props) => (props.inheritColor ? 'color: inherit;' : '')}
${(props) => (props.underline ? 'text-decoration: underline;' : '')}
${(props) => (props.noUnderline ? ':hover { text-decoration: none };' : '')}
`
const StyledLink = styled.a<IStyledLink>`
......@@ -62,47 +64,67 @@ const StyledLink = styled.a<IStyledLink>`
// `
function Link(props: ILink) {
const {children, external, to, noExternalIcon, mail} = props
if (mail) {
return (
<StyledLink href={`mailto:${to}`} {...props}>
{children}
</StyledLink>
);
}
if (external) {
const urlRegex = /^((http|https):\/\/)/;
const href = urlRegex.test(to) ? to : `//${to}`;
return (
<StyledLink
href={href}
target="_blank"
rel="noopener noreferrer"
{...props}
>
{children}
{!noExternalIcon && (
<ExternalIcon>{externalLinkIcon}</ExternalIcon>
)}
</StyledLink>
);
}
// TODO Use StyledRouterLink for internal links when routes are set up
// return (
// <StyledRouterLink {...props}>
// {children}
// </StyledRouterLink>
// )
const { children, external, to, noExternalIcon, mail, underline, marginRight, inheritColor, noUnderline } = props
if (mail) {
return (
<StyledLink {...props}>
{children}
</StyledLink>
<StyledLink href={`mailto:${to}`}
external={external}
underline={underline}
marginRight={marginRight}
inheritColor={inheritColor}
noUnderline={noUnderline}>
{children}
</StyledLink>
)
}
if (external) {
const urlRegex = /^((http|https):\/\/)/
const href = urlRegex.test(to) ? to : `//${to}`
return (
<StyledLink
href={href}
target='_blank'
rel='noopener noreferrer'
external={external}
underline={underline}
marginRight={marginRight}
inheritColor={inheritColor}
noUnderline={noUnderline}
>
{children}
{!noExternalIcon && <ExternalIcon>{externalLinkIcon}</ExternalIcon>}
</StyledLink>
)
}
// TODO Use StyledRouterLink for internal links when routes are set up
// return (
// <StyledRouterLink {...props}>
// {children}
// </StyledRouterLink>
// )
return <StyledLink
external={external}
underline={underline}
marginRight={marginRight}
inheritColor={inheritColor}
noUnderline={noUnderline}>
{children}</StyledLink>
}
Link.defaultProps = {
external: false,
children: undefined,
marginRight: false,
noExternalIcon: false,
mail: false,
inheritColor: false,
underline: false,
noUnderline: false,
}
export default Link
\ No newline at end of file
export default Link
import Page from 'components/page/page'
export { Page }
export default Page
......@@ -8,8 +8,8 @@ import 'i18n'
import getTheme from 'themes'
import GlobalStyle from 'globalStyles'
import App from 'routes'
import reportWebVitals from './reportWebVitals'
import Loading from 'components/loading'
import reportWebVitals from './reportWebVitals'
function appRoot() {
return (
......
import React from 'react'
import { Page } from 'components/page'
import Page from 'components/page'
export default function NotFound() {
return (
......
import React, { useState } from 'react'
import { Page } from 'components/page'
import Page from 'components/page'
import { appTimezone, appVersion, appTheme } from 'appConfig'
export default function FrontPage() {
......
......@@ -10,6 +10,7 @@ import FrontPage from 'routes/frontpage'
import Footer from 'routes/components/footer'
import Header from 'routes/components/header'
import NotFound from 'routes/components/notFound'
import Link from '../components/link'
const AppWrapper = styled.div`
display: flex;
......
import React from 'react'
import { Page } from 'components/page'
import Page from 'components/page'
export default function Register() {
return (
......
import React from 'react'
import { Page } from 'components/page'
import Page from 'components/page'
function FrontPage() {
return (
......
import React from 'react'
import { useParams } from 'react-router-dom'
import {Page} from 'components/page'
import Page from 'components/page'
type GuestInfoParams = {
id: string
......
const { createProxyMiddleware } = require('http-proxy-middleware')
module.exports = function (app) {
module.exports = (app) => {
app.use(
'/api',
createProxyMiddleware({
......
......@@ -5,9 +5,7 @@ import { ThemeProvider } from 'styled-components/macro'
import mainTheme from 'themes/main'
// Providers used in test rendering
const AllTheProviders = ({ children }: any) => {
return <ThemeProvider theme={mainTheme}> {children} </ThemeProvider>
}
const AllTheProviders = ({ children }: any) => <ThemeProvider theme={mainTheme}> {children} </ThemeProvider>
// Custom testing-library/react renderer using our providers.
const customRender = (ui: React.ReactElement, options?: any) =>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment