Skip to content

Commit

Permalink
Merge pull request #30774 from JKobrynski/migrateReportActionSkeleton…
Browse files Browse the repository at this point in the history
…ViewToTypeScript

[TS Migration] Migrate ReportActionsSkeletonView and SkeletonViewContentLoader directories to TypeScript
  • Loading branch information
MonilBhavsar authored Nov 9, 2023
2 parents feae468 + 5bd34f6 commit 732aad9
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 34 deletions.
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;
};

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;

/** 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;

0 comments on commit 732aad9

Please sign in to comment.