diff --git a/app/soapbox/features/ui/components/profile-field.tsx b/app/soapbox/features/ui/components/profile-field.tsx new file mode 100644 index 000000000..2593c5201 --- /dev/null +++ b/app/soapbox/features/ui/components/profile-field.tsx @@ -0,0 +1,73 @@ +import classNames from 'clsx'; +import React from 'react'; +import { defineMessages, useIntl, FormatDateOptions } from 'react-intl'; + +import Markup from 'soapbox/components/markup'; +import { HStack, Icon } from 'soapbox/components/ui'; +import BundleContainer from 'soapbox/features/ui/containers/bundle-container'; +import { CryptoAddress } from 'soapbox/features/ui/util/async-components'; + +import type { Field } from 'soapbox/types/entities'; + +const getTicker = (value: string): string => (value.match(/\$([a-zA-Z]*)/i) || [])[1]; +const isTicker = (value: string): boolean => Boolean(getTicker(value)); + +const messages = defineMessages({ + linkVerifiedOn: { id: 'account.link_verified_on', defaultMessage: 'Ownership of this link was checked on {date}' }, +}); + +const dateFormatOptions: FormatDateOptions = { + month: 'short', + day: 'numeric', + year: 'numeric', + hour12: true, + hour: 'numeric', + minute: '2-digit', +}; + +interface IProfileField { + field: Field, +} + +/** Renders a single profile field. */ +const ProfileField: React.FC = ({ field }) => { + const intl = useIntl(); + + if (isTicker(field.name)) { + return ( + + {Component => ( + + )} + + ); + } + + return ( +
+
+ +
+ +
+ + {field.verified_at && ( + + + + )} + + + +
+
+ ); +}; + +export default ProfileField; diff --git a/app/soapbox/features/ui/components/profile-fields-panel.tsx b/app/soapbox/features/ui/components/profile-fields-panel.tsx index 1ee911e34..1babfb63f 100644 --- a/app/soapbox/features/ui/components/profile-fields-panel.tsx +++ b/app/soapbox/features/ui/components/profile-fields-panel.tsx @@ -1,77 +1,11 @@ -import classNames from 'clsx'; import React from 'react'; -import { defineMessages, useIntl, FormattedMessage, FormatDateOptions } from 'react-intl'; +import { FormattedMessage } from 'react-intl'; -import Markup from 'soapbox/components/markup'; -import { Widget, Stack, HStack, Icon } from 'soapbox/components/ui'; -import BundleContainer from 'soapbox/features/ui/containers/bundle-container'; -import { CryptoAddress } from 'soapbox/features/ui/util/async-components'; +import { Widget, Stack } from 'soapbox/components/ui'; -import type { Account, Field } from 'soapbox/types/entities'; +import ProfileField from './profile-field'; -const getTicker = (value: string): string => (value.match(/\$([a-zA-Z]*)/i) || [])[1]; -const isTicker = (value: string): boolean => Boolean(getTicker(value)); - -const messages = defineMessages({ - linkVerifiedOn: { id: 'account.link_verified_on', defaultMessage: 'Ownership of this link was checked on {date}' }, - account_locked: { id: 'account.locked_info', defaultMessage: 'This account privacy status is set to locked. The owner manually reviews who can follow them.' }, - deactivated: { id: 'account.deactivated', defaultMessage: 'Deactivated' }, - bot: { id: 'account.badges.bot', defaultMessage: 'Bot' }, -}); - -const dateFormatOptions: FormatDateOptions = { - month: 'short', - day: 'numeric', - year: 'numeric', - hour12: true, - hour: 'numeric', - minute: '2-digit', -}; - -interface IProfileField { - field: Field, -} - -/** Renders a single profile field. */ -const ProfileField: React.FC = ({ field }) => { - const intl = useIntl(); - - if (isTicker(field.name)) { - return ( - - {Component => ( - - )} - - ); - } - - return ( -
-
- -
- -
- - {field.verified_at && ( - - - - )} - - - -
-
- ); -}; +import type { Account } from 'soapbox/types/entities'; interface IProfileFieldsPanel { account: Account,