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 CurrentUserPersonalDetailsSkeletonView to TypeScript #30441

Merged
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,38 +1,35 @@
import PropTypes from 'prop-types';
import React from 'react';
import {View} from 'react-native';
import {Circle, Rect} from 'react-native-svg';
import _ from 'underscore';
import {ValueOf} from 'type-fest';
import SkeletonViewContentLoader from '@components/SkeletonViewContentLoader';
import styles from '@styles/styles';
import * as StyleUtils from '@styles/StyleUtils';
import themeColors from '@styles/themes/default';
import variables from '@styles/variables';
import CONST from '@src/CONST';

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

/** The size of the avatar */
avatarSize: PropTypes.oneOf(_.values(CONST.AVATAR_SIZE)),
avatarSize?: ValueOf<typeof CONST.AVATAR_SIZE>;

/** Background color of the skeleton view */
backgroundColor: PropTypes.string,
backgroundColor?: string;

/** Foreground color of the skeleton view */
foregroundColor: PropTypes.string,
foregroundColor?: string;
};

const defaultProps = {
shouldAnimate: true,
avatarSize: CONST.AVATAR_SIZE.LARGE,
backgroundColor: themeColors.highlightBG,
foregroundColor: themeColors.border,
};

function CurrentUserPersonalDetailsSkeletonView(props) {
const avatarPlaceholderSize = StyleUtils.getAvatarSize(props.avatarSize);
function CurrentUserPersonalDetailsSkeletonView({
shouldAnimate = true,
avatarSize = CONST.AVATAR_SIZE.LARGE,
backgroundColor = themeColors.highlightBG,
foregroundColor = themeColors.border,
}: CurrentUserPersonalDetailsSkeletonViewProps) {
const avatarPlaceholderSize = StyleUtils.getAvatarSize(avatarSize);
const avatarPlaceholderRadius = avatarPlaceholderSize / 2;
const spaceBetweenAvatarAndHeadline = styles.mb3.marginBottom + styles.mt1.marginTop + (variables.lineHeightXXLarge - variables.fontSizeXLarge) / 2;
const headlineSize = variables.fontSizeXLarge;
Expand All @@ -41,9 +38,9 @@ function CurrentUserPersonalDetailsSkeletonView(props) {
return (
<View style={styles.avatarSectionWrapperSkeleton}>
<SkeletonViewContentLoader
animate={props.shouldAnimate}
backgroundColor={props.backgroundColor}
foregroundColor={props.foregroundColor}
animate={shouldAnimate}
backgroundColor={backgroundColor}
foregroundColor={foregroundColor}
height={avatarPlaceholderSize + spaceBetweenAvatarAndHeadline + headlineSize + spaceBetweenHeadlineAndLabel + labelSize}
>
<Circle
Expand All @@ -69,6 +66,4 @@ function CurrentUserPersonalDetailsSkeletonView(props) {
}

CurrentUserPersonalDetailsSkeletonView.displayName = 'CurrentUserPersonalDetailsSkeletonView';
CurrentUserPersonalDetailsSkeletonView.propTypes = propTypes;
CurrentUserPersonalDetailsSkeletonView.defaultProps = defaultProps;
export default CurrentUserPersonalDetailsSkeletonView;