Skip to content

Commit

Permalink
fix(website): fix types forwardRefs and function (#5)
Browse files Browse the repository at this point in the history
fix(website): fix types forwardRefs and function
  • Loading branch information
poteirard committed May 23, 2019
2 parents f4d529c + 0de84a2 commit 0c08daa
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/components/atoms/InputText/InputText.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import React from 'react';
import styled from 'styled-components';
import * as colors from '../../../constants/colors';
import { statusColors } from '../../../constants/colors';
import { getBorderColorByStatus } from '../../../helpers/utils';
import { IInput } from '../../types';

export const getBorderColorByStatus = ({ hasError, isValid }: IInput) =>
hasError ? statusColors.error : isValid ? statusColors.valid : colors.neutral.neutral75;

const Input = styled.input<IInput>`
border: 2px solid ${getBorderColorByStatus};
border-radius: 4px;
Expand Down
2 changes: 1 addition & 1 deletion src/components/atoms/Link/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const TargetIcon = (props: ITargetIconProps) => {
);
};

const Link = React.forwardRef<HTMLAnchorElement, ILinkProps>((props, ref) => {
const Link: FC<ILinkProps> = React.forwardRef<HTMLAnchorElement, ILinkProps>((props, ref) => {
const { children, ...rest } = props;
return (
<SLink ref={ref} {...rest}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/RadioField/RadioField.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { FunctionComponent } from 'react';
import styled, { keyframes } from 'styled-components';
import * as colors from '../../../constants/colors';
import { getBorderColorByStatus } from '../../../helpers/utils';
import InputLabel from '../../atoms/InputLabel/InputLabel';
import { getBorderColorByStatus } from '../../atoms/InputText/InputText';
import SizedContainer from '../../layout/SizedContainer/SizedContainer';
import { IField, IInputStatus } from '../../types';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import React, { FC } from 'react';

const AccordionSection = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
const AccordionSection: FC = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ children, ...rest }, ref) => (
<div {...rest}>
<div ref={ref}>{children}</div>
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/Navbar/NavbarLink/NavbarLink.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { FC } from 'react';
import styled from 'styled-components';
import * as colors from '../../../../constants/colors';
import Chevron from '../../../icons/Chevron/Chevron';
Expand Down Expand Up @@ -52,7 +52,7 @@ export interface INavbarLinkProps extends React.AnchorHTMLAttributes<HTMLAnchorE
open?: boolean;
}

const NavbarLink = React.forwardRef<HTMLAnchorElement, INavbarLinkProps>(
const NavbarLink: FC<INavbarLinkProps> = React.forwardRef<HTMLAnchorElement, INavbarLinkProps>(
({ active = false, children, open = false, withChevron = false, color = colors.primary.blue500, ...rest }, ref) => (
<StyledNavbarLink active={active} withChevron={withChevron} color={color} ref={ref} {...rest}>
{children}
Expand Down
7 changes: 7 additions & 0 deletions src/helpers/utils.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
import { IInputStatus } from '../components/types';
import { statusColors } from '../constants/colors';
import * as colors from '../constants/colors';

export const mod = (x: number, n: number) => ((x % n) + n) % n;

export const getBorderColorByStatus = ({ hasError, isValid }: IInputStatus) =>
hasError ? statusColors.error : isValid ? statusColors.valid : colors.neutral.neutral75;

0 comments on commit 0c08daa

Please sign in to comment.