From 0d489fecba646c0bc26308bb6386080a8521bb3e Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 8 Jan 2025 18:15:40 +0100 Subject: [PATCH] WIP: Change design of edit media modal in web UI --- app/javascript/mastodon/actions/compose.js | 2 +- app/javascript/mastodon/components/button.tsx | 3 + .../mastodon/components/follow_button.tsx | 9 +- app/javascript/mastodon/components/gifv.tsx | 29 +- .../features/alt_text_modal/index.tsx | 244 ++++++++++ .../mastodon/features/audio/index.jsx | 12 +- .../compose/components/character_counter.jsx | 18 - .../compose/components/character_counter.tsx | 16 + .../compose/components/compose_form.jsx | 1 + .../components/notification_follow.tsx | 4 +- .../ui/components/focal_point_modal.jsx | 438 ------------------ .../features/ui/components/modal_root.jsx | 4 +- .../styles/mastodon/components.scss | 151 ++---- app/javascript/styles/mastodon/forms.scss | 28 +- app/views/admin/relays/index.html.haml | 2 +- .../otp_authentication/show.html.haml | 2 +- .../webauthn_credentials/index.html.haml | 2 +- .../index.html.haml | 2 +- package.json | 2 +- yarn.lock | 117 ++--- 20 files changed, 397 insertions(+), 689 deletions(-) create mode 100644 app/javascript/mastodon/features/alt_text_modal/index.tsx delete mode 100644 app/javascript/mastodon/features/compose/components/character_counter.jsx create mode 100644 app/javascript/mastodon/features/compose/components/character_counter.tsx delete mode 100644 app/javascript/mastodon/features/ui/components/focal_point_modal.jsx diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js index aa1c6de20e..d70834cec6 100644 --- a/app/javascript/mastodon/actions/compose.js +++ b/app/javascript/mastodon/actions/compose.js @@ -414,7 +414,7 @@ export function initMediaEditModal(id) { dispatch(openModal({ modalType: 'FOCAL_POINT', - modalProps: { id }, + modalProps: { mediaId: id }, })); }; } diff --git a/app/javascript/mastodon/components/button.tsx b/app/javascript/mastodon/components/button.tsx index b349a83f2b..a527468f65 100644 --- a/app/javascript/mastodon/components/button.tsx +++ b/app/javascript/mastodon/components/button.tsx @@ -7,6 +7,7 @@ interface BaseProps extends Omit, 'children'> { block?: boolean; secondary?: boolean; + compact?: boolean; dangerous?: boolean; } @@ -27,6 +28,7 @@ export const Button: React.FC = ({ disabled, block, secondary, + compact, dangerous, className, title, @@ -47,6 +49,7 @@ export const Button: React.FC = ({ + + + + ); +}; + +const Preview: React.FC<{ mediaId: string }> = ({ mediaId }) => { + const media = useAppSelector((state) => + state.compose.get('media_attachments').find((x) => x.get('id') === mediaId), + ); + const account = useAppSelector((state) => + me ? state.accounts.get(me) : undefined, + ); + + if (media.get('type') === 'image') { + return ; + } else if (media.get('type') === 'gifv') { + return ; + } else if (media.get('type') === 'video') { + return ( +