diff --git a/packages/pl-fe/src/components/birthday-input.tsx b/packages/pl-fe/src/components/birthday-input.tsx index 7fa6fbd19..da48cd5d5 100644 --- a/packages/pl-fe/src/components/birthday-input.tsx +++ b/packages/pl-fe/src/components/birthday-input.tsx @@ -1,7 +1,7 @@ import React, { useMemo } from 'react'; import { defineMessages, FormattedDate, useIntl } from 'react-intl'; -import IconButton from 'pl-fe/components/icon-button'; +import IconButton from 'pl-fe/components/ui/icon-button'; import { DatePicker } from 'pl-fe/features/ui/util/async-components'; import { useFeatures } from 'pl-fe/hooks/use-features'; import { useInstance } from 'pl-fe/hooks/use-instance'; @@ -69,7 +69,8 @@ const BirthdayInput: React.FC = ({ value, onChange, required })
= ({ value, onChange, required }) /> = ({ value, onChange, required })
= ({ value, onChange, required }) /> , 'className' | 'disabled' | 'onClick' | 'onKeyDown' | 'onKeyPress' | 'onKeyUp' | 'onMouseDown' | 'onMouseEnter' | 'onMouseLeave' | 'tabIndex' | 'title'> { - active?: boolean; - expanded?: boolean; - iconClassName?: string; - pressed?: boolean; - src: string; - text?: React.ReactNode; -} - -const IconButton: React.FC = ({ - active, - className, - disabled, - expanded, - iconClassName, - onClick, - onKeyDown, - onKeyUp, - onKeyPress, - onMouseDown, - onMouseEnter, - onMouseLeave, - pressed, - src, - tabIndex = 0, - text, - title, -}) => { - const handleClick: React.MouseEventHandler = (e) => { - e.preventDefault(); - - if (!disabled && onClick) { - onClick(e); - } - }; - - const handleMouseDown: React.MouseEventHandler = (e) => { - if (!disabled && onMouseDown) { - onMouseDown(e); - } - }; - - const handleKeyDown: React.KeyboardEventHandler = (e) => { - if (!disabled && onKeyDown) { - onKeyDown(e); - } - }; - - const handleKeyUp: React.KeyboardEventHandler = (e) => { - if (!disabled && onKeyUp) { - onKeyUp(e); - } - }; - - const handleKeyPress: React.KeyboardEventHandler = (e) => { - if (onKeyPress && !disabled) { - onKeyPress(e); - } - }; - - const classes = clsx(className, 'icon-button', { - active, - 'opacity-20 cursor-default': disabled, - }); - - return ( - - ); -}; - -export { IconButton as default }; diff --git a/packages/pl-fe/src/components/ui/icon-button.tsx b/packages/pl-fe/src/components/ui/icon-button.tsx index a4b21924f..74dbb84b9 100644 --- a/packages/pl-fe/src/components/ui/icon-button.tsx +++ b/packages/pl-fe/src/components/ui/icon-button.tsx @@ -29,7 +29,7 @@ const IconButton = React.forwardRef((props: IIconButton, ref: React.ForwardedRef = ({ composeId }) => { } return ( - - +
+

- - +

+
}> = ({ composeId }) => { /> - - +
+
); }; diff --git a/packages/pl-fe/src/features/reply-mentions/account.tsx b/packages/pl-fe/src/features/reply-mentions/account.tsx index 2ca17af4d..ca0dea50e 100644 --- a/packages/pl-fe/src/features/reply-mentions/account.tsx +++ b/packages/pl-fe/src/features/reply-mentions/account.tsx @@ -5,7 +5,7 @@ import { fetchAccount } from 'pl-fe/actions/accounts'; import { addToMentions, removeFromMentions } from 'pl-fe/actions/compose'; import { useAccount } from 'pl-fe/api/hooks/accounts/use-account'; import AccountComponent from 'pl-fe/components/account'; -import IconButton from 'pl-fe/components/icon-button'; +import IconButton from 'pl-fe/components/ui/icon-button'; import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch'; import { useCompose } from 'pl-fe/hooks/use-compose'; @@ -42,9 +42,9 @@ const Account: React.FC = ({ composeId, accountId, author }) => { let button; if (added) { - button = ; + button = ; } else { - button = ; + button = ; } return ( diff --git a/packages/pl-fe/src/modals/list-adder-modal/components/list.tsx b/packages/pl-fe/src/modals/list-adder-modal/components/list.tsx index b7d0925dd..fe9cb4f4c 100644 --- a/packages/pl-fe/src/modals/list-adder-modal/components/list.tsx +++ b/packages/pl-fe/src/modals/list-adder-modal/components/list.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { defineMessages, useIntl } from 'react-intl'; import Icon from 'pl-fe/components/icon'; -import IconButton from 'pl-fe/components/icon-button'; +import IconButton from 'pl-fe/components/ui/icon-button'; import { useAddAccountsToList, useList, useRemoveAccountsFromList } from 'pl-fe/queries/accounts/use-lists'; const messages = defineMessages({ @@ -32,9 +32,9 @@ const List: React.FC = ({ listId, accountId, added }) => { let button; if (added) { - button = ; + button = ; } else { - button = ; + button = ; } return ( diff --git a/packages/pl-fe/src/modals/list-editor-modal/components/account.tsx b/packages/pl-fe/src/modals/list-editor-modal/components/account.tsx index 8379e9a78..755cab0e0 100644 --- a/packages/pl-fe/src/modals/list-editor-modal/components/account.tsx +++ b/packages/pl-fe/src/modals/list-editor-modal/components/account.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { defineMessages, useIntl } from 'react-intl'; -import IconButton from 'pl-fe/components/icon-button'; import HStack from 'pl-fe/components/ui/hstack'; +import IconButton from 'pl-fe/components/ui/icon-button'; import AccountContainer from 'pl-fe/containers/account-container'; const messages = defineMessages({ @@ -23,9 +23,9 @@ const Account: React.FC = ({ accountId, added, onAdd, onRemove }) => { let button; if (added) { - button = onRemove(accountId)} />; + button = onRemove(accountId)} />; } else { - button = onAdd(accountId)} />; + button = onAdd(accountId)} />; } return ( diff --git a/packages/pl-fe/src/pages/search/search.tsx b/packages/pl-fe/src/pages/search/search.tsx index 747a3e810..8f232b91a 100644 --- a/packages/pl-fe/src/pages/search/search.tsx +++ b/packages/pl-fe/src/pages/search/search.tsx @@ -5,9 +5,9 @@ import { useSearchParams } from 'react-router-dom-v5-compat'; import { useAccount } from 'pl-fe/api/hooks/accounts/use-account'; import SearchColumn from 'pl-fe/columns/search'; -import IconButton from 'pl-fe/components/icon-button'; import Column from 'pl-fe/components/ui/column'; import HStack from 'pl-fe/components/ui/hstack'; +import IconButton from 'pl-fe/components/ui/icon-button'; import Input from 'pl-fe/components/ui/input'; import SvgIcon from 'pl-fe/components/ui/svg-icon'; import Tabs from 'pl-fe/components/ui/tabs'; @@ -172,7 +172,7 @@ const SearchResults = () => { <> {accountId ? ( - + = ({ accountId, aliases }) => { if (!added && accountId !== me) { button = ( - + ); } diff --git a/packages/pl-fe/src/pages/timelines/remote-timeline.tsx b/packages/pl-fe/src/pages/timelines/remote-timeline.tsx index 89588ed2a..b3d57af0a 100644 --- a/packages/pl-fe/src/pages/timelines/remote-timeline.tsx +++ b/packages/pl-fe/src/pages/timelines/remote-timeline.tsx @@ -4,9 +4,9 @@ import { useHistory } from 'react-router-dom'; import { fetchPublicTimeline } from 'pl-fe/actions/timelines'; import { useRemoteStream } from 'pl-fe/api/hooks/streaming/use-remote-stream'; -import IconButton from 'pl-fe/components/icon-button'; import Column from 'pl-fe/components/ui/column'; import HStack from 'pl-fe/components/ui/hstack'; +import IconButton from 'pl-fe/components/ui/icon-button'; import Text from 'pl-fe/components/ui/text'; import PinnedHostsPicker from 'pl-fe/features/remote-timeline/components/pinned-hosts-picker'; import Timeline from 'pl-fe/features/ui/components/timeline'; @@ -52,7 +52,7 @@ const RemoteTimelinePage: React.FC = ({ params }) => { {!pinned && ( - +