Convert placeholder components to TSX

This commit is contained in:
Alex Gleason 2022-05-01 12:45:37 -05:00
parent db434e3b77
commit e20a083fb4
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 20 additions and 21 deletions

View File

@ -1,7 +1,11 @@
import PropTypes from 'prop-types';
import * as React from 'react';
const PlaceholderAvatar = ({ size }) => {
interface IPlaceholderAvatar {
size: number,
}
/** Fake avatar to display while data is loading. */
const PlaceholderAvatar: React.FC<IPlaceholderAvatar> = ({ size }) => {
const style = React.useMemo(() => {
if (!size) {
return {};
@ -17,13 +21,8 @@ const PlaceholderAvatar = ({ size }) => {
<div
className='rounded-full bg-slate-200 dark:bg-slate-700'
style={style}
alt=''
/>
);
};
PlaceholderAvatar.propTypes = {
size: PropTypes.number.isRequired,
};
export default PlaceholderAvatar;

View File

@ -1,9 +1,14 @@
import PropTypes from 'prop-types';
import React from 'react';
import { randomIntFromInterval, generateText } from '../utils';
const PlaceholderDisplayName = ({ minLength, maxLength }) => {
interface IPlaceholderDisplayName {
maxLength: number,
minLength: number,
}
/** Fake display name to show when data is loading. */
const PlaceholderDisplayName: React.FC<IPlaceholderDisplayName> = ({ minLength, maxLength }) => {
const length = randomIntFromInterval(maxLength, minLength);
const acctLength = randomIntFromInterval(maxLength, minLength);
@ -15,9 +20,4 @@ const PlaceholderDisplayName = ({ minLength, maxLength }) => {
);
};
PlaceholderDisplayName.propTypes = {
maxLength: PropTypes.number.isRequired,
minLength: PropTypes.number.isRequired,
};
export default PlaceholderDisplayName;

View File

@ -1,9 +1,14 @@
import PropTypes from 'prop-types';
import React from 'react';
import { randomIntFromInterval, generateText } from '../utils';
const PlaceholderStatusContent = ({ minLength, maxLength }) => {
interface IPlaceholderStatusContent {
maxLength: number,
minLength: number,
}
/** Fake status content while data is loading. */
const PlaceholderStatusContent: React.FC<IPlaceholderStatusContent> = ({ minLength, maxLength }) => {
const length = randomIntFromInterval(maxLength, minLength);
return (
@ -13,9 +18,4 @@ const PlaceholderStatusContent = ({ minLength, maxLength }) => {
);
};
PlaceholderStatusContent.propTypes = {
maxLength: PropTypes.number.isRequired,
minLength: PropTypes.number.isRequired,
};
export default PlaceholderStatusContent;