diff --git a/app/soapbox/components/__tests__/avatar.test.tsx b/app/soapbox/components/__tests__/avatar.test.tsx deleted file mode 100644 index 56f592925c..0000000000 --- a/app/soapbox/components/__tests__/avatar.test.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import React from 'react'; - -import { normalizeAccount } from 'soapbox/normalizers'; - -import { render, screen } from '../../jest/test-helpers'; -import Avatar from '../avatar'; - -import type { ReducerAccount } from 'soapbox/reducers/accounts'; - -describe('', () => { - const account = normalizeAccount({ - username: 'alice', - acct: 'alice', - display_name: 'Alice', - avatar: '/animated/alice.gif', - avatar_static: '/static/alice.jpg', - }) as ReducerAccount; - - const size = 100; - - // describe('Autoplay', () => { - // it('renders an animated avatar', () => { - // render(); - - // expect(screen.getByRole('img').getAttribute('src')).toBe(account.get('avatar')); - // }); - // }); - - describe('Still', () => { - it('renders a still avatar', () => { - render(); - - expect(screen.getByRole('img').getAttribute('src')).toBe(account.get('avatar')); - }); - }); - - // TODO add autoplay test if possible -}); diff --git a/app/soapbox/components/account.tsx b/app/soapbox/components/account.tsx index 322a981194..546d5f3f4d 100644 --- a/app/soapbox/components/account.tsx +++ b/app/soapbox/components/account.tsx @@ -46,7 +46,7 @@ interface IProfilePopper { const ProfilePopper: React.FC = ({ condition, wrapper, children }): any => condition ? wrapper(children) : children; -interface IAccount { +export interface IAccount { account: AccountEntity, action?: React.ReactElement, actionAlignment?: 'center' | 'top', diff --git a/app/soapbox/components/avatar.tsx b/app/soapbox/components/avatar.tsx deleted file mode 100644 index 4bc5c07748..0000000000 --- a/app/soapbox/components/avatar.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import classNames from 'clsx'; -import React from 'react'; - -import StillImage from 'soapbox/components/still-image'; - -import type { Account } from 'soapbox/types/entities'; - -interface IAvatar { - account?: Account | null, - size?: number, - className?: string, -} - -/** - * Legacy avatar component. - * @see soapbox/components/ui/avatar/avatar.tsx - * @deprecated - */ -const Avatar: React.FC = ({ account, size, className }) => { - if (!account) return null; - - // : TODO : remove inline and change all avatars to be sized using css - const style: React.CSSProperties = !size ? {} : { - width: `${size}px`, - height: `${size}px`, - }; - - return ( - - ); -}; - -export default Avatar; diff --git a/app/soapbox/containers/account-container.js b/app/soapbox/containers/account-container.js deleted file mode 100644 index 3ee72a60e3..0000000000 Binary files a/app/soapbox/containers/account-container.js and /dev/null differ diff --git a/app/soapbox/containers/account-container.tsx b/app/soapbox/containers/account-container.tsx new file mode 100644 index 0000000000..54c6db64e1 --- /dev/null +++ b/app/soapbox/containers/account-container.tsx @@ -0,0 +1,21 @@ +import React, { useCallback } from 'react'; + +import { useAppSelector } from 'soapbox/hooks'; + +import Account, { IAccount } from '../components/account'; +import { makeGetAccount } from '../selectors'; + +interface IAccountContainer extends Omit { + id: string +} + +const AccountContainer: React.FC = ({ id, ...props }) => { + const getAccount = useCallback(makeGetAccount(), []); + const account = useAppSelector(state => getAccount(state, id)); + + return ( + + ); +}; + +export default AccountContainer; diff --git a/app/soapbox/features/admin/components/report.tsx b/app/soapbox/features/admin/components/report.tsx index c316e2c458..210288fdc4 100644 --- a/app/soapbox/features/admin/components/report.tsx +++ b/app/soapbox/features/admin/components/report.tsx @@ -4,9 +4,8 @@ import { Link } from 'react-router-dom'; import { closeReports } from 'soapbox/actions/admin'; import { deactivateUserModal, deleteUserModal } from 'soapbox/actions/moderation'; -import Avatar from 'soapbox/components/avatar'; import HoverRefWrapper from 'soapbox/components/hover-ref-wrapper'; -import { Accordion, Button, Stack, HStack, Text } from 'soapbox/components/ui'; +import { Accordion, Avatar, Button, Stack, HStack, Text } from 'soapbox/components/ui'; import DropdownMenu from 'soapbox/containers/dropdown-menu-container'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import { makeGetReport } from 'soapbox/selectors'; @@ -86,7 +85,7 @@ const Report: React.FC = ({ id }) => { - + diff --git a/app/soapbox/features/birthdays/account.tsx b/app/soapbox/features/birthdays/account.tsx index 805538fd57..79a70fc426 100644 --- a/app/soapbox/features/birthdays/account.tsx +++ b/app/soapbox/features/birthdays/account.tsx @@ -1,10 +1,9 @@ import React, { useCallback } from 'react'; import { defineMessages, useIntl } from 'react-intl'; -import { Link } from 'react-router-dom'; -import Avatar from 'soapbox/components/avatar'; -import DisplayName from 'soapbox/components/display-name'; +import AccountComponent from 'soapbox/components/account'; import Icon from 'soapbox/components/icon'; +import { HStack } from 'soapbox/components/ui'; import { useAppSelector } from 'soapbox/hooks'; import { makeGetAccount } from 'soapbox/selectors'; @@ -22,12 +21,6 @@ const Account: React.FC = ({ accountId }) => { const account = useAppSelector((state) => getAccount(state, accountId)); - // useEffect(() => { - // if (accountId && !account) { - // fetchAccount(accountId); - // } - // }, [accountId]); - if (!account) return null; const birthday = account.birthday; @@ -36,26 +29,20 @@ const Account: React.FC = ({ accountId }) => { const formattedBirthday = intl.formatDate(birthday, { day: 'numeric', month: 'short', year: 'numeric' }); return ( -
-
- -
-
- - -
- -
- - {formattedBirthday} -
+ +
+
-
+
+ + {formattedBirthday} +
+ ); }; diff --git a/app/soapbox/features/ui/components/user-panel.tsx b/app/soapbox/features/ui/components/user-panel.tsx index 918d94efdb..0ccfe16312 100644 --- a/app/soapbox/features/ui/components/user-panel.tsx +++ b/app/soapbox/features/ui/components/user-panel.tsx @@ -2,9 +2,8 @@ import React from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; import { Link } from 'react-router-dom'; -import Avatar from 'soapbox/components/avatar'; import StillImage from 'soapbox/components/still-image'; -import { HStack, Stack, Text } from 'soapbox/components/ui'; +import { Avatar, HStack, Stack, Text } from 'soapbox/components/ui'; import VerificationBadge from 'soapbox/components/verification-badge'; import { useAppSelector } from 'soapbox/hooks'; import { makeGetAccount } from 'soapbox/selectors'; @@ -48,10 +47,7 @@ const UserPanel: React.FC = ({ accountId, action, badges, domain }) title={acct} className='-mt-12 block' > - + {action && (