Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TS Migration] Migrate ReportActionsSkeletonView and SkeletonViewContentLoader directories to TypeScript #30774

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
import PropTypes from 'prop-types';
import React from 'react';
import {Circle, Rect} from 'react-native-svg';
import SkeletonViewContentLoader from '@components/SkeletonViewContentLoader';
import styles from '@styles/styles';
import themeColors from '@styles/themes/default';
import CONST from '@src/CONST';

const propTypes = {
type SkeletonViewLinesProps = {
/** Number of rows to show in Skeleton UI block */
numberOfRows: PropTypes.number.isRequired,
shouldAnimate: PropTypes.bool,
numberOfRows: 1 | 2 | 3;
shouldAnimate?: boolean;
JKobrynski marked this conversation as resolved.
Show resolved Hide resolved
};

const defaultTypes = {
shouldAnimate: true,
};

function SkeletonViewLines(props) {
function SkeletonViewLines({numberOfRows, shouldAnimate = true}: SkeletonViewLinesProps) {
return (
<SkeletonViewContentLoader
animate={props.shouldAnimate}
height={CONST.CHAT_SKELETON_VIEW.HEIGHT_FOR_ROW_COUNT[props.numberOfRows]}
animate={shouldAnimate}
height={CONST.CHAT_SKELETON_VIEW.HEIGHT_FOR_ROW_COUNT[numberOfRows]}
backgroundColor={themeColors.skeletonLHNIn}
foregroundColor={themeColors.skeletonLHNOut}
style={styles.mr5}
Expand All @@ -42,15 +37,15 @@ function SkeletonViewLines(props) {
width="100%"
height="8"
/>
{props.numberOfRows > 1 && (
{numberOfRows > 1 && (
<Rect
x="72"
y="51"
width="50%"
height="8"
/>
)}
{props.numberOfRows > 2 && (
{numberOfRows > 2 && (
<Rect
x="72"
y="71"
Expand All @@ -63,6 +58,4 @@ function SkeletonViewLines(props) {
}

SkeletonViewLines.displayName = 'SkeletonViewLines';
SkeletonViewLines.propTypes = propTypes;
SkeletonViewLines.defaultProps = defaultTypes;
export default SkeletonViewLines;
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
import PropTypes from 'prop-types';
import React from 'react';
import {Dimensions, View} from 'react-native';
import CONST from '@src/CONST';
import SkeletonViewLines from './SkeletonViewLines';

const propTypes = {
type ReportActionsSkeletonViewProps = {
/** Whether to animate the skeleton view */
shouldAnimate: PropTypes.bool,
shouldAnimate?: boolean;

JKobrynski marked this conversation as resolved.
Show resolved Hide resolved
/** Number of possible visible content items */
possibleVisibleContentItems: PropTypes.number,
possibleVisibleContentItems?: number;
};

const defaultProps = {
shouldAnimate: true,
possibleVisibleContentItems: 0,
};

function ReportActionsSkeletonView({shouldAnimate, possibleVisibleContentItems}) {
function ReportActionsSkeletonView({shouldAnimate = true, possibleVisibleContentItems = 0}: ReportActionsSkeletonViewProps) {
const contentItems = possibleVisibleContentItems || Math.ceil(Dimensions.get('window').height / CONST.CHAT_SKELETON_VIEW.AVERAGE_ROW_HEIGHT);
const skeletonViewLines = [];
const skeletonViewLines: React.ReactNode[] = [];
for (let index = 0; index < contentItems; index++) {
const iconIndex = (index + 1) % 4;
switch (iconIndex) {
Expand Down Expand Up @@ -55,6 +49,4 @@ function ReportActionsSkeletonView({shouldAnimate, possibleVisibleContentItems})
}

ReportActionsSkeletonView.displayName = 'ReportActionsSkeletonView';
ReportActionsSkeletonView.propTypes = propTypes;
ReportActionsSkeletonView.defaultProps = defaultProps;
export default ReportActionsSkeletonView;
3 changes: 0 additions & 3 deletions src/components/SkeletonViewContentLoader/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions src/components/SkeletonViewContentLoader/index.native.js

This file was deleted.

10 changes: 10 additions & 0 deletions src/components/SkeletonViewContentLoader/index.native.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import SkeletonViewContentLoader from 'react-content-loader/native';
import SkeletonViewContentLoaderProps from './types';

function ContentLoader(props: SkeletonViewContentLoaderProps) {
// eslint-disable-next-line react/jsx-props-no-spreading
return <SkeletonViewContentLoader {...props} />;
}

export default ContentLoader;
10 changes: 10 additions & 0 deletions src/components/SkeletonViewContentLoader/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import SkeletonViewContentLoader from 'react-content-loader';
import SkeletonViewContentLoaderProps from './types';

function ContentLoader(props: SkeletonViewContentLoaderProps) {
// eslint-disable-next-line react/jsx-props-no-spreading
return <SkeletonViewContentLoader {...props} />;
}

export default ContentLoader;
6 changes: 6 additions & 0 deletions src/components/SkeletonViewContentLoader/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {IContentLoaderProps} from 'react-content-loader';
import {IContentLoaderProps as NativeIContentLoaderProps} from 'react-content-loader/native';

type SkeletonViewContentLoaderProps = IContentLoaderProps & NativeIContentLoaderProps;

export default SkeletonViewContentLoaderProps;
Loading