From 17af994a05cb933c3898a8740954dfd8b4802a99 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 23 Jan 2025 14:01:11 +0100 Subject: [PATCH] [Glitch] Add information about alt text to alt text modal in web UI Port 0885c316331cf4d314fb6dc3f2e057a6d2ccdfaf to glitch-soc Signed-off-by: Claire --- .../alt_text_modal/components/info_button.tsx | 81 +++++++++++++++++++ .../glitch/features/alt_text_modal/index.tsx | 14 +++- .../flavours/glitch/styles/components.scss | 42 ++++++++++ .../flavours/glitch/styles/forms.scss | 7 +- 4 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 app/javascript/flavours/glitch/features/alt_text_modal/components/info_button.tsx diff --git a/app/javascript/flavours/glitch/features/alt_text_modal/components/info_button.tsx b/app/javascript/flavours/glitch/features/alt_text_modal/components/info_button.tsx new file mode 100644 index 0000000000..9a3b8e4a5c --- /dev/null +++ b/app/javascript/flavours/glitch/features/alt_text_modal/components/info_button.tsx @@ -0,0 +1,81 @@ +import { useState, useRef, useCallback, useId } from 'react'; + +import { FormattedMessage, useIntl, defineMessages } from 'react-intl'; + +import classNames from 'classnames'; + +import Overlay from 'react-overlays/Overlay'; + +import QuestionMarkIcon from '@/material-icons/400-24px/question_mark.svg?react'; +import { Icon } from 'flavours/glitch/components/icon'; + +const messages = defineMessages({ + help: { id: 'info_button.label', defaultMessage: 'Help' }, +}); + +export const InfoButton: React.FC = () => { + const intl = useIntl(); + const [open, setOpen] = useState(false); + const triggerRef = useRef(null); + const accessibilityId = useId(); + + const handleClick = useCallback(() => { + setOpen(!open); + }, [open, setOpen]); + + return ( + <> + + + + {({ props }) => ( +
+

{node}

, + p: (node) =>

{node}

, + ul: (node) =>
    {node}
, + li: (node) =>
  • {node}
  • , + }} + /> +
    + )} +
    + + ); +}; diff --git a/app/javascript/flavours/glitch/features/alt_text_modal/index.tsx b/app/javascript/flavours/glitch/features/alt_text_modal/index.tsx index 94d39cb2ba..b9ce7e710f 100644 --- a/app/javascript/flavours/glitch/features/alt_text_modal/index.tsx +++ b/app/javascript/flavours/glitch/features/alt_text_modal/index.tsx @@ -36,6 +36,8 @@ import type { MediaAttachment } from 'flavours/glitch/models/media_attachment'; import { useAppSelector, useAppDispatch } from 'flavours/glitch/store'; import { assetHost } from 'flavours/glitch/utils/config'; +import { InfoButton } from './components/info_button'; + const messages = defineMessages({ placeholderVisual: { id: 'alt_text_modal.describe_for_people_with_visual_impairments', @@ -504,6 +506,13 @@ export const AltTextModal = forwardRef>(
    + + +
    + - +
    diff --git a/app/javascript/flavours/glitch/styles/components.scss b/app/javascript/flavours/glitch/styles/components.scss index 07f2bdbe8c..52f4490d76 100644 --- a/app/javascript/flavours/glitch/styles/components.scss +++ b/app/javascript/flavours/glitch/styles/components.scss @@ -50,6 +50,34 @@ } } +.help-button { + background: $ui-button-background-color; + border: 0; + color: $ui-button-color; + border-radius: 20px; + cursor: pointer; + width: 24px; + height: 24px; + display: flex; + align-items: center; + justify-content: center; + + &:active, + &:focus, + &:hover { + background-color: $ui-button-focus-background-color; + } + + &:focus-visible { + outline: $ui-button-icon-focus-outline; + } + + .icon { + width: 14px; + height: 14px; + } +} + .button { background-color: $ui-button-background-color; border: 10px none; @@ -6429,6 +6457,20 @@ a.status-card { } } + &__popout { + background: var(--dropdown-background-color); + backdrop-filter: var(--background-filter); + border: 1px solid var(--dropdown-border-color); + box-shadow: var(--dropdown-shadow); + max-width: 320px; + padding: 16px; + border-radius: 8px; + z-index: 9999 !important; + font-size: 14px; + line-height: 20px; + color: $darker-text-color; + } + .copy-paste-text { margin-bottom: 0; } diff --git a/app/javascript/flavours/glitch/styles/forms.scss b/app/javascript/flavours/glitch/styles/forms.scss index 0e257fe9db..16f5ae0f2d 100644 --- a/app/javascript/flavours/glitch/styles/forms.scss +++ b/app/javascript/flavours/glitch/styles/forms.scss @@ -83,9 +83,12 @@ code { &__toolbar { margin-top: 16px; display: flex; - justify-content: space-between; align-items: center; gap: 16px; + + .character-counter { + flex: 0 0 auto; + } } &.hidden { @@ -566,7 +569,7 @@ code { margin-bottom: 15px; } - button:not(.button, .link-button) { + button:not(.button, .link-button, .help-button) { display: block; width: 100%; border: 0;