wisemapping-frontend/packages/webapp/src/components/layout/header/index.tsx

74 lines
2.3 KiB
TypeScript
Raw Normal View History

2020-12-08 18:35:36 +01:00
import { StyledNav, StyledDiv,Logo } from './styled';
import React from 'react'
import { FormattedMessage } from 'react-intl'
2020-12-06 17:24:53 +01:00
import { Link } from 'react-router-dom'
2020-12-27 18:58:21 +01:00
const logo = require('../../../images/header-logo.png')
2020-12-06 06:28:00 +01:00
interface HeaderProps {
2020-12-08 08:14:08 +01:00
type: 'only-signup' | 'only-signin' | 'none';
2020-12-06 06:28:00 +01:00
}
class Header extends React.Component<HeaderProps, HeaderProps> {
constructor(props: HeaderProps) {
super(props);
2020-12-06 18:02:57 +01:00
this.state = { type: props.type };
}
render() {
let signUpButton;
let signInButton;
let text;
const pageType = this.state.type;
if (pageType === 'only-signup') {
text = <span className="header-area-content-span"><span><FormattedMessage id="header.donthaveaccount" defaultMessage="Don't have an account ?" /></span></span>;
signUpButton = <SignUpButton className="header-area-right2" />;
} else if (pageType === 'only-signin') {
text = <span className="header-area-content-span"><span><FormattedMessage id="header.haveaccount" defaultMessage="Already have an account?" /></span></span>;
signUpButton = <SignInButton className="header-area-right2" />;
2020-12-08 08:14:08 +01:00
} else if (pageType === 'none') {
text = '';
signUpButton = '';
} else {
2020-12-06 06:28:00 +01:00
signUpButton = <SignUpButton className="header-area-right2" />
signInButton = <SignInButton className="header-area-right2" />;
}
return (
2020-12-08 18:35:36 +01:00
<StyledNav>
<StyledDiv>
2020-12-12 05:37:48 +01:00
<Logo><Link to="/c/login" className="header-logo"><img src={String(logo)} alt="logo" /></Link></Logo>
{text}
{signUpButton}
{signInButton}
2020-12-08 18:35:36 +01:00
</StyledDiv>
</StyledNav>
)
};
}
2020-12-06 06:28:00 +01:00
interface ButtonProps {
2020-12-08 18:35:36 +01:00
style?: 'style1' | 'style2' | 'style3';
2020-12-08 08:14:08 +01:00
className?: string;
2020-12-06 06:28:00 +01:00
}
const SignInButton = (props: ButtonProps) => {
2020-12-08 08:14:08 +01:00
const style = props.style ? props.style : 'style1';
return (
2020-12-08 08:14:08 +01:00
<span className={`button-${style} ${props.className}`}>
2020-12-12 05:37:48 +01:00
<Link to="/c/login"><FormattedMessage id="login.signin" defaultMessage="Sign In" /></Link>
</span>);
}
2020-12-06 06:28:00 +01:00
const SignUpButton = (props: ButtonProps) => {
2020-12-08 08:14:08 +01:00
const style = props.style ? props.style : 'style1';
return (
2020-12-08 08:14:08 +01:00
<span className={`button-${style} ${props.className}`}>
2020-12-12 05:37:48 +01:00
<Link to="/c/registration"><FormattedMessage id="login.signup" defaultMessage="Sign Up" /></Link>
2020-12-06 06:28:00 +01:00
</span>);
}
2020-12-08 08:14:08 +01:00
export { SignInButton, SignUpButton };
export default Header;