push small updates for Spacer component merge

This commit is contained in:
Shaun Hamilton
2021-06-24 16:16:19 +00:00
parent fb8ab17fdf
commit 8abe1eafbc
8 changed files with 21 additions and 24 deletions

View File

@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next';
interface AvatarRendererProps { interface AvatarRendererProps {
isDonating?: boolean; isDonating?: boolean;
isTopContributor?: boolean; isTopContributor?: boolean;
picture: unknown; picture: string;
userName: string; userName: string;
} }
@ -19,14 +19,12 @@ function AvatarRenderer({
isTopContributor isTopContributor
}: AvatarRendererProps): JSX.Element { }: AvatarRendererProps): JSX.Element {
const { t } = useTranslation(); const { t } = useTranslation();
// eslint-disable-next-line @typescript-eslint/no-unsafe-call const borderColor: string = borderColorPicker(isDonating, isTopContributor);
const borderColor: unknown = borderColorPicker(isDonating, isTopContributor);
const isPlaceHolderImage = const isPlaceHolderImage =
/example.com|identicon.org/.test(picture as string) || /example.com|identicon.org/.test(picture) || picture === defaultUserImage;
picture === defaultUserImage;
return ( return (
<div className={`avatar-container ${borderColor as string}`}> <div className={`avatar-container ${borderColor}`}>
{isPlaceHolderImage ? ( {isPlaceHolderImage ? (
<DefaultAvatar className='avatar default-avatar' /> <DefaultAvatar className='avatar default-avatar' />
) : ( ) : (

View File

@ -3,7 +3,7 @@ import React from 'react';
import envData from '../../../../config/env.json'; import envData from '../../../../config/env.json';
interface EnvData { interface EnvData {
apiLocation?: string; apiLocation: string;
} }
const { apiLocation } = envData as EnvData; const { apiLocation } = envData as EnvData;
@ -14,7 +14,7 @@ function CurrentChallengeLink({
children, children,
isLargeBtn isLargeBtn
}: { }: {
children?: React.ReactNode; children?: JSX.ElementChildrenAttribute;
isLargeBtn?: boolean; isLargeBtn?: boolean;
}): JSX.Element { }): JSX.Element {
let classNames; let classNames;
@ -24,10 +24,7 @@ function CurrentChallengeLink({
classNames = 'btn btn-primary btn-block'; classNames = 'btn btn-primary btn-block';
} }
return ( return (
<a <a className={classNames} href={`${apiLocation}${currentChallengeApi}`}>
className={classNames}
href={`${apiLocation as string}${currentChallengeApi}`}
>
{children} {children}
</a> </a>
); );

View File

@ -5,7 +5,7 @@ function FullWidthRow({
children, children,
className className
}: { }: {
children?: React.ReactNode; children?: JSX.ElementChildrenAttribute;
className?: string; className?: string;
}): JSX.Element { }): JSX.Element {
return ( return (

View File

@ -1,8 +1,8 @@
import React, { ReactNode } from 'react'; import React from 'react';
import { Link as GatsbyLink } from 'gatsby'; import { Link as GatsbyLink } from 'gatsby';
interface LinkProps { interface LinkProps {
children?: ReactNode; children?: JSX.ElementChildrenAttribute;
external?: boolean; external?: boolean;
sameTab?: boolean; sameTab?: boolean;
to: string; to: string;

View File

@ -2,6 +2,7 @@ import React from 'react';
import styles from './skeleton-styles'; import styles from './skeleton-styles';
// TODO: unsure about parameter typing
function SkeletonSprite({}: React.FC< function SkeletonSprite({}: React.FC<
React.ComponentPropsWithoutRef<'svg'> React.ComponentPropsWithoutRef<'svg'>
>): JSX.Element { >): JSX.Element {

View File

@ -1,8 +1,8 @@
import React, { ReactNode } from 'react'; import React from 'react';
import { Row, Col } from '@freecodecamp/react-bootstrap'; import { Row, Col } from '@freecodecamp/react-bootstrap';
interface SlimWidthRowProps { interface SlimWidthRowProps {
children: ReactNode; children: JSX.ElementChildrenAttribute;
} }
function SlimWidthRow({ function SlimWidthRow({
children, children,

View File

@ -6,18 +6,19 @@ interface SpacerProps {
const styles = { padding: '15px 0', height: '1px' }; const styles = { padding: '15px 0', height: '1px' };
const Comp: React.FC = ({ ...props }) => ( const Comp = ({ ...props }): JSX.Element => (
<div className='spacer' style={styles} {...props} /> <div className='spacer' style={styles} {...props} />
); );
const Spacer = ({ size = 1 }: SpacerProps): React.ReactNode => const Spacer = ({ size = 1 }: SpacerProps): JSX.Element =>
size === 1 ? ( size === 1 ? (
<Comp /> <Comp />
) : ( ) : (
'#' <>
.repeat(size) {Array.from(Array(size), (_, i) => (
.split('') <Comp key={`spacer_${i}`} />
.map((_, i) => <Comp key={`spacer_${i}`} />) ))}
</>
); );
export default Spacer; export default Spacer;

View File

@ -29,7 +29,7 @@ export default function ToggleButton({
value, value,
onLabel = 'On', onLabel = 'On',
offLabel = 'Off' offLabel = 'Off'
}: ButtonProps): React.ReactNode { }: ButtonProps): JSX.Element {
const checkIconStyle = { const checkIconStyle = {
height: '15px', height: '15px',
width: '20px' width: '20px'