Rewrite `<Skeleton/>` as FC and TS (#25055)

This commit is contained in:
たいち ひ 2023-05-23 15:58:08 +09:00 committed by GitHub
parent 711a037660
commit 8066118d1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 21 additions and 20 deletions

View File

@ -4,7 +4,7 @@ import api from 'mastodon/api';
import { FormattedNumber } from 'react-intl'; import { FormattedNumber } from 'react-intl';
import { Sparklines, SparklinesCurve } from 'react-sparklines'; import { Sparklines, SparklinesCurve } from 'react-sparklines';
import classNames from 'classnames'; import classNames from 'classnames';
import Skeleton from 'mastodon/components/skeleton'; import { Skeleton } from 'mastodon/components/skeleton';
const percIncrease = (a, b) => { const percIncrease = (a, b) => {
let percent; let percent;

View File

@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import api from 'mastodon/api'; import api from 'mastodon/api';
import { FormattedNumber } from 'react-intl'; import { FormattedNumber } from 'react-intl';
import { roundTo10 } from 'mastodon/utils/numbers'; import { roundTo10 } from 'mastodon/utils/numbers';
import Skeleton from 'mastodon/components/skeleton'; import { Skeleton } from 'mastodon/components/skeleton';
export default class Dimension extends React.PureComponent { export default class Dimension extends React.PureComponent {

View File

@ -5,7 +5,7 @@ import type { List } from 'immutable';
import type { Account } from '../../types/resources'; import type { Account } from '../../types/resources';
import { autoPlayGif } from '../initial_state'; import { autoPlayGif } from '../initial_state';
import Skeleton from './skeleton'; import { Skeleton } from './skeleton';
interface Props { interface Props {
account?: Account; account?: Account;

View File

@ -3,7 +3,7 @@ import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import { DisplayName } from 'mastodon/components/display_name'; import { DisplayName } from 'mastodon/components/display_name';
import Skeleton from 'mastodon/components/skeleton'; import { Skeleton } from 'mastodon/components/skeleton';
interface Props { interface Props {
size?: number; size?: number;

View File

@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePropTypes from 'react-immutable-proptypes';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import ShortNumber from 'mastodon/components/short_number'; import ShortNumber from 'mastodon/components/short_number';
import Skeleton from 'mastodon/components/skeleton'; import { Skeleton } from 'mastodon/components/skeleton';
import classNames from 'classnames'; import classNames from 'classnames';
class SilentErrorBoundary extends React.Component { class SilentErrorBoundary extends React.Component {

View File

@ -4,7 +4,7 @@ import { FormattedMessage, defineMessages, injectIntl } from 'react-intl';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { fetchServer } from 'mastodon/actions/server'; import { fetchServer } from 'mastodon/actions/server';
import ShortNumber from 'mastodon/components/short_number'; import ShortNumber from 'mastodon/components/short_number';
import Skeleton from 'mastodon/components/skeleton'; import { Skeleton } from 'mastodon/components/skeleton';
import Account from 'mastodon/containers/account_container'; import Account from 'mastodon/containers/account_container';
import { domain } from 'mastodon/initial_state'; import { domain } from 'mastodon/initial_state';
import { ServerHeroImage } from 'mastodon/components/server_hero_image'; import { ServerHeroImage } from 'mastodon/components/server_hero_image';

View File

@ -1,11 +0,0 @@
import React from 'react';
import PropTypes from 'prop-types';
const Skeleton = ({ width, height }) => <span className='skeleton' style={{ width, height }}>&zwnj;</span>;
Skeleton.propTypes = {
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
};
export default Skeleton;

View File

@ -0,0 +1,12 @@
import React from 'react';
interface Props {
width?: number | string;
height?: number | string;
}
export const Skeleton: React.FC<Props> = ({ width, height }) => (
<span className='skeleton' style={{ width, height }}>
&zwnj;
</span>
);

View File

@ -8,7 +8,7 @@ import LinkFooter from 'mastodon/features/ui/components/link_footer';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';
import { fetchServer, fetchExtendedDescription, fetchDomainBlocks } from 'mastodon/actions/server'; import { fetchServer, fetchExtendedDescription, fetchDomainBlocks } from 'mastodon/actions/server';
import Account from 'mastodon/containers/account_container'; import Account from 'mastodon/containers/account_container';
import Skeleton from 'mastodon/components/skeleton'; import { Skeleton } from 'mastodon/components/skeleton';
import { Icon } from 'mastodon/components/icon'; import { Icon } from 'mastodon/components/icon';
import classNames from 'classnames'; import classNames from 'classnames';
import { ServerHeroImage } from 'mastodon/components/server_hero_image'; import { ServerHeroImage } from 'mastodon/components/server_hero_image';

View File

@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { Blurhash } from 'mastodon/components/blurhash'; import { Blurhash } from 'mastodon/components/blurhash';
import { accountsCountRenderer } from 'mastodon/components/hashtag'; import { accountsCountRenderer } from 'mastodon/components/hashtag';
import ShortNumber from 'mastodon/components/short_number'; import ShortNumber from 'mastodon/components/short_number';
import Skeleton from 'mastodon/components/skeleton'; import { Skeleton } from 'mastodon/components/skeleton';
import classNames from 'classnames'; import classNames from 'classnames';
export default class Story extends React.PureComponent { export default class Story extends React.PureComponent {

View File

@ -4,7 +4,7 @@ import { Helmet } from 'react-helmet';
import { FormattedMessage, FormattedDate, injectIntl, defineMessages } from 'react-intl'; import { FormattedMessage, FormattedDate, injectIntl, defineMessages } from 'react-intl';
import Column from 'mastodon/components/column'; import Column from 'mastodon/components/column';
import api from 'mastodon/api'; import api from 'mastodon/api';
import Skeleton from 'mastodon/components/skeleton'; import { Skeleton } from 'mastodon/components/skeleton';
const messages = defineMessages({ const messages = defineMessages({
title: { id: 'privacy_policy.title', defaultMessage: 'Privacy Policy' }, title: { id: 'privacy_policy.title', defaultMessage: 'Privacy Policy' },