Merge pull request #3556 from glitch-soc/glitch-soc/merge-upstream

Merge upstream changes up to 52b781c2f4
This commit is contained in:
Claire authored and GitHub committed 2026-06-29 17:05:29 +02:00
commit 38440f8bb2
178 files changed
+2157 -1159

No files matched your search

+1 -1
View File
@@ -1 +1 @@
24.17
24.18
+12 -1
View File
@@ -84,7 +84,7 @@ const preview: Preview = {
// Get the locale from the global toolbar
// and merge it with any parameters or args state.
const { locale } = globals as { locale: string };
const { state = {} } = parameters;
const { state = {}, stateFn } = parameters;
const argsState: Record<string, unknown> = {};
for (const [key, value] of Object.entries(args)) {
@@ -106,6 +106,16 @@ const preview: Preview = {
}
}
let stateFnState: Record<string, unknown> = {};
if (typeof stateFn === 'function') {
stateFnState =
(
stateFn as (
args: Record<string, unknown>,
) => Record<string, unknown> | undefined | null
)(args) ?? {};
}
const reducer = reducerWithInitialState(
{
meta: {
@@ -113,6 +123,7 @@ const preview: Preview = {
},
},
state as Record<string, unknown>,
stateFnState,
argsState,
);
+6 -5
View File
@@ -292,7 +292,7 @@ GEM
activesupport (>= 5.1)
haml (>= 4.0.6)
railties (>= 5.1)
haml_lint (0.73.0)
haml_lint (0.74.0)
haml (>= 5.0)
parallel (>= 1.10)
rainbow
@@ -354,7 +354,7 @@ GEM
azure-blob (~> 0.5.2)
hashie (~> 5.0)
jmespath (1.6.2)
json (2.19.9)
json (2.20.0)
json-canonicalization (1.0.0)
json-jwt (1.17.1)
activesupport (>= 4.2)
@@ -832,9 +832,10 @@ GEM
concurrent-ruby (~> 1.0, >= 1.0.5)
sidekiq (>= 7.0.0, < 9.0.0)
thor (>= 1.0, < 3.0)
simple-navigation (4.4.1)
activesupport (>= 2.3.2)
ostruct
simple-navigation (4.5.0)
activesupport (>= 6.1.0)
json
zeitwerk
simple_form (5.4.1)
actionpack (>= 7.0)
activemodel (>= 7.0)
+6
View File
@@ -9,6 +9,12 @@ module SettingsHelper
LanguagesHelper.sorted_locale_keys(I18n.available_locales)
end
def inline_qrcode_svg(code)
code
.as_svg(padding: 0, module_size: 4, use_path: true)
.html_safe # rubocop:disable Rails/OutputSafety
end
def featured_tags_hint(recently_used_tags)
recently_used_tags.present? &&
safe_join(
-8
View File
@@ -522,14 +522,6 @@ on('click', '.rules-list button', ({ target }) => {
* don't produce accessible markup (simple-forms & simple-navigation)
*/
function applyRailsA11yPatches() {
/**
* Mark current navigation item with aria-current
*/
const activeNavLink = document.querySelector(
'.simple-navigation-active-leaf a.selected',
);
activeNavLink?.setAttribute('aria-current', 'page');
/**
* Hides the asterisk added to labels of required form fields
* from assistive tech. (Those fields already have the `required` attribute)
@@ -20,7 +20,7 @@ export function normalizeStatus(
) {
const normalStatus: StatusShape = {
hidden: normalOldStatus?.hidden ?? false,
collapsed: normalOldStatus?.collapsed ?? false,
collapsed: normalOldStatus?.collapsed ?? null,
content: '',
contentHtml: '',
muted: false,
@@ -1,12 +1,10 @@
import { useCallback, useId, useRef, useState } from 'react';
import { useCallback, useId, useState } from 'react';
import type { FC } from 'react';
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
import classNames from 'classnames';
import Overlay from 'react-overlays/esm/Overlay';
import { useAccount } from '@/flavours/glitch/hooks/useAccount';
import { useRelationship } from '@/flavours/glitch/hooks/useRelationship';
import { useAppSelector } from '@/flavours/glitch/store';
@@ -20,6 +18,7 @@ import { CopyButton } from '../copy_button';
import { DisplayName } from '../display_name';
import { Icon } from '../icon';
import { NavigationFocusTarget } from '../navigation_focus_target';
import { Popover } from '../popover';
import { AccountBadges } from './badges';
import classes from './styles.module.scss';
@@ -82,7 +81,8 @@ const AccountNameHelp: FC<{
const accessibilityId = useId();
const intl = useIntl();
const [open, setOpen] = useState(false);
const triggerRef = useRef<HTMLButtonElement>(null);
const [triggerElement, setTriggerElement] =
useState<HTMLButtonElement | null>(null);
const handleClick = useCallback(() => {
setOpen((prev) => !prev);
@@ -94,7 +94,7 @@ const AccountNameHelp: FC<{
<>
<button
type='button'
ref={triggerRef}
ref={setTriggerElement}
className={classes.handleHelpButton}
onClick={handleClick}
aria-expanded={open}
@@ -108,12 +108,11 @@ const AccountNameHelp: FC<{
/>
</button>
<Overlay
show={open}
rootClose
target={triggerRef as React.RefObject<HTMLButtonElement>}
onHide={handleClick}
offset={[5, 5]}
<Popover
isOpen={open}
reference={triggerElement}
onClose={handleClick}
offset={5}
>
{({ props }) => (
<div
@@ -192,7 +191,7 @@ const AccountNameHelp: FC<{
</CopyButton>
</div>
)}
</Overlay>
</Popover>
</>
);
};
@@ -4,22 +4,14 @@ import { FormattedMessage, useIntl } from 'react-intl';
import classNames from 'classnames';
import type {
OffsetValue,
UsePopperOptions,
} from 'react-overlays/esm/usePopper';
import Overlay from 'react-overlays/Overlay';
import CloseIcon from '@/material-icons/400-24px/close.svg?react';
import { useSelectableClick } from 'flavours/glitch/hooks/useSelectableClick';
import { IconButton } from '../icon_button';
import { Popover } from '../popover';
import classes from './styles.module.scss';
const offset = [0, 4] as OffsetValue;
const popperConfig = { strategy: 'fixed' } as UsePopperOptions;
export const AltTextBadge: React.FC<{
description: string;
className?: string;
@@ -28,7 +20,9 @@ export const AltTextBadge: React.FC<{
const uniqueId = useId();
const popoverId = `${uniqueId}-popover`;
const titleId = `${uniqueId}-title`;
const buttonRef = useRef<HTMLButtonElement>(null);
const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(
null,
);
const popoverRef = useRef<HTMLDivElement>(null);
const [open, setOpen] = useState(false);
@@ -41,8 +35,8 @@ export const AltTextBadge: React.FC<{
const handleClose = useCallback(() => {
setOpen(false);
buttonRef.current?.focus();
}, [setOpen]);
buttonElement?.focus();
}, [buttonElement]);
const [handleMouseDown, handleMouseUp] = useSelectableClick(handleClose);
@@ -50,7 +44,7 @@ export const AltTextBadge: React.FC<{
<>
<button
type='button'
ref={buttonRef}
ref={setButtonElement}
className={classNames('media-gallery__alt__label', className)}
onClick={handleClick}
aria-expanded={open}
@@ -60,15 +54,12 @@ export const AltTextBadge: React.FC<{
ALT
</button>
<Overlay
rootClose
onHide={handleClose}
show={open}
target={buttonRef as React.RefObject<HTMLButtonElement>}
<Popover
isOpen={open}
onClose={handleClose}
reference={buttonElement}
placement='top-end'
flip
offset={offset}
popperConfig={popperConfig}
offset={4}
>
{({ props }) => (
<div {...props} className='hover-card-controller'>
@@ -105,7 +96,7 @@ export const AltTextBadge: React.FC<{
</div>
</div>
)}
</Overlay>
</Popover>
</>
);
};
@@ -5,14 +5,13 @@ import classNames from 'classnames';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import Overlay from 'react-overlays/Overlay';
import AutosuggestAccountContainer from '../features/compose/containers/autosuggest_account_container';
import { AutosuggestEmoji } from './autosuggest_emoji';
import { AutosuggestHashtag } from './autosuggest_hashtag';
import { LocalCustomEmojiProvider } from './emoji/context';
import { textAtCursorMatchesToken } from './autosuggest/utils';
import { Popover } from './popover';
export default class AutosuggestInput extends ImmutablePureComponent {
@@ -129,6 +128,10 @@ export default class AutosuggestInput extends ImmutablePureComponent {
this.setState({ focused: true });
};
onCloseMenu = () => {
this.setState({ suggestionsHidden: true });
};
onSuggestionClick = (e) => {
const suggestion = this.props.suggestions.get(e.currentTarget.getAttribute('data-index'));
e.preventDefault();
@@ -197,7 +200,12 @@ export default class AutosuggestInput extends ImmutablePureComponent {
/>
<LocalCustomEmojiProvider>
<Overlay show={!(suggestionsHidden || suggestions.isEmpty())} offset={[0, 0]} placement='bottom' target={this.input} popperConfig={{ strategy: 'fixed' }}>
<Popover
reference={this.input}
isOpen={!(suggestionsHidden || suggestions.isEmpty())}
onClose={this.onCloseMenu}
flip={false}
>
{({ props }) => (
<div {...props}>
<div className='autosuggest-textarea__suggestions' style={{ width: this.input?.clientWidth }}>
@@ -205,7 +213,7 @@ export default class AutosuggestInput extends ImmutablePureComponent {
</div>
</div>
)}
</Overlay>
</Popover>
</LocalCustomEmojiProvider>
</div>
);
@@ -5,7 +5,6 @@ import classNames from 'classnames';
import ImmutablePropTypes from 'react-immutable-proptypes';
import Overlay from 'react-overlays/Overlay';
import Textarea from 'react-textarea-autosize';
import AutosuggestAccountContainer from '../features/compose/containers/autosuggest_account_container';
@@ -14,6 +13,7 @@ import { AutosuggestEmoji } from './autosuggest_emoji';
import { AutosuggestHashtag } from './autosuggest_hashtag';
import { LocalCustomEmojiProvider } from './emoji/context';
import { textAtCursorMatchesToken } from './autosuggest/utils';
import { Popover } from './popover';
const AutosuggestTextarea = forwardRef(({
value,
@@ -36,6 +36,7 @@ const AutosuggestTextarea = forwardRef(({
const [suggestionsHidden, setSuggestionsHidden] = useState(true);
const [selectedSuggestion, setSelectedSuggestion] = useState(0);
const [textareaElement, setTextareaElement] = useState(null);
const lastTokenRef = useRef(null);
const tokenStartRef = useRef(0);
@@ -110,7 +111,7 @@ const AutosuggestTextarea = forwardRef(({
onKeyDown(e);
}, [disabled, suggestions, suggestionsHidden, selectedSuggestion, setSelectedSuggestion, setSuggestionsHidden, onSuggestionSelected, onKeyDown]);
const handleBlur = useCallback(() => {
const closeMenu = useCallback(() => {
setSuggestionsHidden(true);
}, [setSuggestionsHidden]);
@@ -173,10 +174,15 @@ const AutosuggestTextarea = forwardRef(({
);
};
const handleRef = useCallback((element) => {
textareaRef.current = element;
setTextareaElement(element);
}, []);
return (
<div className={classNames('autosuggest-textarea', className)}>
<Textarea
ref={textareaRef}
ref={handleRef}
className='autosuggest-textarea__textarea'
disabled={disabled}
placeholder={placeholder}
@@ -186,7 +192,7 @@ const AutosuggestTextarea = forwardRef(({
onKeyDown={handleKeyDown}
onKeyUp={onKeyUp}
onFocus={handleFocus}
onBlur={handleBlur}
onBlur={closeMenu}
onPaste={handlePaste}
onDrop={handleDrop}
dir='auto'
@@ -196,15 +202,20 @@ const AutosuggestTextarea = forwardRef(({
/>
<LocalCustomEmojiProvider>
<Overlay show={!(suggestionsHidden || suggestions.isEmpty())} offset={[0, 0]} placement='bottom' target={textareaRef} popperConfig={{ strategy: 'fixed' }}>
<Popover
matchReferenceWidth
isOpen={!(suggestionsHidden || suggestions.isEmpty())}
onClose={closeMenu}
reference={textareaElement}
>
{({ props }) => (
<div {...props}>
<div className='autosuggest-textarea__suggestions' style={{ width: textareaRef.current?.clientWidth }}>
<div className='autosuggest-textarea__suggestions' style={{ width: textareaElement?.clientWidth }}>
{suggestions.map(renderSuggestion)}
</div>
</div>
)}
</Overlay>
</Popover>
</LocalCustomEmojiProvider>
</div>
);
@@ -1,4 +1,4 @@
import { useCallback, useId, useMemo, useRef, useState } from 'react';
import { useCallback, useId, useMemo, useState } from 'react';
import type { ComponentPropsWithoutRef, FC } from 'react';
import { useIntl } from 'react-intl';
@@ -6,15 +6,12 @@ import type { MessageDescriptor } from 'react-intl';
import classNames from 'classnames';
import Overlay from 'react-overlays/Overlay';
import UnfoldMoreIcon from '@/material-icons/400-24px/unfold_more.svg?react';
import type { SelectItem } from '../dropdown_selector';
import { DropdownSelector } from '../dropdown_selector';
import { Icon } from '../icon';
import { matchWidth } from './utils';
import { Popover } from '../popover';
interface DropdownProps {
disabled?: boolean;
@@ -42,7 +39,9 @@ export const Dropdown: FC<
...buttonProps
}) => {
const intl = useIntl();
const buttonRef = useRef<HTMLButtonElement>(null);
const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(
null,
);
const uniqueId = useId();
const buttonId = id ?? `${uniqueId}-button`;
const listboxId = `${uniqueId}-listbox`;
@@ -52,16 +51,16 @@ export const Dropdown: FC<
const handleToggle = useCallback(() => {
if (!disabled) {
setOpen((prevOpen) => {
buttonRef.current?.focus();
buttonElement?.focus();
return !prevOpen;
});
}
}, [disabled]);
}, [buttonElement, disabled]);
const handleClose = useCallback(() => {
setOpen(false);
buttonRef.current?.focus();
}, []);
buttonElement?.focus();
}, [buttonElement]);
const currentText = useMemo(
() =>
@@ -93,7 +92,7 @@ export const Dropdown: FC<
},
className,
)}
ref={buttonRef}
ref={setButtonElement}
>
{currentText}
<Icon
@@ -103,17 +102,12 @@ export const Dropdown: FC<
/>
</button>
<Overlay
show={open}
offset={[0, 0]}
<Popover
matchReferenceWidth
isOpen={open}
placement='bottom-start'
onHide={handleClose}
flip
target={buttonRef as React.RefObject<HTMLButtonElement>}
popperConfig={{
strategy: 'fixed',
modifiers: [matchWidth],
}}
onClose={handleClose}
reference={buttonElement}
>
{({ props, placement }) => (
<div {...props} className={`${classPrefix}__overlay`}>
@@ -135,7 +129,7 @@ export const Dropdown: FC<
</div>
</div>
)}
</Overlay>
</Popover>
</>
);
};
@@ -1,17 +0,0 @@
import type { Modifier, UsePopperState } from 'react-overlays/esm/usePopper';
export const matchWidth: Modifier<'sameWidth', UsePopperState> = {
name: 'sameWidth',
enabled: true,
phase: 'beforeWrite',
requires: ['computeStyles'],
fn: ({ state }) => {
if (state.styles.popper) {
state.styles.popper.width = `${state.rects.reference.width}px`;
}
},
effect: ({ state }) => {
const reference = state.elements.reference as HTMLElement;
state.elements.popper.style.width = `${reference.offsetWidth}px`;
},
};
@@ -13,13 +13,6 @@ import { Link } from 'react-router-dom';
import type { Map as ImmutableMap } from 'immutable';
import type {
OffsetValue,
UsePopperOptions,
Placement,
} from 'react-overlays/esm/usePopper';
import Overlay from 'react-overlays/Overlay';
import { fetchRelationships } from 'flavours/glitch/actions/accounts';
import {
openDropdownMenu,
@@ -40,6 +33,8 @@ import { useAppDispatch, useAppSelector } from 'flavours/glitch/store';
import { Icon } from './icon';
import type { IconProp } from './icon';
import { IconButton } from './icon_button';
import type { PopoverProps } from './popover';
import { Popover } from './popover';
let id = 0;
@@ -302,8 +297,8 @@ interface DropdownProps<Item extends object | null = MenuItem> {
title?: string;
disabled?: boolean;
scrollable?: boolean;
placement?: Placement;
offset?: OffsetValue;
placement?: PopoverProps['placement'];
offset?: PopoverProps['offset'];
/**
* Prevent the `ScrollableList` with this scrollKey
* from being scrolled while the dropdown is open
@@ -321,8 +316,6 @@ interface DropdownProps<Item extends object | null = MenuItem> {
onItemClick?: ItemClickFn<Item>;
}
const popperConfig = { strategy: 'fixed' } as UsePopperOptions;
export const Dropdown = <Item extends object | null = MenuItem>({
children,
icon,
@@ -334,7 +327,7 @@ export const Dropdown = <Item extends object | null = MenuItem>({
disabled,
scrollable,
placement = 'bottom',
offset = [5, 5],
offset = 5,
status,
needsStatusRefresh,
forceDropdown = false,
@@ -352,7 +345,9 @@ export const Dropdown = <Item extends object | null = MenuItem>({
);
const [currentId] = useState(id++);
const open = currentId === openDropdownId;
const buttonRef = useRef<HTMLButtonElement>(null);
const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(
null,
);
const menuId = useId();
const prefetchAccountId = status
? status.getIn(['account', 'id'])
@@ -360,8 +355,8 @@ export const Dropdown = <Item extends object | null = MenuItem>({
const statusId = status?.get('id') as string | undefined;
const handleClose = useCallback(() => {
if (buttonRef.current) {
buttonRef.current.focus({ preventScroll: true });
if (buttonElement) {
buttonElement.focus({ preventScroll: true });
}
dispatch(
@@ -372,7 +367,7 @@ export const Dropdown = <Item extends object | null = MenuItem>({
);
dispatch(closeDropdownMenu({ id: currentId }));
}, [dispatch, currentId]);
}, [buttonElement, dispatch, currentId]);
const handleItemClick = useCallback(
(e: React.MouseEvent) => {
@@ -489,7 +484,7 @@ export const Dropdown = <Item extends object | null = MenuItem>({
onBlur: unsetIsKeypress,
'aria-expanded': open,
'aria-controls': menuId,
ref: buttonRef,
ref: setButtonElement,
};
if (children) {
@@ -513,22 +508,16 @@ export const Dropdown = <Item extends object | null = MenuItem>({
<>
{button}
<Overlay
show={open}
<Popover
isOpen={open}
onClose={handleClose}
offset={offset}
placement={placement}
flip
target={buttonRef as React.RefObject<HTMLButtonElement>}
popperConfig={popperConfig}
reference={buttonElement}
>
{({ props, arrowProps, placement }) => (
{({ props, placement }) => (
<div {...props} className={className} id={menuId}>
<div className={`dropdown-animation dropdown-menu ${placement}`}>
<div
className={`dropdown-menu__arrow ${placement}`}
{...arrowProps}
/>
<DropdownMenu
items={items}
loading={loading}
@@ -542,7 +531,7 @@ export const Dropdown = <Item extends object | null = MenuItem>({
</div>
</div>
)}
</Overlay>
</Popover>
</>
);
};
@@ -14,16 +14,13 @@ import { useIntl } from 'react-intl';
import classNames from 'classnames';
import Overlay from 'react-overlays/Overlay';
import KeyboardArrowDownIcon from '@/material-icons/400-24px/keyboard_arrow_down.svg?react';
import KeyboardArrowUpIcon from '@/material-icons/400-24px/keyboard_arrow_up.svg?react';
import SearchIcon from '@/material-icons/400-24px/search.svg?react';
import { matchWidth } from 'flavours/glitch/components/dropdown/utils';
import { IconButton } from 'flavours/glitch/components/icon_button';
import { useOnClickOutside } from 'flavours/glitch/hooks/useOnClickOutside';
import { LoadingIndicator } from '../loading_indicator';
import { Popover } from '../popover';
import classes from './combobox.module.scss';
import { FormFieldWrapper } from './form_field_wrapper';
@@ -236,8 +233,12 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
) => {
const intl = useIntl();
const wrapperRef = useRef<HTMLDivElement>(null);
const inputRef = useRef<HTMLInputElement>(null);
const popoverRef = useRef<HTMLDivElement>(null);
const [inputElement, setInputElement] = useState<HTMLInputElement | null>(
null,
);
const [popoverElement, setPopoverElement] = useState<HTMLDivElement | null>(
null,
);
// This ref tracks whether the menu was just closed following a
// selection, and prevents the menu from re-opening again
@@ -275,24 +276,27 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
const openMenu = useCallback(() => {
setShouldMenuOpen(true);
inputRef.current?.focus();
}, []);
inputElement?.focus();
}, [inputElement]);
const closeMenu = useCallback(() => {
setShouldMenuOpen(false);
}, []);
const highlightItem = useCallback((id: string | null) => {
setHighlightedItemId(id);
if (id) {
const itemElement = popoverRef.current?.querySelector<HTMLLIElement>(
`[data-item-id='${id}']`,
);
if (itemElement && popoverRef.current) {
scrollItemIntoView(itemElement, popoverRef.current);
const highlightItem = useCallback(
(id: string | null) => {
setHighlightedItemId(id);
if (id) {
const itemElement = popoverElement?.querySelector<HTMLLIElement>(
`[data-item-id='${id}']`,
);
if (itemElement && popoverElement) {
scrollItemIntoView(itemElement, popoverElement);
}
}
}
}, []);
},
[popoverElement],
);
const resetHighlight = useCallback(() => {
const firstItem = flatItems[0];
@@ -353,9 +357,16 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
}
}
}
inputRef.current?.focus();
inputElement?.focus();
},
[closeMenu, closeOnSelect, getIsItemDisabled, flatItems, onSelectItem],
[
flatItems,
inputElement,
getIsItemDisabled,
onSelectItem,
closeOnSelect,
closeMenu,
],
);
const handleSelectItem = useCallback(
@@ -406,8 +417,6 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
[getItemId, highlightItem, highlightedItemId, flatItems],
);
useOnClickOutside(wrapperRef, closeMenu);
const handleInputKeyDown = useCallback(
(e: React.KeyboardEvent<HTMLInputElement>) => {
onKeyDown?.(e);
@@ -489,9 +498,9 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
);
});
const mergeRefs = useCallback(
const mergeInputRefs = useCallback(
(element: HTMLInputElement | null) => {
inputRef.current = element;
setInputElement(element);
if (typeof ref === 'function') {
ref(element);
} else if (ref) {
@@ -525,7 +534,7 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
onKeyDown={handleInputKeyDown}
icon={icon ?? undefined}
className={classNames(classes.input, className)}
ref={mergeRefs}
ref={mergeInputRefs}
/>
{hasMenuContent && (
<IconButton
@@ -551,20 +560,23 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
<span role='status' aria-live='polite' className='sr-only'>
{isMenuOpen && statusMessage}
</span>
<Overlay
show={isMenuOpen}
offset={[0, 1]}
<Popover
matchReferenceWidth
isOpen={isMenuOpen}
onClose={closeMenu}
offset={1}
placement='bottom-start'
onHide={closeMenu}
ref={popoverRef}
target={inputRef as React.RefObject<HTMLInputElement>}
container={wrapperRef as React.RefObject<HTMLDivElement>}
popperConfig={{
modifiers: [matchWidth],
}}
strategy='absolute'
popoverElement={popoverElement}
reference={inputElement}
container={null}
>
{({ props, placement }) => (
<div {...props} className={classNames(classes.popover, placement)}>
<div
{...props}
ref={setPopoverElement}
className={classNames(classes.popover, placement)}
>
<StatusMessageWrapper
showStatus={showStatusMessageInMenu}
isLoading={isLoading}
@@ -608,7 +620,7 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
</StatusMessageWrapper>
</div>
)}
</Overlay>
</Popover>
</div>
);
};
@@ -2,23 +2,18 @@ import { useEffect, useRef, useState, useCallback } from 'react';
import { useLocation } from 'react-router-dom';
import type {
OffsetValue,
UsePopperOptions,
} from 'react-overlays/esm/usePopper';
import Overlay from 'react-overlays/Overlay';
import { HoverCardAccount } from 'flavours/glitch/components/hover_card_account';
import type { PopoverProps } from 'flavours/glitch/components/popover';
import { Popover } from 'flavours/glitch/components/popover';
import { useTimeout } from 'flavours/glitch/hooks/useTimeout';
const offset = [-12, 4] as OffsetValue;
const offset: PopoverProps['offset'] = { crossAxis: -12, mainAxis: 4 } as const;
const enterDelay = 750;
const leaveDelay = 150;
// Only open the card if the mouse was moved within this time,
// to avoid triggering the card without intentional mouse movement
// (e.g. when content changed underneath the mouse cursor)
const activeMovementThreshold = 150;
const popperConfig = { strategy: 'fixed' } as UsePopperOptions;
const isHoverCardAnchor = (element: HTMLElement) =>
element.matches('[data-hover-card-account]');
@@ -212,21 +207,18 @@ export const HoverCardController: React.FC = () => {
]);
return (
<Overlay
rootClose
onHide={handleClose}
show={open}
target={anchor}
<Popover
onClose={handleClose}
isOpen={open}
reference={anchor}
placement='bottom-start'
flip
offset={offset}
popperConfig={popperConfig}
>
{({ props }) => (
<div {...props} className='hover-card-controller'>
<HoverCardAccount accountId={accountId} ref={cardRef} />
</div>
)}
</Overlay>
</Popover>
);
};
@@ -1,15 +1,15 @@
import { useState, useRef, useCallback, useId } from 'react';
import { useState, useCallback, useId } from 'react';
import { FormattedMessage } from 'react-intl';
import Overlay from 'react-overlays/Overlay';
import { Popover } from './popover';
export const LearnMoreLink: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
const accessibilityId = useId();
const [open, setOpen] = useState(false);
const triggerRef = useRef<HTMLButtonElement>(null);
const [trigger, setTrigger] = useState<HTMLButtonElement | null>(null);
const handleClick = useCallback(() => {
setOpen(!open);
@@ -19,7 +19,7 @@ export const LearnMoreLink: React.FC<{ children: React.ReactNode }> = ({
<>
<button
className='link-button'
ref={triggerRef}
ref={setTrigger}
onClick={handleClick}
aria-expanded={open}
aria-controls={accessibilityId}
@@ -31,13 +31,12 @@ export const LearnMoreLink: React.FC<{ children: React.ReactNode }> = ({
/>
</button>
<Overlay
show={open}
rootClose
onHide={handleClick}
offset={[5, 5]}
<Popover
isOpen={open}
onClose={handleClick}
offset={5}
placement='bottom-end'
target={triggerRef as React.RefObject<HTMLButtonElement>}
reference={trigger}
>
{({ props }) => (
<div
@@ -62,7 +61,7 @@ export const LearnMoreLink: React.FC<{ children: React.ReactNode }> = ({
</div>
</div>
)}
</Overlay>
</Popover>
</>
);
};
@@ -15,7 +15,6 @@ import { fetchPoll, vote } from 'flavours/glitch/actions/polls';
import { Icon } from 'flavours/glitch/components/icon';
import { useIdentity } from 'flavours/glitch/identity_context';
import type * as Model from 'flavours/glitch/models/poll';
import type { Status } from 'flavours/glitch/models/status';
import { useAppDispatch, useAppSelector } from 'flavours/glitch/store';
import { RelativeTimestamp } from './relative_timestamp';
@@ -40,12 +39,18 @@ const isPollExpired = (expiresAt: Model.Poll['expires_at']) =>
interface PollProps {
pollId: string;
status: Status;
accountId: string;
statusUrl: string;
lang?: string;
disabled?: boolean;
}
export const Poll: React.FC<PollProps> = ({ pollId, disabled, status }) => {
export const Poll: React.FC<PollProps> = ({
pollId,
disabled,
accountId,
statusUrl,
}) => {
// Third party hooks
const poll = useAppSelector((state) => state.polls[pollId]);
const identity = useIdentity();
@@ -110,14 +115,22 @@ export const Poll: React.FC<PollProps> = ({ pollId, disabled, status }) => {
openModal({
modalType: 'INTERACTION',
modalProps: {
accountId,
intent: 'vote',
accountId: status.getIn(['account', 'id']),
url: status.get('uri'),
url: statusUrl,
},
}),
);
}
}, [voteDisabled, dispatch, identity, pollId, selected, status]);
}, [
voteDisabled,
dispatch,
identity,
pollId,
selected,
accountId,
statusUrl,
]);
const handleReveal = useCallback(() => {
setRevealed(true);
@@ -0,0 +1,203 @@
import { useEffect } from 'react';
import type {
ReferenceType,
Placement,
OffsetOptions,
Strategy,
} from '@floating-ui/react-dom';
import {
useFloating,
autoUpdate,
inline,
offset as offsetMiddleware,
shift,
flip as flipMiddleware,
size,
hide,
} from '@floating-ui/react-dom';
import { useOnClickOutside } from '@/flavours/glitch/hooks/useOnClickOutside';
import { Portal } from './portal';
export interface PopoverProps {
/**
* Set the visibility of the popover
*/
isOpen?: boolean;
/**
* Callback triggered when the popover needs to be closed
* (e.g. because the Esc key was pressed).
*/
onClose: (e: Event) => void;
/**
* Pass an element that the popover should be attached to.
* Must come from `useState`, not `useRef`.
*/
reference: ReferenceType | null;
/**
* Pass the popover element (useful if you also need the element
* in the parent and already have it in state).
* Must come from `useState`, not `useRef`.
*/
popoverElement?: HTMLElement | null;
/**
* Control which element the popover will be rendered into.
* Passing `null` will render the popover in place.
*/
container?: HTMLElement | null;
/**
* Control where the overlay element is positioned in relation
* to the reference element
*/
placement?: Placement;
/**
* Control the distance between popover and reference
*/
offset?: OffsetOptions;
/**
* Allow the popover to flip to the other side of the reference
* if there's no room in the specified direction. Enabled by default.
*/
flip?: boolean;
/**
* Change the positioning strategy, defaults to 'fixed'
* but can be changed to 'absolute'
*/
strategy?: Strategy;
/**
* Adapt the popover's width to match that of the reference,
* useful when attached to text input.
*/
matchReferenceWidth?: boolean;
/**
* Control whether to close the popover when clicking outside
* of it (enabled by default).
*/
closeOnClickOutside?: boolean;
/**
* Render prop that must return the popover element.
*/
children: (value: {
/**
* The popover's final computed placement. Can be used to
* adjust the popover's style based on its position.
*/
placement: Placement | undefined;
/**
* Re-computes the popover's position – call this when an
* action inside of the popover has changed its size.
*/
update: () => void;
/**
* These props must be passed to the popover element to
* enable it to be sized and positioned. The `ref` prop
* is not passed when the `popoverElement` prop is provided.
*/
props: Record<string, unknown> & {
ref?: React.RefCallback<HTMLElement>;
style: React.CSSProperties;
};
}) => React.ReactNode;
}
export const Popover: React.FC<PopoverProps> = ({
isOpen,
onClose,
reference,
popoverElement,
placement = 'bottom',
offset,
strategy = 'fixed',
flip = true,
container,
matchReferenceWidth = false,
closeOnClickOutside = true,
children,
}) => {
const {
placement: computedPlacement,
update,
refs,
floatingStyles,
middlewareData,
elements,
} = useFloating({
elements: {
reference,
floating: popoverElement,
},
placement,
strategy,
whileElementsMounted: autoUpdate,
middleware: [
offsetMiddleware(offset),
inline(),
shift(),
flip ? flipMiddleware() : null,
matchReferenceWidth
? size({
apply({ rects, elements }) {
Object.assign(elements.floating.style, {
minWidth: `${rects.reference.width}px`,
});
},
})
: null,
hide(),
],
});
// Close when clicking outside the popover
useOnClickOutside(
[
elements.floating,
// Only pass reference if it's not a "virtual element"
elements.reference instanceof Element ? elements.reference : null,
],
(e) => {
onClose(e);
},
isOpen && closeOnClickOutside,
);
// Close when pressing Escape
useEffect(() => {
if (!isOpen) {
return () => null;
}
function closeOnEscape(event: KeyboardEvent) {
if (event.key === 'Escape') {
onClose(event);
}
}
document.addEventListener('keyup', closeOnEscape);
return () => {
document.removeEventListener('keyup', closeOnEscape);
};
}, [isOpen, onClose]);
if (!isOpen) {
return null;
}
return (
<Portal container={container}>
{children({
placement: computedPlacement,
update,
props: {
ref: popoverElement ? undefined : refs.setFloating,
style: floatingStyles,
'data-popover-placement': computedPlacement,
'data-popover-reference-hidden': middlewareData.hide?.referenceHidden,
'data-popover-escaped': middlewareData.hide?.escaped,
},
})}
</Portal>
);
};
@@ -0,0 +1,21 @@
import { createPortal } from 'react-dom';
interface PortalProps {
/**
* The element to render the Portal's children into.
* Must be an object, e.g. the result of a getElementById() call.
* Set to `null` to render the children in place,
* i.e. effectively disable the Portal's functionality
*/
readonly container?: HTMLElement | SVGElement | null;
readonly children?: React.ReactNode;
}
export const Portal: React.FC<PortalProps> = ({
container,
children,
}: PortalProps) => {
if (container === null) return children;
return createPortal(children, container ?? document.body);
};
@@ -187,7 +187,7 @@ const BoostOrQuoteMenu: FC<ReblogButtonProps> = ({ status, counters }) => {
return (
<Dropdown
placement='bottom-start'
offset={[-19, 5]} // This aligns button icon with menu icons
offset={{ mainAxis: 5, crossAxis: -19 }} // This aligns button icon with menu icons
items={items}
renderItem={renderMenuItem}
onOpen={handleDropdownOpen}
@@ -0,0 +1,121 @@
import type { Meta, StoryObj } from '@storybook/react-vite';
import { fn } from 'storybook/test';
import type { StatusTranslation } from '@/flavours/glitch/models/status';
import { statusFactoryState } from '@/testing/factories';
import { StatusContent } from './content';
interface StatusContentProps {
text: string;
collapsible: boolean;
clickable: boolean;
translatable: boolean;
translatedTo?: string;
}
const onClickFn = fn().mockName('onClick');
const onTranslateFn = fn().mockName('onTranslate');
const meta = {
title: 'Components/Status/StatusContent',
render(args) {
return (
<div style={{ width: 'min(600px, 80vw)' }}>
<StatusContent
statusId='1'
collapsible={args.collapsible}
onClick={args.clickable ? onClickFn : undefined}
onTranslate={args.translatable ? onTranslateFn : undefined}
/>
</div>
);
},
args: {
text: 'This is status text.',
collapsible: true,
clickable: true,
translatable: true,
},
argTypes: {
text: {
reduxPath: 'statuses.1.contentHtml',
},
translatedTo: {
control: 'select',
options: ['en', 'de', 'fr'],
},
},
parameters: {
state: {
server: {
translationLanguages: {
item: {
en: ['en', 'de', 'fr'],
},
},
},
},
stateFn(args: StatusContentProps) {
let status = statusFactoryState();
if (args.translatedTo) {
status = status.set('translation', {
contentHtml: `${args.text}<p><em>(in ${args.translatedTo})</em></p>`,
provider: 'Test Translation API',
spoiler_text: '',
spoilerHtml: '',
language: args.translatedTo,
detected_source_language: 'en',
} satisfies StatusTranslation);
}
return {
statuses: {
'1': status,
},
};
},
},
} satisfies Meta<StatusContentProps>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {};
export const ReadMore: Story = {
args: {
text: [
'This is a long-form piece of text that wraps multiple lines.',
'It is here to test what a longer status looks like.',
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'Pellentesque a ante placerat, egestas eros vitae, ornare orci.',
'Phasellus fringilla felis vel purus fermentum, nec viverra eros fringilla.',
'Mauris feugiat metus in dolor elementum, ultricies suscipit sapien tincidunt.',
'Mauris vestibulum urna vel mauris sagittis, a blandit felis cursus.',
'Sed nec sem dictum ligula hendrerit dignissim et non dolor.',
'Cras maximus lorem sit amet aliquet faucibus.',
'Donec tempus lectus vitae laoreet congue.',
'Nulla congue nibh sed eros pulvinar pharetra.',
'Fusce vel nibh quis nisi mollis volutpat quis vel erat.',
'Fusce non metus non sapien volutpat elementum.',
'Aenean elementum ipsum ut neque bibendum, eget blandit ex efficitur.',
'Morbi semper eros at ipsum pellentesque mattis.',
'Donec ultricies ante imperdiet placerat tempus.',
'Vivamus vitae ante sit amet lectus porta mollis quis dictum quam.',
'Cras dignissim ante at turpis scelerisque, non hendrerit ipsum vestibulum.',
'Quisque ac nulla ac sem auctor posuere eget id ex.',
'Phasellus cursus purus sit amet sollicitudin finibus.',
'In varius justo eu metus dapibus, non imperdiet lorem efficitur.',
'Nulla tincidunt odio eget ipsum auctor rhoncus.',
]
.map((text) => `<p>${text}</p>`)
.join('\n'),
},
};
export const Translated: Story = {
args: {
translatedTo: 'fr',
},
};
@@ -0,0 +1,210 @@
import type React from 'react';
import { useCallback } from 'react';
import { FormattedMessage, useIntl } from 'react-intl';
import classnames from 'classnames';
import { toggleStatusCollapse } from '@/flavours/glitch/actions/statuses';
import { useIdentity } from '@/flavours/glitch/identity_context';
import { languages as preloadedLanguages } from '@/flavours/glitch/initial_state';
import type { StatusTranslation } from '@/flavours/glitch/models/status';
import { selectPlainStatus } from '@/flavours/glitch/selectors/statuses';
import { useAppDispatch, useAppSelector } from '@/flavours/glitch/store';
import ChevronRightIcon from '@/material-icons/400-24px/chevron_right.svg?react';
import { EmojiHTML } from '../emoji/html';
import { Icon } from '../icon';
import { Poll } from '../poll';
import { useElementHandledLink } from './handled_link';
const MAX_HEIGHT = 706; // 22px * 32 (+ 2px padding at the top)
export const StatusContent: React.FC<{
statusId: string;
onClick?: React.MouseEventHandler;
onTranslate?: React.MouseEventHandler<HTMLButtonElement>;
collapsible?: boolean;
}> = ({ statusId, onClick, onTranslate, collapsible }) => {
const status = useAppSelector((state) => selectPlainStatus(state, statusId));
const { signedIn } = useIdentity();
const targetLanguages = useAppSelector(
(state) =>
state.server.translationLanguages.item?.[status?.language ?? 'und'],
);
const intl = useIntl();
// Determines if a long post should show the read more button.
const dispatch = useAppDispatch();
const handleCollapse = useCallback(
(node: HTMLDivElement | null) => {
if (!node || status?.collapsed !== null || !collapsible) {
return;
}
const text = node.querySelector(':scope > .status__content__text');
const collapsed =
(node.clientHeight > MAX_HEIGHT ||
(text !== null && text.scrollWidth > text.clientWidth)) &&
!status.spoiler_text;
dispatch(toggleStatusCollapse(status.id, collapsed));
},
[collapsible, status, dispatch],
);
// Trigger the click event if clicking outside a link, button, or label inside a status.
const handleClick: React.MouseEventHandler<HTMLDivElement> = useCallback(
(event) => {
const { target } = event;
if (
!onClick ||
!(target instanceof Element) ||
target.closest(':is(a, button, label)')
) {
return;
}
onClick(event);
},
[onClick],
);
const hrefToMention = useCallback(
(href: string) => status?.mentions.find((item) => item.url === href),
[status?.mentions],
);
const hrefToCollectionId = useCallback(
(href: string) =>
status?.tagged_collections.find((item) => item.url === href)?.id,
[status?.tagged_collections],
);
const htmlHandlers = useElementHandledLink({
hashtagAccountId: status?.account,
hrefToCollectionId,
hrefToMention,
});
if (!status) {
return null;
}
const language = status.translation?.language ?? status.language;
const renderReadMore = !!onClick && status.collapsed;
const readMoreButton = renderReadMore && (
<button
className='status__content__read-more-button'
type='button'
onClick={onClick}
key='read-more'
>
<FormattedMessage id='status.read_more' defaultMessage='Read more' />
<Icon id='angle-right' icon={ChevronRightIcon} />
</button>
);
const renderTranslate =
!!onTranslate &&
signedIn &&
['public', 'unlisted'].includes(status.visibility) &&
status.search_index &&
status.search_index.trim().length > 0 &&
targetLanguages?.includes(intl.locale.replace(/[_-].*/, ''));
const translateButton = renderTranslate && (
<TranslateButton onClick={onTranslate} translation={status.translation} />
);
const poll = !!status.poll && (
<Poll
pollId={status.poll}
statusUrl={status.uri}
accountId={status.account}
lang={language}
/>
);
const content = (
<EmojiHTML
className='status__content__text status__content__text--visible translate'
lang={language}
htmlString={status.translation?.contentHtml ?? status.contentHtml}
extraEmojis={status.emojis}
{...htmlHandlers}
/>
);
const classNames = classnames('status__content', {
'status__content--with-action': onClick,
'status__content--collapsed': renderReadMore,
});
if (!onClick) {
return (
<div className={classNames} ref={handleCollapse}>
{content}
{poll}
{translateButton}
</div>
);
}
/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
return (
<>
<div className={classNames} ref={handleCollapse} onClick={handleClick}>
{content}
{poll}
{translateButton}
</div>
{readMoreButton}
</>
);
/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
};
const TranslateButton: React.FC<{
onClick: React.MouseEventHandler<HTMLButtonElement>;
translation?: StatusTranslation;
}> = ({ translation, onClick }) => {
if (!translation) {
return (
<button
type='button'
className='status__content__translate-button'
onClick={onClick}
>
<FormattedMessage id='status.translate' defaultMessage='Translate' />
</button>
);
}
const language = preloadedLanguages?.find(
(lang) => lang[0] === translation.detected_source_language,
);
const languageName = language
? language[1]
: translation.detected_source_language;
const provider = translation.provider;
return (
<div className='translate-button'>
<button type='button' className='link-button' onClick={onClick}>
<FormattedMessage
id='status.show_original'
defaultMessage='Show original'
/>
</button>
<div className='translate-button__meta'>
<FormattedMessage
id='status.translated_from_with'
defaultMessage='Translated from {lang} using {provider}'
values={{ lang: languageName, provider }}
/>
</div>
</div>
);
};
@@ -1,16 +1,15 @@
import { useEffect, useRef, useState, useId } from 'react';
import { useEffect, useState, useId } from 'react';
import { FormattedMessage, useIntl } from 'react-intl';
import classNames from 'classnames';
import Overlay from 'react-overlays/Overlay';
import { useDismissible } from '@/flavours/glitch/hooks/useDismissible';
import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
import { Button } from '../button';
import { Icon } from '../icon';
import { Popover } from '../popover';
import classes from './remove_quote_hint.module.css';
@@ -28,7 +27,9 @@ export const RemoveQuoteHint: React.FC<{
className?: string;
children: (dismiss: () => void) => React.ReactNode;
}> = ({ canShowHint, className, children }) => {
const anchorRef = useRef<HTMLDivElement>(null);
const [anchorElement, setAnchorElement] = useState<HTMLDivElement | null>(
null,
);
const intl = useIntl();
const { wasDismissed, dismiss } = useDismissible(DISMISSIBLE_BANNER_ID);
@@ -57,16 +58,16 @@ export const RemoveQuoteHint: React.FC<{
}, [shouldShowHint, uniqueId]);
return (
<div className={className} ref={anchorRef}>
<div className={className} ref={setAnchorElement}>
{children(dismiss)}
{shouldShowHint && isOnlyHint && (
<Overlay
show
flip
offset={[12, 10]}
<Popover
isOpen
offset={{ mainAxis: 10, crossAxis: 12 }}
placement='bottom-end'
target={anchorRef as React.RefObject<HTMLDivElement>}
container={anchorRef as React.RefObject<HTMLDivElement>}
reference={anchorElement}
container={anchorElement}
onClose={dismiss}
>
{({ props, placement }) => (
<div
@@ -113,7 +114,7 @@ export const RemoveQuoteHint: React.FC<{
</FormattedMessage>
</div>
)}
</Overlay>
</Popover>
)}
</div>
);
@@ -208,7 +208,7 @@ class StatusContent extends PureComponent {
);
const poll = !!status.get('poll') && (
<Poll pollId={status.get('poll')} status={status} lang={language} />
<Poll pollId={status.get('poll')} statusUrl={status.get('uri')} accountId={status.getIn(['account', 'id'])} lang={language} />
);
if (this.props.onClick) {
@@ -522,14 +522,6 @@ on('click', '.rules-list button', ({ target }) => {
* don't produce accessible markup (simple-forms & simple-navigation)
*/
function applyRailsA11yPatches() {
/**
* Mark current navigation item with aria-current
*/
const activeNavLink = document.querySelector(
'.simple-navigation-active-leaf a.selected',
);
activeNavLink?.setAttribute('aria-current', 'page');
/**
* Hides the asterisk added to labels of required form fields
* from assistive tech. (Those fields already have the `required` attribute)
@@ -5,8 +5,6 @@ import { defineMessages, useIntl } from 'react-intl';
import classNames from 'classnames';
import type { OffsetValue } from 'react-overlays/esm/usePopper';
import type { ModalType } from '@/flavours/glitch/actions/modal';
import { openModal } from '@/flavours/glitch/actions/modal';
import { Dropdown } from '@/flavours/glitch/components/dropdown_menu';
@@ -118,7 +116,7 @@ export const AccountImageEdit: FC<{
<Dropdown
items={items}
placement={location === 'header' ? 'bottom-end' : 'bottom-start'}
offset={popperOffset}
offset={6}
className={classes.imageMenu}
icon='camera'
title={intl.formatMessage(messages.replace)}
@@ -127,5 +125,3 @@ export const AccountImageEdit: FC<{
/>
);
};
const popperOffset = [0, 6] as OffsetValue;
@@ -1,15 +1,14 @@
import { useCallback, useId, useRef, useState } from 'react';
import { useCallback, useId, useState } from 'react';
import type { ChangeEventHandler, FC } from 'react';
import { FormattedMessage } from 'react-intl';
import { useParams } from 'react-router';
import Overlay from 'react-overlays/esm/Overlay';
import { AccountTabs } from '@/flavours/glitch/components/account_header/tabs';
import { Toggle } from '@/flavours/glitch/components/form_fields';
import { Icon } from '@/flavours/glitch/components/icon';
import { Popover } from '@/flavours/glitch/components/popover';
import KeyboardArrowDownIcon from '@/material-icons/400-24px/keyboard_arrow_down.svg?react';
import { useAccountContext } from '../hooks/useAccountContext';
@@ -32,10 +31,12 @@ export const AccountFilters: FC = () => {
const FilterDropdown: FC = () => {
const [open, setOpen] = useState(false);
const buttonRef = useRef<HTMLButtonElement>(null);
const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(
null,
);
const handleClick = useCallback(() => {
setOpen(true);
setOpen((prev) => !prev);
}, []);
const handleHide = useCallback(() => {
setOpen(false);
@@ -55,14 +56,13 @@ const FilterDropdown: FC = () => {
);
const accessibleId = useId();
const containerRef = useRef<HTMLDivElement>(null);
return (
<div ref={containerRef}>
<div>
<button
type='button'
className={classes.filterSelectButton}
ref={buttonRef}
ref={setButtonElement}
onClick={handleClick}
aria-expanded={open}
aria-controls={`${accessibleId}-wrapper`}
@@ -97,13 +97,13 @@ const FilterDropdown: FC = () => {
className={classes.filterSelectIcon}
/>
</button>
<Overlay
show={open}
target={buttonRef as React.RefObject<HTMLButtonElement>}
<Popover
isOpen={open}
reference={buttonElement}
placement='bottom-start'
rootClose
onHide={handleHide}
container={containerRef as React.RefObject<HTMLDivElement>}
onClose={handleHide}
strategy='absolute'
container={null}
>
{({ props }) => (
<div
@@ -138,7 +138,7 @@ const FilterDropdown: FC = () => {
/>
</div>
)}
</Overlay>
</Popover>
</div>
);
};
@@ -1,11 +1,10 @@
import { useState, useRef, useCallback, useId } from 'react';
import { useState, useCallback, useId } from 'react';
import { FormattedMessage, useIntl, defineMessages } from 'react-intl';
import classNames from 'classnames';
import Overlay from 'react-overlays/Overlay';
import { Popover } from '@/flavours/glitch/components/popover';
import QuestionMarkIcon from '@/material-icons/400-24px/question_mark.svg?react';
import { Icon } from 'flavours/glitch/components/icon';
import { useSelectableClick } from 'flavours/glitch/hooks/useSelectableClick';
@@ -17,7 +16,7 @@ const messages = defineMessages({
export const InfoButton: React.FC = () => {
const intl = useIntl();
const [open, setOpen] = useState(false);
const triggerRef = useRef<HTMLButtonElement>(null);
const [trigger, setTrigger] = useState<HTMLButtonElement | null>(null);
const accessibilityId = useId();
const handleClick = useCallback(() => {
@@ -31,7 +30,7 @@ export const InfoButton: React.FC = () => {
<button
type='button'
className={classNames('help-button', { active: open })}
ref={triggerRef}
ref={setTrigger}
onClick={handleClick}
aria-expanded={open}
aria-controls={accessibilityId}
@@ -40,13 +39,12 @@ export const InfoButton: React.FC = () => {
<Icon id='' icon={QuestionMarkIcon} />
</button>
<Overlay
show={open}
rootClose
<Popover
isOpen={open}
placement='top'
onHide={handleClick}
offset={[5, 5]}
target={triggerRef as React.RefObject<HTMLButtonElement>}
onClose={handleClick}
offset={5}
reference={trigger}
>
{({ props }) => (
<div // eslint-disable-line jsx-a11y/no-noninteractive-element-interactions
@@ -82,7 +80,7 @@ export const InfoButton: React.FC = () => {
/>
</div>
)}
</Overlay>
</Popover>
</>
);
};
@@ -1,17 +1,14 @@
import PropTypes from 'prop-types';
import { useCallback, useState, useRef } from 'react';
import Overlay from 'react-overlays/Overlay';
import { useCallback, useState } from 'react';
import { DropdownSelector } from 'flavours/glitch/components/dropdown_selector';
import { IconButton } from 'flavours/glitch/components/icon_button';
import { Popover } from 'flavours/glitch/components/popover';
export const DropdownIconButton = ({ value, disabled, icon, onChange, iconComponent, title, options }) => {
const containerRef = useRef(null);
const [activeElement, setActiveElement] = useState(null);
const [open, setOpen] = useState(false);
const [placement, setPlacement] = useState('bottom');
const [containerElement, setContainerElement] = useState(null);
const handleToggle = useCallback(() => {
if (open && activeElement) {
@@ -31,12 +28,8 @@ export const DropdownIconButton = ({ value, disabled, icon, onChange, iconCompon
setOpen(false);
}, [open, setOpen, activeElement, setActiveElement]);
const handleOverlayEnter = useCallback((state) => {
setPlacement(state.placement);
}, [setPlacement]);
return (
<div ref={containerRef}>
<div ref={setContainerElement}>
<IconButton
disabled={disabled}
icon={icon}
@@ -48,7 +41,12 @@ export const DropdownIconButton = ({ value, disabled, icon, onChange, iconCompon
inverted
/>
<Overlay show={open} offset={[5, 5]} placement={placement} flip target={containerRef} popperConfig={{ strategy: 'fixed', onFirstUpdate: handleOverlayEnter }}>
<Popover
isOpen={open}
offset={5}
reference={containerElement}
onClose={handleClose}
>
{({ props, placement }) => (
<div {...props}>
<div className={`dropdown-animation privacy-dropdown__dropdown ${placement}`}>
@@ -61,7 +59,7 @@ export const DropdownIconButton = ({ value, disabled, icon, onChange, iconCompon
</div>
</div>
)}
</Overlay>
</Popover>
</div>
);
};
@@ -6,11 +6,11 @@ import { defineMessages, FormattedMessage } from 'react-intl';
import classNames from 'classnames';
import { supportsPassiveEvents } from 'detect-passive-events';
import Overlay from 'react-overlays/Overlay';
import MoodIcon from '@/material-icons/400-20px/mood.svg?react';
import { IconButton } from 'flavours/glitch/components/icon_button';
import { IconButton } from '@/flavours/glitch/components/icon_button';
import { injectIntl } from '@/flavours/glitch/components/intl';
import { Popover } from '@/flavours/glitch/components/popover';
import { EmojiPicker as EmojiPickerAsync } from '../../ui/util/async-components';
@@ -175,16 +175,7 @@ class EmojiPickerMenuImpl extends PureComponent {
readyToFocus: false,
};
handleDocumentClick = e => {
if (this.node && !this.node.contains(e.target) && !this.props.pickerButtonRef.contains(e.target)) {
this.props.onClose();
}
};
componentDidMount() {
document.addEventListener('click', this.handleDocumentClick, { capture: true });
document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
// Because of https://github.com/react-bootstrap/react-bootstrap/issues/2614 we need
// to wait for a frame before focusing
requestAnimationFrame(() => {
@@ -196,11 +187,6 @@ class EmojiPickerMenuImpl extends PureComponent {
});
}
componentWillUnmount() {
document.removeEventListener('click', this.handleDocumentClick, { capture: true });
document.removeEventListener('touchend', this.handleDocumentClick, listenerOptions);
}
setRef = c => {
this.node = c;
};
@@ -307,7 +293,7 @@ class EmojiPickerDropdown extends PureComponent {
state = {
active: false,
loading: false,
placement: 'bottom',
target: null,
};
setRef = (c) => {
@@ -344,31 +330,17 @@ class EmojiPickerDropdown extends PureComponent {
}
};
handleKeyDown = e => {
if (e.key === 'Escape') {
this.onHideDropdown();
}
};
setTargetRef = c => {
this.target = c;
};
findTarget = () => {
return this.target;
};
handleOverlayEnter = (state) => {
this.setState({ placement: state.placement });
this.setState({ target: c });
};
render() {
const { intl, onPickEmoji, onSkinTone, skinTone, frequentlyUsedEmojis, disabled } = this.props;
const title = intl.formatMessage(messages.emoji);
const { active, loading, placement } = this.state;
const { active, loading, target } = this.state;
return (
<div className='emoji-picker-dropdown' onKeyDown={this.handleKeyDown} ref={this.setTargetRef}>
<div className='emoji-picker-dropdown' ref={this.setTargetRef}>
<IconButton
title={title}
aria-expanded={active}
@@ -380,23 +352,25 @@ class EmojiPickerDropdown extends PureComponent {
inverted
/>
<Overlay show={active} placement={placement} flip target={this.findTarget} popperConfig={{ strategy: 'fixed', onFirstUpdate: this.handleOverlayEnter }}>
<Popover
isOpen={active}
reference={target}
onClose={this.onHideDropdown}
>
{({ props, placement }) => (
<div {...props} style={{ ...props.style }}>
<div className={`dropdown-animation ${placement}`}>
<EmojiPickerMenu
loading={loading}
onClose={this.onHideDropdown}
onPick={onPickEmoji}
onSkinTone={onSkinTone}
skinTone={skinTone}
frequentlyUsedEmojis={frequentlyUsedEmojis}
pickerButtonRef={this.target}
/>
</div>
<div {...props} className={`dropdown-animation ${placement}`}>
<EmojiPickerMenu
loading={loading}
onClose={this.onHideDropdown}
onPick={onPickEmoji}
onSkinTone={onSkinTone}
skinTone={skinTone}
frequentlyUsedEmojis={frequentlyUsedEmojis}
pickerButtonRef={this.target}
/>
</div>
)}
</Overlay>
</Popover>
</div>
);
}
@@ -8,9 +8,8 @@ import { createSelector } from '@reduxjs/toolkit';
import { Map as ImmutableMap } from 'immutable';
import fuzzysort from 'fuzzysort';
import Overlay from 'react-overlays/Overlay';
import type { State, Placement } from 'react-overlays/usePopper';
import { Popover } from '@/flavours/glitch/components/popover';
import CancelIcon from '@/material-icons/400-24px/cancel-fill.svg?react';
import SearchIcon from '@/material-icons/400-24px/search.svg?react';
import TranslateIcon from '@/material-icons/400-24px/translate.svg?react';
@@ -203,34 +202,13 @@ const LanguageDropdownMenu: React.FC<{
const isSearching = searchValue !== '';
useEffect(() => {
const handleDocumentClick = (e: MouseEvent) => {
if (
nodeRef.current &&
e.target instanceof HTMLElement &&
!nodeRef.current.contains(e.target)
) {
onClose();
e.stopPropagation();
}
};
document.addEventListener('click', handleDocumentClick, { capture: true });
// Because of https://github.com/react-bootstrap/react-bootstrap/issues/2614 we need
// to wait for a frame before focusing
requestAnimationFrame(() => {
if (nodeRef.current) {
const element = nodeRef.current.querySelector<HTMLInputElement>(
'input[type="search"]',
);
if (element) element.focus();
}
});
return () => {
document.removeEventListener('click', handleDocumentClick);
};
}, [onClose]);
if (nodeRef.current) {
const element = nodeRef.current.querySelector<HTMLInputElement>(
'input[type="search"]',
);
if (element) element.focus();
}
}, []);
const results = useMemo(() => {
if (searchValue === '') {
@@ -326,10 +304,9 @@ const LanguageDropdownMenu: React.FC<{
export const LanguageDropdown: React.FC = () => {
const [open, setOpen] = useState(false);
const [placement, setPlacement] = useState<Placement | undefined>('bottom');
const [guess, setGuess] = useState('');
const activeElementRef = useRef<HTMLElement>(null);
const targetRef = useRef<HTMLButtonElement>(null);
const activeElementRef = useRef<HTMLElement | null>(null);
const [targetElement, setTargetElement] = useState<HTMLElement | null>(null);
const intl = useIntl();
@@ -369,13 +346,6 @@ export const LanguageDropdown: React.FC = () => {
[dispatch],
);
const handleOverlayEnter = useCallback(
(state: Partial<State>) => {
setPlacement(state.placement);
},
[setPlacement],
);
useEffect(() => {
if (isTextLongEnoughForGuess(text)) {
debouncedGuess(text, setGuess);
@@ -402,7 +372,7 @@ export const LanguageDropdown: React.FC = () => {
<>
<button
type='button'
ref={targetRef}
ref={setTargetElement}
title={intl.formatMessage(messages.changeLanguage)}
aria-expanded={open}
onClick={handleToggle}
@@ -416,13 +386,11 @@ export const LanguageDropdown: React.FC = () => {
<span className='dropdown-button__label'>{current[2] ?? value}</span>
</button>
<Overlay
show={open}
offset={[5, 5]}
placement={placement}
flip
target={targetRef as React.RefObject<HTMLButtonElement>}
popperConfig={{ strategy: 'fixed', onFirstUpdate: handleOverlayEnter }}
<Popover
isOpen={open}
onClose={handleClose}
offset={5}
reference={targetElement}
>
{({ props, placement }) => (
<div {...props}>
@@ -438,7 +406,7 @@ export const LanguageDropdown: React.FC = () => {
</div>
</div>
)}
</Overlay>
</Popover>
</>
);
};
@@ -4,10 +4,8 @@ import { defineMessages, useIntl } from 'react-intl';
import classNames from 'classnames';
import type { OverlayProps } from 'react-overlays/Overlay';
import Overlay from 'react-overlays/Overlay';
import type { StatusVisibility } from '@/flavours/glitch/api_types/statuses';
import { Popover } from '@/flavours/glitch/components/popover';
import AlternateEmailIcon from '@/material-icons/400-24px/alternate_email.svg?react';
import LockIcon from '@/material-icons/400-24px/lock.svg?react';
import PublicIcon from '@/material-icons/400-24px/public.svg?react';
@@ -58,7 +56,6 @@ interface PrivacyDropdownProps {
value: StatusVisibility;
onChange: (value: StatusVisibility) => void;
noDirect?: boolean;
container?: OverlayProps['container'];
disabled?: boolean;
}
@@ -66,11 +63,12 @@ const PrivacyDropdown: React.FC<PrivacyDropdownProps> = ({
value,
onChange,
noDirect,
container,
disabled,
}) => {
const intl = useIntl();
const overlayTargetRef = useRef<HTMLDivElement>(null);
const [popoverTarget, setPopoverTarget] = useState<HTMLDivElement | null>(
null,
);
const previousFocusTargetRef = useRef<HTMLElement>(null);
const [isOpen, setIsOpen] = useState(false);
@@ -142,7 +140,7 @@ const PrivacyDropdown: React.FC<PrivacyDropdownProps> = ({
options.find((item) => item.value === value) ?? options.at(0);
return (
<div ref={overlayTargetRef}>
<div ref={setPopoverTarget}>
<button
type='button'
title={intl.formatMessage(messages.change_privacy)}
@@ -166,14 +164,11 @@ const PrivacyDropdown: React.FC<PrivacyDropdownProps> = ({
)}
</button>
<Overlay
show={isOpen}
offset={[5, 5]}
placement='bottom'
flip
target={overlayTargetRef as React.RefObject<HTMLDivElement>}
container={container}
popperConfig={{ strategy: 'fixed' }}
<Popover
isOpen={isOpen}
offset={5}
reference={popoverTarget}
onClose={handleClose}
>
{({ props, placement }) => (
<div {...props}>
@@ -190,7 +185,7 @@ const PrivacyDropdown: React.FC<PrivacyDropdownProps> = ({
</div>
</div>
)}
</Overlay>
</Popover>
</div>
);
};
@@ -60,6 +60,7 @@ export const Emoji: FC<EmojiProps> = ({
sheetSize={sheetSize}
skin={1}
tooltip={false}
forceSize={false}
{...{ useButton: true }}
{...props}
/>
@@ -73,7 +73,7 @@ export type CustomEmojiMapArg =
| ExtraCustomEmojiMap
| ImmutableList<CustomEmoji>
| CustomEmoji[]
| ApiCustomEmojiJSON[];
| Pick<ApiCustomEmojiJSON, 'shortcode' | 'static_url' | 'url'>[];
export type ExtraCustomEmojiMap = Record<
string,
@@ -1,11 +1,9 @@
import type { PropsWithChildren } from 'react';
import { useCallback, useState, useRef, useId } from 'react';
import { useCallback, useState, useId } from 'react';
import classNames from 'classnames';
import type { Placement, State as PopperState } from '@popperjs/core';
import Overlay from 'react-overlays/Overlay';
import { Popover } from '@/flavours/glitch/components/popover';
import ArrowDropDownIcon from '@/material-icons/400-24px/arrow_drop_down.svg?react';
import type { SelectItem } from 'flavours/glitch/components/dropdown_selector';
import { DropdownSelector } from 'flavours/glitch/components/dropdown_selector';
@@ -18,7 +16,6 @@ interface DropdownProps {
onChange: (value: string) => void;
'aria-labelledby': string;
'aria-describedby'?: string;
placement?: Placement;
}
const Dropdown: React.FC<DropdownProps> = ({
@@ -28,22 +25,21 @@ const Dropdown: React.FC<DropdownProps> = ({
onChange,
'aria-labelledby': ariaLabelledBy,
'aria-describedby': ariaDescribedBy,
placement: initialPlacement = 'bottom-end',
}) => {
const containerRef = useRef<HTMLDivElement>(null);
const buttonRef = useRef<HTMLButtonElement>(null);
const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(
null,
);
const [isOpen, setOpen] = useState<boolean>(false);
const [placement, setPlacement] = useState<Placement>(initialPlacement);
const uniqueId = useId();
const menuId = `${uniqueId}-menu`;
const buttonLabelId = `${uniqueId}-button`;
const handleClose = useCallback(() => {
if (isOpen && buttonRef.current) {
buttonRef.current.focus({ preventScroll: true });
if (isOpen && buttonElement) {
buttonElement.focus({ preventScroll: true });
}
setOpen(false);
}, [isOpen]);
}, [isOpen, buttonElement]);
const handleToggle = useCallback(() => {
if (isOpen) {
@@ -53,20 +49,13 @@ const Dropdown: React.FC<DropdownProps> = ({
}
}, [isOpen, handleClose]);
const handleOverlayEnter = useCallback(
(state: Partial<PopperState>) => {
if (state.placement) setPlacement(state.placement);
},
[setPlacement],
);
const valueOption = options.find((item) => item.value === value);
return (
<div ref={containerRef}>
<div>
<button
type='button'
ref={buttonRef}
ref={setButtonElement}
onClick={handleToggle}
disabled={disabled}
aria-expanded={isOpen}
@@ -81,30 +70,29 @@ const Dropdown: React.FC<DropdownProps> = ({
<Icon id='down' icon={ArrowDropDownIcon} />
</button>
<Overlay
show={isOpen}
offset={[5, 5]}
placement={placement}
flip
target={containerRef as React.RefObject<HTMLDivElement>}
popperConfig={{ strategy: 'fixed', onFirstUpdate: handleOverlayEnter }}
<Popover
isOpen={isOpen}
offset={5}
placement='bottom-end'
reference={buttonElement}
onClose={handleClose}
>
{({ props, placement }) => (
<div {...props} id={menuId}>
<div
className={`dropdown-animation privacy-dropdown__dropdown ${placement}`}
>
<DropdownSelector
items={options}
value={value}
onClose={handleClose}
onChange={onChange}
classNamePrefix='privacy-dropdown'
/>
</div>
<div
{...props}
id={menuId}
className={`dropdown-animation privacy-dropdown__dropdown ${placement}`}
>
<DropdownSelector
items={options}
value={value}
onClose={handleClose}
onChange={onChange}
classNamePrefix='privacy-dropdown'
/>
</div>
)}
</Overlay>
</Popover>
</div>
);
};
@@ -53,14 +53,6 @@ export const BoostModal: React.FC<{
onClose();
}, [onClose]);
const findContainer = useCallback(
() =>
document.getElementsByClassName(
'modal-root__container',
)[0] as HTMLDivElement,
[],
);
return (
<div className='modal-root__modal safety-action-modal'>
<div className='safety-action-modal__top'>
@@ -117,7 +109,6 @@ export const BoostModal: React.FC<{
<PrivacyDropdown
noDirect
value={privacy}
container={findContainer}
onChange={onPrivacyChange}
disabled={statusVisibility === 'private'}
/>
@@ -4,13 +4,8 @@ import { useIntl, defineMessages } from 'react-intl';
import { useLocation } from 'react-router-dom';
import type {
OffsetValue,
UsePopperOptions,
} from 'react-overlays/esm/usePopper';
import Overlay from 'react-overlays/Overlay';
import { DropdownMenu } from 'flavours/glitch/components/dropdown_menu';
import { Popover } from 'flavours/glitch/components/popover';
import { useIdentity } from 'flavours/glitch/identity_context';
import type { MenuItem } from 'flavours/glitch/models/dropdown_menu';
import { useAppSelector } from 'flavours/glitch/store';
@@ -27,9 +22,6 @@ const messages = defineMessages({
muteHashtag: { id: 'hashtag.mute', defaultMessage: 'Mute #{hashtag}' },
});
const offset = [5, 5] as OffsetValue;
const popperConfig = { strategy: 'fixed' } as UsePopperOptions;
const isHashtagLink = (
element: HTMLAnchorElement | null,
): element is HTMLAnchorElement => {
@@ -135,30 +127,19 @@ export const HashtagMenuController: React.FC = () => {
}
return (
<Overlay
show={open}
offset={offset}
placement='bottom'
flip
target={element}
popperConfig={popperConfig}
>
{({ props, arrowProps, placement }) => (
<div {...props}>
<div className={`dropdown-animation dropdown-menu ${placement}`}>
<div
className={`dropdown-menu__arrow ${placement}`}
{...arrowProps}
/>
<DropdownMenu
items={menu}
onClose={handleClose}
openedViaKeyboard={false}
/>
</div>
<Popover isOpen={open} offset={5} reference={element} onClose={handleClose}>
{({ props, placement }) => (
<div
{...props}
className={`dropdown-animation dropdown-menu ${placement}`}
>
<DropdownMenu
items={menu}
onClose={handleClose}
openedViaKeyboard={false}
/>
</div>
)}
</Overlay>
</Popover>
);
};
@@ -3,47 +3,45 @@
*/
import type { RefObject } from 'react';
import { useEffect } from 'react';
import { useEffect, useEffectEvent } from 'react';
type ElementRef = RefObject<HTMLElement | null>;
type PlainElement = Element | null;
type ElementOrRef = PlainElement | RefObject<PlainElement>;
export function useOnClickOutside(
excludedElementRef: ElementRef | ElementRef[] | null,
excludedElement: ElementOrRef | ElementOrRef[],
onClick: (e: MouseEvent) => void,
enabled = true,
) {
useEffect(() => {
// If the search popover is expanded, close it when tabbing or
// clicking outside of it or the search form, while allowing
// tabbing or clicking inside of the popover
if (enabled) {
function handleClickOutside(event: MouseEvent) {
const excludedRefs = Array.isArray(excludedElementRef)
? excludedElementRef
: [excludedElementRef];
const handleClickOutside = useEffectEvent((event: MouseEvent) => {
const excludedRefs = Array.isArray(excludedElement)
? excludedElement
: [excludedElement];
for (const ref of excludedRefs) {
const excludedElement = ref?.current;
for (const ref of excludedRefs) {
const excludedElement = ref instanceof Element ? ref : ref?.current;
// Bail out if the clicked element or the currently focused element
// is inside of excludedElement. We're also checking the focused element
// to prevent an issue in Chrome where initiating a drag inside of an
// input (to select the text inside of it) and ending that drag outside
// of the input fires a click event, breaking our excludedElement rule.
if (
excludedElement &&
(excludedElement === event.target ||
excludedElement === document.activeElement ||
excludedElement.contains(event.target as Node) ||
excludedElement.contains(document.activeElement))
) {
return;
}
}
onClick(event);
// Bail out if the clicked element or the currently focused element
// is inside of excludedElement. We're also checking the focused element
// to prevent an issue in Chrome where initiating a drag inside of an
// input (to select the text inside of it) and ending that drag outside
// of the input fires a click event, breaking our excludedElement rule.
if (
excludedElement &&
(excludedElement === event.target ||
excludedElement === document.activeElement ||
excludedElement.contains(event.target as Node) ||
excludedElement.contains(document.activeElement))
) {
return;
}
}
onClick(event);
});
useEffect(() => {
if (enabled) {
document.addEventListener('click', handleClickOutside);
return () => {
@@ -51,5 +49,5 @@ export function useOnClickOutside(
};
}
return () => null;
}, [enabled, excludedElementRef, onClick]);
}, [enabled, excludedElement, onClick]);
}
@@ -47,7 +47,7 @@ export interface StatusShape {
pinned: boolean;
filtered: FilterResult[];
sensitive: boolean;
collapsed: boolean;
collapsed: boolean | null;
uri: string;
url: string | null;
@@ -372,7 +372,7 @@
}
}
body > [data-popper-placement] {
body > [data-popover-placement] {
z-index: 9999;
}
@@ -4157,9 +4157,8 @@ a.account__display-name {
align-items: center;
gap: 8px;
width: 100%;
padding: 10px;
padding-inline-start: 14px;
overflow: hidden;
padding: 12px;
padding-inline-start: 16px;
font-size: 16px;
font-weight: 400;
text-decoration: none;
@@ -4170,7 +4169,7 @@ a.account__display-name {
var(--color-text-secondary)
);
background: transparent;
border: 2px solid transparent;
border: none;
border-radius: 4px;
&:hover,
@@ -4184,14 +4183,14 @@ a.account__display-name {
}
&:focus-visible {
outline: none;
border-color: var(--color-border-brand);
outline: var(--outline-focus-default);
outline-offset: -2px;
background: var(--color-bg-brand-softest);
}
&--logo {
padding: 8px;
padding-inline-start: 12px;
padding: 10px;
padding-inline-start: 14px;
}
}
@@ -6017,10 +6016,6 @@ a.status-card {
}
.visibility-dropdown {
&__overlay[data-popper-placement] {
z-index: 9999;
}
&.disabled {
opacity: 0.6;
cursor: default;
@@ -11063,7 +11058,7 @@ noscript {
}
}
.hover-card-controller[data-popper-reference-hidden='true'] {
.hover-card-controller[data-popover-reference-hidden='true'] {
opacity: 0;
pointer-events: none;
}
@@ -20,7 +20,7 @@ export function normalizeStatus(
) {
const normalStatus: StatusShape = {
hidden: normalOldStatus?.hidden ?? false,
collapsed: normalOldStatus?.collapsed ?? false,
collapsed: normalOldStatus?.collapsed ?? null,
content: '',
contentHtml: '',
muted: false,
@@ -1,12 +1,10 @@
import { useCallback, useId, useRef, useState } from 'react';
import { useCallback, useId, useState } from 'react';
import type { FC } from 'react';
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
import classNames from 'classnames';
import Overlay from 'react-overlays/esm/Overlay';
import { useAccount } from '@/mastodon/hooks/useAccount';
import { useRelationship } from '@/mastodon/hooks/useRelationship';
import { useAppSelector } from '@/mastodon/store';
@@ -20,6 +18,7 @@ import { CopyButton } from '../copy_button';
import { DisplayName } from '../display_name';
import { Icon } from '../icon';
import { NavigationFocusTarget } from '../navigation_focus_target';
import { Popover } from '../popover';
import { AccountBadges } from './badges';
import classes from './styles.module.scss';
@@ -82,7 +81,8 @@ const AccountNameHelp: FC<{
const accessibilityId = useId();
const intl = useIntl();
const [open, setOpen] = useState(false);
const triggerRef = useRef<HTMLButtonElement>(null);
const [triggerElement, setTriggerElement] =
useState<HTMLButtonElement | null>(null);
const handleClick = useCallback(() => {
setOpen((prev) => !prev);
@@ -94,7 +94,7 @@ const AccountNameHelp: FC<{
<>
<button
type='button'
ref={triggerRef}
ref={setTriggerElement}
className={classes.handleHelpButton}
onClick={handleClick}
aria-expanded={open}
@@ -108,12 +108,11 @@ const AccountNameHelp: FC<{
/>
</button>
<Overlay
show={open}
rootClose
target={triggerRef as React.RefObject<HTMLButtonElement>}
onHide={handleClick}
offset={[5, 5]}
<Popover
isOpen={open}
reference={triggerElement}
onClose={handleClick}
offset={5}
>
{({ props }) => (
<div
@@ -192,7 +191,7 @@ const AccountNameHelp: FC<{
</CopyButton>
</div>
)}
</Overlay>
</Popover>
</>
);
};
@@ -4,22 +4,14 @@ import { FormattedMessage, useIntl } from 'react-intl';
import classNames from 'classnames';
import type {
OffsetValue,
UsePopperOptions,
} from 'react-overlays/esm/usePopper';
import Overlay from 'react-overlays/Overlay';
import CloseIcon from '@/material-icons/400-24px/close.svg?react';
import { useSelectableClick } from 'mastodon/hooks/useSelectableClick';
import { IconButton } from '../icon_button';
import { Popover } from '../popover';
import classes from './styles.module.scss';
const offset = [0, 4] as OffsetValue;
const popperConfig = { strategy: 'fixed' } as UsePopperOptions;
export const AltTextBadge: React.FC<{
description: string;
className?: string;
@@ -28,7 +20,9 @@ export const AltTextBadge: React.FC<{
const uniqueId = useId();
const popoverId = `${uniqueId}-popover`;
const titleId = `${uniqueId}-title`;
const buttonRef = useRef<HTMLButtonElement>(null);
const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(
null,
);
const popoverRef = useRef<HTMLDivElement>(null);
const [open, setOpen] = useState(false);
@@ -41,8 +35,8 @@ export const AltTextBadge: React.FC<{
const handleClose = useCallback(() => {
setOpen(false);
buttonRef.current?.focus();
}, [setOpen]);
buttonElement?.focus();
}, [buttonElement]);
const [handleMouseDown, handleMouseUp] = useSelectableClick(handleClose);
@@ -50,7 +44,7 @@ export const AltTextBadge: React.FC<{
<>
<button
type='button'
ref={buttonRef}
ref={setButtonElement}
className={classNames('media-gallery__alt__label', className)}
onClick={handleClick}
aria-expanded={open}
@@ -60,15 +54,12 @@ export const AltTextBadge: React.FC<{
ALT
</button>
<Overlay
rootClose
onHide={handleClose}
show={open}
target={buttonRef as React.RefObject<HTMLButtonElement>}
<Popover
isOpen={open}
onClose={handleClose}
reference={buttonElement}
placement='top-end'
flip
offset={offset}
popperConfig={popperConfig}
offset={4}
>
{({ props }) => (
<div {...props} className='hover-card-controller'>
@@ -105,7 +96,7 @@ export const AltTextBadge: React.FC<{
</div>
</div>
)}
</Overlay>
</Popover>
</>
);
};
@@ -5,14 +5,13 @@ import classNames from 'classnames';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import Overlay from 'react-overlays/Overlay';
import AutosuggestAccountContainer from '../features/compose/containers/autosuggest_account_container';
import { AutosuggestEmoji } from './autosuggest_emoji';
import { AutosuggestHashtag } from './autosuggest_hashtag';
import { LocalCustomEmojiProvider } from './emoji/context';
import { textAtCursorMatchesToken } from './autosuggest/utils';
import { Popover } from './popover';
export default class AutosuggestInput extends ImmutablePureComponent {
@@ -129,6 +128,10 @@ export default class AutosuggestInput extends ImmutablePureComponent {
this.setState({ focused: true });
};
onCloseMenu = () => {
this.setState({ suggestionsHidden: true });
};
onSuggestionClick = (e) => {
const suggestion = this.props.suggestions.get(e.currentTarget.getAttribute('data-index'));
e.preventDefault();
@@ -197,7 +200,12 @@ export default class AutosuggestInput extends ImmutablePureComponent {
/>
<LocalCustomEmojiProvider>
<Overlay show={!(suggestionsHidden || suggestions.isEmpty())} offset={[0, 0]} placement='bottom' target={this.input} popperConfig={{ strategy: 'fixed' }}>
<Popover
reference={this.input}
isOpen={!(suggestionsHidden || suggestions.isEmpty())}
onClose={this.onCloseMenu}
flip={false}
>
{({ props }) => (
<div {...props}>
<div className='autosuggest-textarea__suggestions' style={{ width: this.input?.clientWidth }}>
@@ -205,7 +213,7 @@ export default class AutosuggestInput extends ImmutablePureComponent {
</div>
</div>
)}
</Overlay>
</Popover>
</LocalCustomEmojiProvider>
</div>
);
@@ -5,7 +5,6 @@ import classNames from 'classnames';
import ImmutablePropTypes from 'react-immutable-proptypes';
import Overlay from 'react-overlays/Overlay';
import Textarea from 'react-textarea-autosize';
import AutosuggestAccountContainer from '../features/compose/containers/autosuggest_account_container';
@@ -14,6 +13,7 @@ import { AutosuggestEmoji } from './autosuggest_emoji';
import { AutosuggestHashtag } from './autosuggest_hashtag';
import { LocalCustomEmojiProvider } from './emoji/context';
import { textAtCursorMatchesToken } from './autosuggest/utils';
import { Popover } from './popover';
const AutosuggestTextarea = forwardRef(({
value,
@@ -36,6 +36,7 @@ const AutosuggestTextarea = forwardRef(({
const [suggestionsHidden, setSuggestionsHidden] = useState(true);
const [selectedSuggestion, setSelectedSuggestion] = useState(0);
const [textareaElement, setTextareaElement] = useState(null);
const lastTokenRef = useRef(null);
const tokenStartRef = useRef(0);
@@ -110,7 +111,7 @@ const AutosuggestTextarea = forwardRef(({
onKeyDown(e);
}, [disabled, suggestions, suggestionsHidden, selectedSuggestion, setSelectedSuggestion, setSuggestionsHidden, onSuggestionSelected, onKeyDown]);
const handleBlur = useCallback(() => {
const closeMenu = useCallback(() => {
setSuggestionsHidden(true);
}, [setSuggestionsHidden]);
@@ -173,10 +174,15 @@ const AutosuggestTextarea = forwardRef(({
);
};
const handleRef = useCallback((element) => {
textareaRef.current = element;
setTextareaElement(element);
}, []);
return (
<div className={classNames('autosuggest-textarea', className)}>
<Textarea
ref={textareaRef}
ref={handleRef}
className='autosuggest-textarea__textarea'
disabled={disabled}
placeholder={placeholder}
@@ -186,7 +192,7 @@ const AutosuggestTextarea = forwardRef(({
onKeyDown={handleKeyDown}
onKeyUp={onKeyUp}
onFocus={handleFocus}
onBlur={handleBlur}
onBlur={closeMenu}
onPaste={handlePaste}
onDrop={handleDrop}
dir='auto'
@@ -196,15 +202,20 @@ const AutosuggestTextarea = forwardRef(({
/>
<LocalCustomEmojiProvider>
<Overlay show={!(suggestionsHidden || suggestions.isEmpty())} offset={[0, 0]} placement='bottom' target={textareaRef} popperConfig={{ strategy: 'fixed' }}>
<Popover
matchReferenceWidth
isOpen={!(suggestionsHidden || suggestions.isEmpty())}
onClose={closeMenu}
reference={textareaElement}
>
{({ props }) => (
<div {...props}>
<div className='autosuggest-textarea__suggestions' style={{ width: textareaRef.current?.clientWidth }}>
<div className='autosuggest-textarea__suggestions' style={{ width: textareaElement?.clientWidth }}>
{suggestions.map(renderSuggestion)}
</div>
</div>
)}
</Overlay>
</Popover>
</LocalCustomEmojiProvider>
</div>
);
@@ -1,4 +1,4 @@
import { useCallback, useId, useMemo, useRef, useState } from 'react';
import { useCallback, useId, useMemo, useState } from 'react';
import type { ComponentPropsWithoutRef, FC } from 'react';
import { useIntl } from 'react-intl';
@@ -6,15 +6,12 @@ import type { MessageDescriptor } from 'react-intl';
import classNames from 'classnames';
import Overlay from 'react-overlays/Overlay';
import UnfoldMoreIcon from '@/material-icons/400-24px/unfold_more.svg?react';
import type { SelectItem } from '../dropdown_selector';
import { DropdownSelector } from '../dropdown_selector';
import { Icon } from '../icon';
import { matchWidth } from './utils';
import { Popover } from '../popover';
interface DropdownProps {
disabled?: boolean;
@@ -42,7 +39,9 @@ export const Dropdown: FC<
...buttonProps
}) => {
const intl = useIntl();
const buttonRef = useRef<HTMLButtonElement>(null);
const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(
null,
);
const uniqueId = useId();
const buttonId = id ?? `${uniqueId}-button`;
const listboxId = `${uniqueId}-listbox`;
@@ -52,16 +51,16 @@ export const Dropdown: FC<
const handleToggle = useCallback(() => {
if (!disabled) {
setOpen((prevOpen) => {
buttonRef.current?.focus();
buttonElement?.focus();
return !prevOpen;
});
}
}, [disabled]);
}, [buttonElement, disabled]);
const handleClose = useCallback(() => {
setOpen(false);
buttonRef.current?.focus();
}, []);
buttonElement?.focus();
}, [buttonElement]);
const currentText = useMemo(
() =>
@@ -93,7 +92,7 @@ export const Dropdown: FC<
},
className,
)}
ref={buttonRef}
ref={setButtonElement}
>
{currentText}
<Icon
@@ -103,17 +102,12 @@ export const Dropdown: FC<
/>
</button>
<Overlay
show={open}
offset={[0, 0]}
<Popover
matchReferenceWidth
isOpen={open}
placement='bottom-start'
onHide={handleClose}
flip
target={buttonRef as React.RefObject<HTMLButtonElement>}
popperConfig={{
strategy: 'fixed',
modifiers: [matchWidth],
}}
onClose={handleClose}
reference={buttonElement}
>
{({ props, placement }) => (
<div {...props} className={`${classPrefix}__overlay`}>
@@ -135,7 +129,7 @@ export const Dropdown: FC<
</div>
</div>
)}
</Overlay>
</Popover>
</>
);
};
@@ -1,17 +0,0 @@
import type { Modifier, UsePopperState } from 'react-overlays/esm/usePopper';
export const matchWidth: Modifier<'sameWidth', UsePopperState> = {
name: 'sameWidth',
enabled: true,
phase: 'beforeWrite',
requires: ['computeStyles'],
fn: ({ state }) => {
if (state.styles.popper) {
state.styles.popper.width = `${state.rects.reference.width}px`;
}
},
effect: ({ state }) => {
const reference = state.elements.reference as HTMLElement;
state.elements.popper.style.width = `${reference.offsetWidth}px`;
},
};
@@ -13,13 +13,6 @@ import { Link } from 'react-router-dom';
import type { Map as ImmutableMap } from 'immutable';
import type {
OffsetValue,
UsePopperOptions,
Placement,
} from 'react-overlays/esm/usePopper';
import Overlay from 'react-overlays/Overlay';
import { fetchRelationships } from 'mastodon/actions/accounts';
import {
openDropdownMenu,
@@ -40,6 +33,8 @@ import { useAppDispatch, useAppSelector } from 'mastodon/store';
import { Icon } from './icon';
import type { IconProp } from './icon';
import { IconButton } from './icon_button';
import type { PopoverProps } from './popover';
import { Popover } from './popover';
let id = 0;
@@ -302,8 +297,8 @@ interface DropdownProps<Item extends object | null = MenuItem> {
title?: string;
disabled?: boolean;
scrollable?: boolean;
placement?: Placement;
offset?: OffsetValue;
placement?: PopoverProps['placement'];
offset?: PopoverProps['offset'];
/**
* Prevent the `ScrollableList` with this scrollKey
* from being scrolled while the dropdown is open
@@ -321,8 +316,6 @@ interface DropdownProps<Item extends object | null = MenuItem> {
onItemClick?: ItemClickFn<Item>;
}
const popperConfig = { strategy: 'fixed' } as UsePopperOptions;
export const Dropdown = <Item extends object | null = MenuItem>({
children,
icon,
@@ -334,7 +327,7 @@ export const Dropdown = <Item extends object | null = MenuItem>({
disabled,
scrollable,
placement = 'bottom',
offset = [5, 5],
offset = 5,
status,
needsStatusRefresh,
forceDropdown = false,
@@ -352,7 +345,9 @@ export const Dropdown = <Item extends object | null = MenuItem>({
);
const [currentId] = useState(id++);
const open = currentId === openDropdownId;
const buttonRef = useRef<HTMLButtonElement>(null);
const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(
null,
);
const menuId = useId();
const prefetchAccountId = status
? status.getIn(['account', 'id'])
@@ -360,8 +355,8 @@ export const Dropdown = <Item extends object | null = MenuItem>({
const statusId = status?.get('id') as string | undefined;
const handleClose = useCallback(() => {
if (buttonRef.current) {
buttonRef.current.focus({ preventScroll: true });
if (buttonElement) {
buttonElement.focus({ preventScroll: true });
}
dispatch(
@@ -372,7 +367,7 @@ export const Dropdown = <Item extends object | null = MenuItem>({
);
dispatch(closeDropdownMenu({ id: currentId }));
}, [dispatch, currentId]);
}, [buttonElement, dispatch, currentId]);
const handleItemClick = useCallback(
(e: React.MouseEvent) => {
@@ -489,7 +484,7 @@ export const Dropdown = <Item extends object | null = MenuItem>({
onBlur: unsetIsKeypress,
'aria-expanded': open,
'aria-controls': menuId,
ref: buttonRef,
ref: setButtonElement,
};
if (children) {
@@ -513,22 +508,16 @@ export const Dropdown = <Item extends object | null = MenuItem>({
<>
{button}
<Overlay
show={open}
<Popover
isOpen={open}
onClose={handleClose}
offset={offset}
placement={placement}
flip
target={buttonRef as React.RefObject<HTMLButtonElement>}
popperConfig={popperConfig}
reference={buttonElement}
>
{({ props, arrowProps, placement }) => (
{({ props, placement }) => (
<div {...props} className={className} id={menuId}>
<div className={`dropdown-animation dropdown-menu ${placement}`}>
<div
className={`dropdown-menu__arrow ${placement}`}
{...arrowProps}
/>
<DropdownMenu
items={items}
loading={loading}
@@ -542,7 +531,7 @@ export const Dropdown = <Item extends object | null = MenuItem>({
</div>
</div>
)}
</Overlay>
</Popover>
</>
);
};
@@ -14,16 +14,13 @@ import { useIntl } from 'react-intl';
import classNames from 'classnames';
import Overlay from 'react-overlays/Overlay';
import KeyboardArrowDownIcon from '@/material-icons/400-24px/keyboard_arrow_down.svg?react';
import KeyboardArrowUpIcon from '@/material-icons/400-24px/keyboard_arrow_up.svg?react';
import SearchIcon from '@/material-icons/400-24px/search.svg?react';
import { matchWidth } from 'mastodon/components/dropdown/utils';
import { IconButton } from 'mastodon/components/icon_button';
import { useOnClickOutside } from 'mastodon/hooks/useOnClickOutside';
import { LoadingIndicator } from '../loading_indicator';
import { Popover } from '../popover';
import classes from './combobox.module.scss';
import { FormFieldWrapper } from './form_field_wrapper';
@@ -236,8 +233,12 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
) => {
const intl = useIntl();
const wrapperRef = useRef<HTMLDivElement>(null);
const inputRef = useRef<HTMLInputElement>(null);
const popoverRef = useRef<HTMLDivElement>(null);
const [inputElement, setInputElement] = useState<HTMLInputElement | null>(
null,
);
const [popoverElement, setPopoverElement] = useState<HTMLDivElement | null>(
null,
);
// This ref tracks whether the menu was just closed following a
// selection, and prevents the menu from re-opening again
@@ -275,24 +276,27 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
const openMenu = useCallback(() => {
setShouldMenuOpen(true);
inputRef.current?.focus();
}, []);
inputElement?.focus();
}, [inputElement]);
const closeMenu = useCallback(() => {
setShouldMenuOpen(false);
}, []);
const highlightItem = useCallback((id: string | null) => {
setHighlightedItemId(id);
if (id) {
const itemElement = popoverRef.current?.querySelector<HTMLLIElement>(
`[data-item-id='${id}']`,
);
if (itemElement && popoverRef.current) {
scrollItemIntoView(itemElement, popoverRef.current);
const highlightItem = useCallback(
(id: string | null) => {
setHighlightedItemId(id);
if (id) {
const itemElement = popoverElement?.querySelector<HTMLLIElement>(
`[data-item-id='${id}']`,
);
if (itemElement && popoverElement) {
scrollItemIntoView(itemElement, popoverElement);
}
}
}
}, []);
},
[popoverElement],
);
const resetHighlight = useCallback(() => {
const firstItem = flatItems[0];
@@ -353,9 +357,16 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
}
}
}
inputRef.current?.focus();
inputElement?.focus();
},
[closeMenu, closeOnSelect, getIsItemDisabled, flatItems, onSelectItem],
[
flatItems,
inputElement,
getIsItemDisabled,
onSelectItem,
closeOnSelect,
closeMenu,
],
);
const handleSelectItem = useCallback(
@@ -406,8 +417,6 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
[getItemId, highlightItem, highlightedItemId, flatItems],
);
useOnClickOutside(wrapperRef, closeMenu);
const handleInputKeyDown = useCallback(
(e: React.KeyboardEvent<HTMLInputElement>) => {
onKeyDown?.(e);
@@ -489,9 +498,9 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
);
});
const mergeRefs = useCallback(
const mergeInputRefs = useCallback(
(element: HTMLInputElement | null) => {
inputRef.current = element;
setInputElement(element);
if (typeof ref === 'function') {
ref(element);
} else if (ref) {
@@ -525,7 +534,7 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
onKeyDown={handleInputKeyDown}
icon={icon ?? undefined}
className={classNames(classes.input, className)}
ref={mergeRefs}
ref={mergeInputRefs}
/>
{hasMenuContent && (
<IconButton
@@ -551,20 +560,23 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
<span role='status' aria-live='polite' className='sr-only'>
{isMenuOpen && statusMessage}
</span>
<Overlay
show={isMenuOpen}
offset={[0, 1]}
<Popover
matchReferenceWidth
isOpen={isMenuOpen}
onClose={closeMenu}
offset={1}
placement='bottom-start'
onHide={closeMenu}
ref={popoverRef}
target={inputRef as React.RefObject<HTMLInputElement>}
container={wrapperRef as React.RefObject<HTMLDivElement>}
popperConfig={{
modifiers: [matchWidth],
}}
strategy='absolute'
popoverElement={popoverElement}
reference={inputElement}
container={null}
>
{({ props, placement }) => (
<div {...props} className={classNames(classes.popover, placement)}>
<div
{...props}
ref={setPopoverElement}
className={classNames(classes.popover, placement)}
>
<StatusMessageWrapper
showStatus={showStatusMessageInMenu}
isLoading={isLoading}
@@ -608,7 +620,7 @@ const ComboboxWithRef = <Item extends ComboboxItem, GroupKey extends string>(
</StatusMessageWrapper>
</div>
)}
</Overlay>
</Popover>
</div>
);
};
@@ -2,23 +2,18 @@ import { useEffect, useRef, useState, useCallback } from 'react';
import { useLocation } from 'react-router-dom';
import type {
OffsetValue,
UsePopperOptions,
} from 'react-overlays/esm/usePopper';
import Overlay from 'react-overlays/Overlay';
import { HoverCardAccount } from 'mastodon/components/hover_card_account';
import type { PopoverProps } from 'mastodon/components/popover';
import { Popover } from 'mastodon/components/popover';
import { useTimeout } from 'mastodon/hooks/useTimeout';
const offset = [-12, 4] as OffsetValue;
const offset: PopoverProps['offset'] = { crossAxis: -12, mainAxis: 4 } as const;
const enterDelay = 750;
const leaveDelay = 150;
// Only open the card if the mouse was moved within this time,
// to avoid triggering the card without intentional mouse movement
// (e.g. when content changed underneath the mouse cursor)
const activeMovementThreshold = 150;
const popperConfig = { strategy: 'fixed' } as UsePopperOptions;
const isHoverCardAnchor = (element: HTMLElement) =>
element.matches('[data-hover-card-account]');
@@ -212,21 +207,18 @@ export const HoverCardController: React.FC = () => {
]);
return (
<Overlay
rootClose
onHide={handleClose}
show={open}
target={anchor}
<Popover
onClose={handleClose}
isOpen={open}
reference={anchor}
placement='bottom-start'
flip
offset={offset}
popperConfig={popperConfig}
>
{({ props }) => (
<div {...props} className='hover-card-controller'>
<HoverCardAccount accountId={accountId} ref={cardRef} />
</div>
)}
</Overlay>
</Popover>
);
};
@@ -1,15 +1,15 @@
import { useState, useRef, useCallback, useId } from 'react';
import { useState, useCallback, useId } from 'react';
import { FormattedMessage } from 'react-intl';
import Overlay from 'react-overlays/Overlay';
import { Popover } from './popover';
export const LearnMoreLink: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
const accessibilityId = useId();
const [open, setOpen] = useState(false);
const triggerRef = useRef<HTMLButtonElement>(null);
const [trigger, setTrigger] = useState<HTMLButtonElement | null>(null);
const handleClick = useCallback(() => {
setOpen(!open);
@@ -19,7 +19,7 @@ export const LearnMoreLink: React.FC<{ children: React.ReactNode }> = ({
<>
<button
className='link-button'
ref={triggerRef}
ref={setTrigger}
onClick={handleClick}
aria-expanded={open}
aria-controls={accessibilityId}
@@ -31,13 +31,12 @@ export const LearnMoreLink: React.FC<{ children: React.ReactNode }> = ({
/>
</button>
<Overlay
show={open}
rootClose
onHide={handleClick}
offset={[5, 5]}
<Popover
isOpen={open}
onClose={handleClick}
offset={5}
placement='bottom-end'
target={triggerRef as React.RefObject<HTMLButtonElement>}
reference={trigger}
>
{({ props }) => (
<div
@@ -62,7 +61,7 @@ export const LearnMoreLink: React.FC<{ children: React.ReactNode }> = ({
</div>
</div>
)}
</Overlay>
</Popover>
</>
);
};
+19 -6
View File
@@ -15,7 +15,6 @@ import { fetchPoll, vote } from 'mastodon/actions/polls';
import { Icon } from 'mastodon/components/icon';
import { useIdentity } from 'mastodon/identity_context';
import type * as Model from 'mastodon/models/poll';
import type { Status } from 'mastodon/models/status';
import { useAppDispatch, useAppSelector } from 'mastodon/store';
import { RelativeTimestamp } from './relative_timestamp';
@@ -40,12 +39,18 @@ const isPollExpired = (expiresAt: Model.Poll['expires_at']) =>
interface PollProps {
pollId: string;
status: Status;
accountId: string;
statusUrl: string;
lang?: string;
disabled?: boolean;
}
export const Poll: React.FC<PollProps> = ({ pollId, disabled, status }) => {
export const Poll: React.FC<PollProps> = ({
pollId,
disabled,
accountId,
statusUrl,
}) => {
// Third party hooks
const poll = useAppSelector((state) => state.polls[pollId]);
const identity = useIdentity();
@@ -110,14 +115,22 @@ export const Poll: React.FC<PollProps> = ({ pollId, disabled, status }) => {
openModal({
modalType: 'INTERACTION',
modalProps: {
accountId,
intent: 'vote',
accountId: status.getIn(['account', 'id']),
url: status.get('uri'),
url: statusUrl,
},
}),
);
}
}, [voteDisabled, dispatch, identity, pollId, selected, status]);
}, [
voteDisabled,
dispatch,
identity,
pollId,
selected,
accountId,
statusUrl,
]);
const handleReveal = useCallback(() => {
setRevealed(true);
@@ -0,0 +1,203 @@
import { useEffect } from 'react';
import type {
ReferenceType,
Placement,
OffsetOptions,
Strategy,
} from '@floating-ui/react-dom';
import {
useFloating,
autoUpdate,
inline,
offset as offsetMiddleware,
shift,
flip as flipMiddleware,
size,
hide,
} from '@floating-ui/react-dom';
import { useOnClickOutside } from '@/mastodon/hooks/useOnClickOutside';
import { Portal } from './portal';
export interface PopoverProps {
/**
* Set the visibility of the popover
*/
isOpen?: boolean;
/**
* Callback triggered when the popover needs to be closed
* (e.g. because the Esc key was pressed).
*/
onClose: (e: Event) => void;
/**
* Pass an element that the popover should be attached to.
* Must come from `useState`, not `useRef`.
*/
reference: ReferenceType | null;
/**
* Pass the popover element (useful if you also need the element
* in the parent and already have it in state).
* Must come from `useState`, not `useRef`.
*/
popoverElement?: HTMLElement | null;
/**
* Control which element the popover will be rendered into.
* Passing `null` will render the popover in place.
*/
container?: HTMLElement | null;
/**
* Control where the overlay element is positioned in relation
* to the reference element
*/
placement?: Placement;
/**
* Control the distance between popover and reference
*/
offset?: OffsetOptions;
/**
* Allow the popover to flip to the other side of the reference
* if there's no room in the specified direction. Enabled by default.
*/
flip?: boolean;
/**
* Change the positioning strategy, defaults to 'fixed'
* but can be changed to 'absolute'
*/
strategy?: Strategy;
/**
* Adapt the popover's width to match that of the reference,
* useful when attached to text input.
*/
matchReferenceWidth?: boolean;
/**
* Control whether to close the popover when clicking outside
* of it (enabled by default).
*/
closeOnClickOutside?: boolean;
/**
* Render prop that must return the popover element.
*/
children: (value: {
/**
* The popover's final computed placement. Can be used to
* adjust the popover's style based on its position.
*/
placement: Placement | undefined;
/**
* Re-computes the popover's position – call this when an
* action inside of the popover has changed its size.
*/
update: () => void;
/**
* These props must be passed to the popover element to
* enable it to be sized and positioned. The `ref` prop
* is not passed when the `popoverElement` prop is provided.
*/
props: Record<string, unknown> & {
ref?: React.RefCallback<HTMLElement>;
style: React.CSSProperties;
};
}) => React.ReactNode;
}
export const Popover: React.FC<PopoverProps> = ({
isOpen,
onClose,
reference,
popoverElement,
placement = 'bottom',
offset,
strategy = 'fixed',
flip = true,
container,
matchReferenceWidth = false,
closeOnClickOutside = true,
children,
}) => {
const {
placement: computedPlacement,
update,
refs,
floatingStyles,
middlewareData,
elements,
} = useFloating({
elements: {
reference,
floating: popoverElement,
},
placement,
strategy,
whileElementsMounted: autoUpdate,
middleware: [
offsetMiddleware(offset),
inline(),
shift(),
flip ? flipMiddleware() : null,
matchReferenceWidth
? size({
apply({ rects, elements }) {
Object.assign(elements.floating.style, {
minWidth: `${rects.reference.width}px`,
});
},
})
: null,
hide(),
],
});
// Close when clicking outside the popover
useOnClickOutside(
[
elements.floating,
// Only pass reference if it's not a "virtual element"
elements.reference instanceof Element ? elements.reference : null,
],
(e) => {
onClose(e);
},
isOpen && closeOnClickOutside,
);
// Close when pressing Escape
useEffect(() => {
if (!isOpen) {
return () => null;
}
function closeOnEscape(event: KeyboardEvent) {
if (event.key === 'Escape') {
onClose(event);
}
}
document.addEventListener('keyup', closeOnEscape);
return () => {
document.removeEventListener('keyup', closeOnEscape);
};
}, [isOpen, onClose]);
if (!isOpen) {
return null;
}
return (
<Portal container={container}>
{children({
placement: computedPlacement,
update,
props: {
ref: popoverElement ? undefined : refs.setFloating,
style: floatingStyles,
'data-popover-placement': computedPlacement,
'data-popover-reference-hidden': middlewareData.hide?.referenceHidden,
'data-popover-escaped': middlewareData.hide?.escaped,
},
})}
</Portal>
);
};
@@ -0,0 +1,21 @@
import { createPortal } from 'react-dom';
interface PortalProps {
/**
* The element to render the Portal's children into.
* Must be an object, e.g. the result of a getElementById() call.
* Set to `null` to render the children in place,
* i.e. effectively disable the Portal's functionality
*/
readonly container?: HTMLElement | SVGElement | null;
readonly children?: React.ReactNode;
}
export const Portal: React.FC<PortalProps> = ({
container,
children,
}: PortalProps) => {
if (container === null) return children;
return createPortal(children, container ?? document.body);
};
@@ -187,7 +187,7 @@ const BoostOrQuoteMenu: FC<ReblogButtonProps> = ({ status, counters }) => {
return (
<Dropdown
placement='bottom-start'
offset={[-19, 5]} // This aligns button icon with menu icons
offset={{ mainAxis: 5, crossAxis: -19 }} // This aligns button icon with menu icons
items={items}
renderItem={renderMenuItem}
onOpen={handleDropdownOpen}
@@ -0,0 +1,121 @@
import type { Meta, StoryObj } from '@storybook/react-vite';
import { fn } from 'storybook/test';
import type { StatusTranslation } from '@/mastodon/models/status';
import { statusFactoryState } from '@/testing/factories';
import { StatusContent } from './content';
interface StatusContentProps {
text: string;
collapsible: boolean;
clickable: boolean;
translatable: boolean;
translatedTo?: string;
}
const onClickFn = fn().mockName('onClick');
const onTranslateFn = fn().mockName('onTranslate');
const meta = {
title: 'Components/Status/StatusContent',
render(args) {
return (
<div style={{ width: 'min(600px, 80vw)' }}>
<StatusContent
statusId='1'
collapsible={args.collapsible}
onClick={args.clickable ? onClickFn : undefined}
onTranslate={args.translatable ? onTranslateFn : undefined}
/>
</div>
);
},
args: {
text: 'This is status text.',
collapsible: true,
clickable: true,
translatable: true,
},
argTypes: {
text: {
reduxPath: 'statuses.1.contentHtml',
},
translatedTo: {
control: 'select',
options: ['en', 'de', 'fr'],
},
},
parameters: {
state: {
server: {
translationLanguages: {
item: {
en: ['en', 'de', 'fr'],
},
},
},
},
stateFn(args: StatusContentProps) {
let status = statusFactoryState();
if (args.translatedTo) {
status = status.set('translation', {
contentHtml: `${args.text}<p><em>(in ${args.translatedTo})</em></p>`,
provider: 'Test Translation API',
spoiler_text: '',
spoilerHtml: '',
language: args.translatedTo,
detected_source_language: 'en',
} satisfies StatusTranslation);
}
return {
statuses: {
'1': status,
},
};
},
},
} satisfies Meta<StatusContentProps>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {};
export const ReadMore: Story = {
args: {
text: [
'This is a long-form piece of text that wraps multiple lines.',
'It is here to test what a longer status looks like.',
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'Pellentesque a ante placerat, egestas eros vitae, ornare orci.',
'Phasellus fringilla felis vel purus fermentum, nec viverra eros fringilla.',
'Mauris feugiat metus in dolor elementum, ultricies suscipit sapien tincidunt.',
'Mauris vestibulum urna vel mauris sagittis, a blandit felis cursus.',
'Sed nec sem dictum ligula hendrerit dignissim et non dolor.',
'Cras maximus lorem sit amet aliquet faucibus.',
'Donec tempus lectus vitae laoreet congue.',
'Nulla congue nibh sed eros pulvinar pharetra.',
'Fusce vel nibh quis nisi mollis volutpat quis vel erat.',
'Fusce non metus non sapien volutpat elementum.',
'Aenean elementum ipsum ut neque bibendum, eget blandit ex efficitur.',
'Morbi semper eros at ipsum pellentesque mattis.',
'Donec ultricies ante imperdiet placerat tempus.',
'Vivamus vitae ante sit amet lectus porta mollis quis dictum quam.',
'Cras dignissim ante at turpis scelerisque, non hendrerit ipsum vestibulum.',
'Quisque ac nulla ac sem auctor posuere eget id ex.',
'Phasellus cursus purus sit amet sollicitudin finibus.',
'In varius justo eu metus dapibus, non imperdiet lorem efficitur.',
'Nulla tincidunt odio eget ipsum auctor rhoncus.',
]
.map((text) => `<p>${text}</p>`)
.join('\n'),
},
};
export const Translated: Story = {
args: {
translatedTo: 'fr',
},
};
@@ -0,0 +1,210 @@
import type React from 'react';
import { useCallback } from 'react';
import { FormattedMessage, useIntl } from 'react-intl';
import classnames from 'classnames';
import { toggleStatusCollapse } from '@/mastodon/actions/statuses';
import { useIdentity } from '@/mastodon/identity_context';
import { languages as preloadedLanguages } from '@/mastodon/initial_state';
import type { StatusTranslation } from '@/mastodon/models/status';
import { selectPlainStatus } from '@/mastodon/selectors/statuses';
import { useAppDispatch, useAppSelector } from '@/mastodon/store';
import ChevronRightIcon from '@/material-icons/400-24px/chevron_right.svg?react';
import { EmojiHTML } from '../emoji/html';
import { Icon } from '../icon';
import { Poll } from '../poll';
import { useElementHandledLink } from './handled_link';
const MAX_HEIGHT = 706; // 22px * 32 (+ 2px padding at the top)
export const StatusContent: React.FC<{
statusId: string;
onClick?: React.MouseEventHandler;
onTranslate?: React.MouseEventHandler<HTMLButtonElement>;
collapsible?: boolean;
}> = ({ statusId, onClick, onTranslate, collapsible }) => {
const status = useAppSelector((state) => selectPlainStatus(state, statusId));
const { signedIn } = useIdentity();
const targetLanguages = useAppSelector(
(state) =>
state.server.translationLanguages.item?.[status?.language ?? 'und'],
);
const intl = useIntl();
// Determines if a long post should show the read more button.
const dispatch = useAppDispatch();
const handleCollapse = useCallback(
(node: HTMLDivElement | null) => {
if (!node || status?.collapsed !== null || !collapsible) {
return;
}
const text = node.querySelector(':scope > .status__content__text');
const collapsed =
(node.clientHeight > MAX_HEIGHT ||
(text !== null && text.scrollWidth > text.clientWidth)) &&
!status.spoiler_text;
dispatch(toggleStatusCollapse(status.id, collapsed));
},
[collapsible, status, dispatch],
);
// Trigger the click event if clicking outside a link, button, or label inside a status.
const handleClick: React.MouseEventHandler<HTMLDivElement> = useCallback(
(event) => {
const { target } = event;
if (
!onClick ||
!(target instanceof Element) ||
target.closest(':is(a, button, label)')
) {
return;
}
onClick(event);
},
[onClick],
);
const hrefToMention = useCallback(
(href: string) => status?.mentions.find((item) => item.url === href),
[status?.mentions],
);
const hrefToCollectionId = useCallback(
(href: string) =>
status?.tagged_collections.find((item) => item.url === href)?.id,
[status?.tagged_collections],
);
const htmlHandlers = useElementHandledLink({
hashtagAccountId: status?.account,
hrefToCollectionId,
hrefToMention,
});
if (!status) {
return null;
}
const language = status.translation?.language ?? status.language;
const renderReadMore = !!onClick && status.collapsed;
const readMoreButton = renderReadMore && (
<button
className='status__content__read-more-button'
type='button'
onClick={onClick}
key='read-more'
>
<FormattedMessage id='status.read_more' defaultMessage='Read more' />
<Icon id='angle-right' icon={ChevronRightIcon} />
</button>
);
const renderTranslate =
!!onTranslate &&
signedIn &&
['public', 'unlisted'].includes(status.visibility) &&
status.search_index &&
status.search_index.trim().length > 0 &&
targetLanguages?.includes(intl.locale.replace(/[_-].*/, ''));
const translateButton = renderTranslate && (
<TranslateButton onClick={onTranslate} translation={status.translation} />
);
const poll = !!status.poll && (
<Poll
pollId={status.poll}
statusUrl={status.uri}
accountId={status.account}
lang={language}
/>
);
const content = (
<EmojiHTML
className='status__content__text status__content__text--visible translate'
lang={language}
htmlString={status.translation?.contentHtml ?? status.contentHtml}
extraEmojis={status.emojis}
{...htmlHandlers}
/>
);
const classNames = classnames('status__content', {
'status__content--with-action': onClick,
'status__content--collapsed': renderReadMore,
});
if (!onClick) {
return (
<div className={classNames} ref={handleCollapse}>
{content}
{poll}
{translateButton}
</div>
);
}
/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
return (
<>
<div className={classNames} ref={handleCollapse} onClick={handleClick}>
{content}
{poll}
{translateButton}
</div>
{readMoreButton}
</>
);
/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
};
const TranslateButton: React.FC<{
onClick: React.MouseEventHandler<HTMLButtonElement>;
translation?: StatusTranslation;
}> = ({ translation, onClick }) => {
if (!translation) {
return (
<button
type='button'
className='status__content__translate-button'
onClick={onClick}
>
<FormattedMessage id='status.translate' defaultMessage='Translate' />
</button>
);
}
const language = preloadedLanguages?.find(
(lang) => lang[0] === translation.detected_source_language,
);
const languageName = language
? language[1]
: translation.detected_source_language;
const provider = translation.provider;
return (
<div className='translate-button'>
<button type='button' className='link-button' onClick={onClick}>
<FormattedMessage
id='status.show_original'
defaultMessage='Show original'
/>
</button>
<div className='translate-button__meta'>
<FormattedMessage
id='status.translated_from_with'
defaultMessage='Translated from {lang} using {provider}'
values={{ lang: languageName, provider }}
/>
</div>
</div>
);
};
@@ -1,16 +1,15 @@
import { useEffect, useRef, useState, useId } from 'react';
import { useEffect, useState, useId } from 'react';
import { FormattedMessage, useIntl } from 'react-intl';
import classNames from 'classnames';
import Overlay from 'react-overlays/Overlay';
import { useDismissible } from '@/mastodon/hooks/useDismissible';
import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
import { Button } from '../button';
import { Icon } from '../icon';
import { Popover } from '../popover';
import classes from './remove_quote_hint.module.css';
@@ -28,7 +27,9 @@ export const RemoveQuoteHint: React.FC<{
className?: string;
children: (dismiss: () => void) => React.ReactNode;
}> = ({ canShowHint, className, children }) => {
const anchorRef = useRef<HTMLDivElement>(null);
const [anchorElement, setAnchorElement] = useState<HTMLDivElement | null>(
null,
);
const intl = useIntl();
const { wasDismissed, dismiss } = useDismissible(DISMISSIBLE_BANNER_ID);
@@ -57,16 +58,16 @@ export const RemoveQuoteHint: React.FC<{
}, [shouldShowHint, uniqueId]);
return (
<div className={className} ref={anchorRef}>
<div className={className} ref={setAnchorElement}>
{children(dismiss)}
{shouldShowHint && isOnlyHint && (
<Overlay
show
flip
offset={[12, 10]}
<Popover
isOpen
offset={{ mainAxis: 10, crossAxis: 12 }}
placement='bottom-end'
target={anchorRef as React.RefObject<HTMLDivElement>}
container={anchorRef as React.RefObject<HTMLDivElement>}
reference={anchorElement}
container={anchorElement}
onClose={dismiss}
>
{({ props, placement }) => (
<div
@@ -113,7 +114,7 @@ export const RemoveQuoteHint: React.FC<{
</FormattedMessage>
</div>
)}
</Overlay>
</Popover>
)}
</div>
);
@@ -208,7 +208,7 @@ class StatusContent extends PureComponent {
);
const poll = !!status.get('poll') && (
<Poll pollId={status.get('poll')} status={status} lang={language} />
<Poll pollId={status.get('poll')} statusUrl={status.get('uri')} accountId={status.getIn(['account', 'id'])} lang={language} />
);
if (this.props.onClick) {
@@ -5,8 +5,6 @@ import { defineMessages, useIntl } from 'react-intl';
import classNames from 'classnames';
import type { OffsetValue } from 'react-overlays/esm/usePopper';
import type { ModalType } from '@/mastodon/actions/modal';
import { openModal } from '@/mastodon/actions/modal';
import { Dropdown } from '@/mastodon/components/dropdown_menu';
@@ -118,7 +116,7 @@ export const AccountImageEdit: FC<{
<Dropdown
items={items}
placement={location === 'header' ? 'bottom-end' : 'bottom-start'}
offset={popperOffset}
offset={6}
className={classes.imageMenu}
icon='camera'
title={intl.formatMessage(messages.replace)}
@@ -127,5 +125,3 @@ export const AccountImageEdit: FC<{
/>
);
};
const popperOffset = [0, 6] as OffsetValue;
@@ -1,15 +1,14 @@
import { useCallback, useId, useRef, useState } from 'react';
import { useCallback, useId, useState } from 'react';
import type { ChangeEventHandler, FC } from 'react';
import { FormattedMessage } from 'react-intl';
import { useParams } from 'react-router';
import Overlay from 'react-overlays/esm/Overlay';
import { AccountTabs } from '@/mastodon/components/account_header/tabs';
import { Toggle } from '@/mastodon/components/form_fields';
import { Icon } from '@/mastodon/components/icon';
import { Popover } from '@/mastodon/components/popover';
import KeyboardArrowDownIcon from '@/material-icons/400-24px/keyboard_arrow_down.svg?react';
import { useAccountContext } from '../hooks/useAccountContext';
@@ -32,10 +31,12 @@ export const AccountFilters: FC = () => {
const FilterDropdown: FC = () => {
const [open, setOpen] = useState(false);
const buttonRef = useRef<HTMLButtonElement>(null);
const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(
null,
);
const handleClick = useCallback(() => {
setOpen(true);
setOpen((prev) => !prev);
}, []);
const handleHide = useCallback(() => {
setOpen(false);
@@ -55,14 +56,13 @@ const FilterDropdown: FC = () => {
);
const accessibleId = useId();
const containerRef = useRef<HTMLDivElement>(null);
return (
<div ref={containerRef}>
<div>
<button
type='button'
className={classes.filterSelectButton}
ref={buttonRef}
ref={setButtonElement}
onClick={handleClick}
aria-expanded={open}
aria-controls={`${accessibleId}-wrapper`}
@@ -97,13 +97,13 @@ const FilterDropdown: FC = () => {
className={classes.filterSelectIcon}
/>
</button>
<Overlay
show={open}
target={buttonRef as React.RefObject<HTMLButtonElement>}
<Popover
isOpen={open}
reference={buttonElement}
placement='bottom-start'
rootClose
onHide={handleHide}
container={containerRef as React.RefObject<HTMLDivElement>}
onClose={handleHide}
strategy='absolute'
container={null}
>
{({ props }) => (
<div
@@ -138,7 +138,7 @@ const FilterDropdown: FC = () => {
/>
</div>
)}
</Overlay>
</Popover>
</div>
);
};
@@ -1,11 +1,10 @@
import { useState, useRef, useCallback, useId } from 'react';
import { useState, useCallback, useId } from 'react';
import { FormattedMessage, useIntl, defineMessages } from 'react-intl';
import classNames from 'classnames';
import Overlay from 'react-overlays/Overlay';
import { Popover } from '@/mastodon/components/popover';
import QuestionMarkIcon from '@/material-icons/400-24px/question_mark.svg?react';
import { Icon } from 'mastodon/components/icon';
import { useSelectableClick } from 'mastodon/hooks/useSelectableClick';
@@ -17,7 +16,7 @@ const messages = defineMessages({
export const InfoButton: React.FC = () => {
const intl = useIntl();
const [open, setOpen] = useState(false);
const triggerRef = useRef<HTMLButtonElement>(null);
const [trigger, setTrigger] = useState<HTMLButtonElement | null>(null);
const accessibilityId = useId();
const handleClick = useCallback(() => {
@@ -31,7 +30,7 @@ export const InfoButton: React.FC = () => {
<button
type='button'
className={classNames('help-button', { active: open })}
ref={triggerRef}
ref={setTrigger}
onClick={handleClick}
aria-expanded={open}
aria-controls={accessibilityId}
@@ -40,13 +39,12 @@ export const InfoButton: React.FC = () => {
<Icon id='' icon={QuestionMarkIcon} />
</button>
<Overlay
show={open}
rootClose
<Popover
isOpen={open}
placement='top'
onHide={handleClick}
offset={[5, 5]}
target={triggerRef as React.RefObject<HTMLButtonElement>}
onClose={handleClick}
offset={5}
reference={trigger}
>
{({ props }) => (
<div // eslint-disable-line jsx-a11y/no-noninteractive-element-interactions
@@ -82,7 +80,7 @@ export const InfoButton: React.FC = () => {
/>
</div>
)}
</Overlay>
</Popover>
</>
);
};
@@ -6,11 +6,11 @@ import { defineMessages, FormattedMessage } from 'react-intl';
import classNames from 'classnames';
import { supportsPassiveEvents } from 'detect-passive-events';
import Overlay from 'react-overlays/Overlay';
import MoodIcon from '@/material-icons/400-20px/mood.svg?react';
import { IconButton } from 'mastodon/components/icon_button';
import { IconButton } from '@/mastodon/components/icon_button';
import { injectIntl } from '@/mastodon/components/intl';
import { Popover } from '@/mastodon/components/popover';
import { EmojiPicker as EmojiPickerAsync } from '../../ui/util/async-components';
@@ -175,16 +175,7 @@ class EmojiPickerMenuImpl extends PureComponent {
readyToFocus: false,
};
handleDocumentClick = e => {
if (this.node && !this.node.contains(e.target) && !this.props.pickerButtonRef.contains(e.target)) {
this.props.onClose();
}
};
componentDidMount() {
document.addEventListener('click', this.handleDocumentClick, { capture: true });
document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
// Because of https://github.com/react-bootstrap/react-bootstrap/issues/2614 we need
// to wait for a frame before focusing
requestAnimationFrame(() => {
@@ -196,11 +187,6 @@ class EmojiPickerMenuImpl extends PureComponent {
});
}
componentWillUnmount() {
document.removeEventListener('click', this.handleDocumentClick, { capture: true });
document.removeEventListener('touchend', this.handleDocumentClick, listenerOptions);
}
setRef = c => {
this.node = c;
};
@@ -307,7 +293,7 @@ class EmojiPickerDropdown extends PureComponent {
state = {
active: false,
loading: false,
placement: 'bottom',
target: null,
};
setRef = (c) => {
@@ -344,31 +330,17 @@ class EmojiPickerDropdown extends PureComponent {
}
};
handleKeyDown = e => {
if (e.key === 'Escape') {
this.onHideDropdown();
}
};
setTargetRef = c => {
this.target = c;
};
findTarget = () => {
return this.target;
};
handleOverlayEnter = (state) => {
this.setState({ placement: state.placement });
this.setState({ target: c });
};
render() {
const { intl, onPickEmoji, onSkinTone, skinTone, frequentlyUsedEmojis, disabled } = this.props;
const title = intl.formatMessage(messages.emoji);
const { active, loading, placement } = this.state;
const { active, loading, target } = this.state;
return (
<div className='emoji-picker-dropdown' onKeyDown={this.handleKeyDown} ref={this.setTargetRef}>
<div className='emoji-picker-dropdown' ref={this.setTargetRef}>
<IconButton
title={title}
aria-expanded={active}
@@ -380,23 +352,25 @@ class EmojiPickerDropdown extends PureComponent {
inverted
/>
<Overlay show={active} placement={placement} flip target={this.findTarget} popperConfig={{ strategy: 'fixed', onFirstUpdate: this.handleOverlayEnter }}>
<Popover
isOpen={active}
reference={target}
onClose={this.onHideDropdown}
>
{({ props, placement }) => (
<div {...props} style={{ ...props.style }}>
<div className={`dropdown-animation ${placement}`}>
<EmojiPickerMenu
loading={loading}
onClose={this.onHideDropdown}
onPick={onPickEmoji}
onSkinTone={onSkinTone}
skinTone={skinTone}
frequentlyUsedEmojis={frequentlyUsedEmojis}
pickerButtonRef={this.target}
/>
</div>
<div {...props} className={`dropdown-animation ${placement}`}>
<EmojiPickerMenu
loading={loading}
onClose={this.onHideDropdown}
onPick={onPickEmoji}
onSkinTone={onSkinTone}
skinTone={skinTone}
frequentlyUsedEmojis={frequentlyUsedEmojis}
pickerButtonRef={this.target}
/>
</div>
)}
</Overlay>
</Popover>
</div>
);
}
@@ -8,9 +8,8 @@ import { createSelector } from '@reduxjs/toolkit';
import { Map as ImmutableMap } from 'immutable';
import fuzzysort from 'fuzzysort';
import Overlay from 'react-overlays/Overlay';
import type { State, Placement } from 'react-overlays/usePopper';
import { Popover } from '@/mastodon/components/popover';
import CancelIcon from '@/material-icons/400-24px/cancel-fill.svg?react';
import SearchIcon from '@/material-icons/400-24px/search.svg?react';
import TranslateIcon from '@/material-icons/400-24px/translate.svg?react';
@@ -203,34 +202,13 @@ const LanguageDropdownMenu: React.FC<{
const isSearching = searchValue !== '';
useEffect(() => {
const handleDocumentClick = (e: MouseEvent) => {
if (
nodeRef.current &&
e.target instanceof HTMLElement &&
!nodeRef.current.contains(e.target)
) {
onClose();
e.stopPropagation();
}
};
document.addEventListener('click', handleDocumentClick, { capture: true });
// Because of https://github.com/react-bootstrap/react-bootstrap/issues/2614 we need
// to wait for a frame before focusing
requestAnimationFrame(() => {
if (nodeRef.current) {
const element = nodeRef.current.querySelector<HTMLInputElement>(
'input[type="search"]',
);
if (element) element.focus();
}
});
return () => {
document.removeEventListener('click', handleDocumentClick);
};
}, [onClose]);
if (nodeRef.current) {
const element = nodeRef.current.querySelector<HTMLInputElement>(
'input[type="search"]',
);
if (element) element.focus();
}
}, []);
const results = useMemo(() => {
if (searchValue === '') {
@@ -326,10 +304,9 @@ const LanguageDropdownMenu: React.FC<{
export const LanguageDropdown: React.FC = () => {
const [open, setOpen] = useState(false);
const [placement, setPlacement] = useState<Placement | undefined>('bottom');
const [guess, setGuess] = useState('');
const activeElementRef = useRef<HTMLElement>(null);
const targetRef = useRef<HTMLButtonElement>(null);
const activeElementRef = useRef<HTMLElement | null>(null);
const [targetElement, setTargetElement] = useState<HTMLElement | null>(null);
const intl = useIntl();
@@ -369,13 +346,6 @@ export const LanguageDropdown: React.FC = () => {
[dispatch],
);
const handleOverlayEnter = useCallback(
(state: Partial<State>) => {
setPlacement(state.placement);
},
[setPlacement],
);
useEffect(() => {
if (isTextLongEnoughForGuess(text)) {
debouncedGuess(text, setGuess);
@@ -402,7 +372,7 @@ export const LanguageDropdown: React.FC = () => {
<>
<button
type='button'
ref={targetRef}
ref={setTargetElement}
title={intl.formatMessage(messages.changeLanguage)}
aria-expanded={open}
onClick={handleToggle}
@@ -416,13 +386,11 @@ export const LanguageDropdown: React.FC = () => {
<span className='dropdown-button__label'>{current[2] ?? value}</span>
</button>
<Overlay
show={open}
offset={[5, 5]}
placement={placement}
flip
target={targetRef as React.RefObject<HTMLButtonElement>}
popperConfig={{ strategy: 'fixed', onFirstUpdate: handleOverlayEnter }}
<Popover
isOpen={open}
onClose={handleClose}
offset={5}
reference={targetElement}
>
{({ props, placement }) => (
<div {...props}>
@@ -438,7 +406,7 @@ export const LanguageDropdown: React.FC = () => {
</div>
</div>
)}
</Overlay>
</Popover>
</>
);
};
@@ -4,10 +4,8 @@ import { defineMessages, useIntl } from 'react-intl';
import classNames from 'classnames';
import type { OverlayProps } from 'react-overlays/Overlay';
import Overlay from 'react-overlays/Overlay';
import type { StatusVisibility } from '@/mastodon/api_types/statuses';
import { Popover } from '@/mastodon/components/popover';
import AlternateEmailIcon from '@/material-icons/400-24px/alternate_email.svg?react';
import LockIcon from '@/material-icons/400-24px/lock.svg?react';
import PublicIcon from '@/material-icons/400-24px/public.svg?react';
@@ -58,7 +56,6 @@ interface PrivacyDropdownProps {
value: StatusVisibility;
onChange: (value: StatusVisibility) => void;
noDirect?: boolean;
container?: OverlayProps['container'];
disabled?: boolean;
}
@@ -66,11 +63,12 @@ const PrivacyDropdown: React.FC<PrivacyDropdownProps> = ({
value,
onChange,
noDirect,
container,
disabled,
}) => {
const intl = useIntl();
const overlayTargetRef = useRef<HTMLDivElement>(null);
const [popoverTarget, setPopoverTarget] = useState<HTMLDivElement | null>(
null,
);
const previousFocusTargetRef = useRef<HTMLElement>(null);
const [isOpen, setIsOpen] = useState(false);
@@ -142,7 +140,7 @@ const PrivacyDropdown: React.FC<PrivacyDropdownProps> = ({
options.find((item) => item.value === value) ?? options.at(0);
return (
<div ref={overlayTargetRef}>
<div ref={setPopoverTarget}>
<button
type='button'
title={intl.formatMessage(messages.change_privacy)}
@@ -166,14 +164,11 @@ const PrivacyDropdown: React.FC<PrivacyDropdownProps> = ({
)}
</button>
<Overlay
show={isOpen}
offset={[5, 5]}
placement='bottom'
flip
target={overlayTargetRef as React.RefObject<HTMLDivElement>}
container={container}
popperConfig={{ strategy: 'fixed' }}
<Popover
isOpen={isOpen}
offset={5}
reference={popoverTarget}
onClose={handleClose}
>
{({ props, placement }) => (
<div {...props}>
@@ -190,7 +185,7 @@ const PrivacyDropdown: React.FC<PrivacyDropdownProps> = ({
</div>
</div>
)}
</Overlay>
</Popover>
</div>
);
};
@@ -60,6 +60,7 @@ export const Emoji: FC<EmojiProps> = ({
sheetSize={sheetSize}
skin={1}
tooltip={false}
forceSize={false}
{...{ useButton: true }}
{...props}
/>
@@ -73,7 +73,7 @@ export type CustomEmojiMapArg =
| ExtraCustomEmojiMap
| ImmutableList<CustomEmoji>
| CustomEmoji[]
| ApiCustomEmojiJSON[];
| Pick<ApiCustomEmojiJSON, 'shortcode' | 'static_url' | 'url'>[];
export type ExtraCustomEmojiMap = Record<
string,
@@ -1,11 +1,9 @@
import type { PropsWithChildren } from 'react';
import { useCallback, useState, useRef, useId } from 'react';
import { useCallback, useState, useId } from 'react';
import classNames from 'classnames';
import type { Placement, State as PopperState } from '@popperjs/core';
import Overlay from 'react-overlays/Overlay';
import { Popover } from '@/mastodon/components/popover';
import ArrowDropDownIcon from '@/material-icons/400-24px/arrow_drop_down.svg?react';
import type { SelectItem } from 'mastodon/components/dropdown_selector';
import { DropdownSelector } from 'mastodon/components/dropdown_selector';
@@ -18,7 +16,6 @@ interface DropdownProps {
onChange: (value: string) => void;
'aria-labelledby': string;
'aria-describedby'?: string;
placement?: Placement;
}
const Dropdown: React.FC<DropdownProps> = ({
@@ -28,22 +25,21 @@ const Dropdown: React.FC<DropdownProps> = ({
onChange,
'aria-labelledby': ariaLabelledBy,
'aria-describedby': ariaDescribedBy,
placement: initialPlacement = 'bottom-end',
}) => {
const containerRef = useRef<HTMLDivElement>(null);
const buttonRef = useRef<HTMLButtonElement>(null);
const [buttonElement, setButtonElement] = useState<HTMLButtonElement | null>(
null,
);
const [isOpen, setOpen] = useState<boolean>(false);
const [placement, setPlacement] = useState<Placement>(initialPlacement);
const uniqueId = useId();
const menuId = `${uniqueId}-menu`;
const buttonLabelId = `${uniqueId}-button`;
const handleClose = useCallback(() => {
if (isOpen && buttonRef.current) {
buttonRef.current.focus({ preventScroll: true });
if (isOpen && buttonElement) {
buttonElement.focus({ preventScroll: true });
}
setOpen(false);
}, [isOpen]);
}, [isOpen, buttonElement]);
const handleToggle = useCallback(() => {
if (isOpen) {
@@ -53,20 +49,13 @@ const Dropdown: React.FC<DropdownProps> = ({
}
}, [isOpen, handleClose]);
const handleOverlayEnter = useCallback(
(state: Partial<PopperState>) => {
if (state.placement) setPlacement(state.placement);
},
[setPlacement],
);
const valueOption = options.find((item) => item.value === value);
return (
<div ref={containerRef}>
<div>
<button
type='button'
ref={buttonRef}
ref={setButtonElement}
onClick={handleToggle}
disabled={disabled}
aria-expanded={isOpen}
@@ -81,30 +70,29 @@ const Dropdown: React.FC<DropdownProps> = ({
<Icon id='down' icon={ArrowDropDownIcon} />
</button>
<Overlay
show={isOpen}
offset={[5, 5]}
placement={placement}
flip
target={containerRef as React.RefObject<HTMLDivElement>}
popperConfig={{ strategy: 'fixed', onFirstUpdate: handleOverlayEnter }}
<Popover
isOpen={isOpen}
offset={5}
placement='bottom-end'
reference={buttonElement}
onClose={handleClose}
>
{({ props, placement }) => (
<div {...props} id={menuId}>
<div
className={`dropdown-animation privacy-dropdown__dropdown ${placement}`}
>
<DropdownSelector
items={options}
value={value}
onClose={handleClose}
onChange={onChange}
classNamePrefix='privacy-dropdown'
/>
</div>
<div
{...props}
id={menuId}
className={`dropdown-animation privacy-dropdown__dropdown ${placement}`}
>
<DropdownSelector
items={options}
value={value}
onClose={handleClose}
onChange={onChange}
classNamePrefix='privacy-dropdown'
/>
</div>
)}
</Overlay>
</Popover>
</div>
);
};
@@ -52,14 +52,6 @@ export const BoostModal: React.FC<{
onClose();
}, [onClose]);
const findContainer = useCallback(
() =>
document.getElementsByClassName(
'modal-root__container',
)[0] as HTMLDivElement,
[],
);
return (
<div className='modal-root__modal safety-action-modal'>
<div className='safety-action-modal__top'>
@@ -109,7 +101,6 @@ export const BoostModal: React.FC<{
<PrivacyDropdown
noDirect
value={privacy}
container={findContainer}
onChange={onPrivacyChange}
disabled={statusVisibility === 'private'}
/>
@@ -4,13 +4,8 @@ import { useIntl, defineMessages } from 'react-intl';
import { useLocation } from 'react-router-dom';
import type {
OffsetValue,
UsePopperOptions,
} from 'react-overlays/esm/usePopper';
import Overlay from 'react-overlays/Overlay';
import { DropdownMenu } from 'mastodon/components/dropdown_menu';
import { Popover } from 'mastodon/components/popover';
import { useIdentity } from 'mastodon/identity_context';
import type { MenuItem } from 'mastodon/models/dropdown_menu';
import { useAppSelector } from 'mastodon/store';
@@ -27,9 +22,6 @@ const messages = defineMessages({
muteHashtag: { id: 'hashtag.mute', defaultMessage: 'Mute #{hashtag}' },
});
const offset = [5, 5] as OffsetValue;
const popperConfig = { strategy: 'fixed' } as UsePopperOptions;
const isHashtagLink = (
element: HTMLAnchorElement | null,
): element is HTMLAnchorElement => {
@@ -135,30 +127,19 @@ export const HashtagMenuController: React.FC = () => {
}
return (
<Overlay
show={open}
offset={offset}
placement='bottom'
flip
target={element}
popperConfig={popperConfig}
>
{({ props, arrowProps, placement }) => (
<div {...props}>
<div className={`dropdown-animation dropdown-menu ${placement}`}>
<div
className={`dropdown-menu__arrow ${placement}`}
{...arrowProps}
/>
<DropdownMenu
items={menu}
onClose={handleClose}
openedViaKeyboard={false}
/>
</div>
<Popover isOpen={open} offset={5} reference={element} onClose={handleClose}>
{({ props, placement }) => (
<div
{...props}
className={`dropdown-animation dropdown-menu ${placement}`}
>
<DropdownMenu
items={menu}
onClose={handleClose}
openedViaKeyboard={false}
/>
</div>
)}
</Overlay>
</Popover>
);
};
@@ -3,47 +3,45 @@
*/
import type { RefObject } from 'react';
import { useEffect } from 'react';
import { useEffect, useEffectEvent } from 'react';
type ElementRef = RefObject<HTMLElement | null>;
type PlainElement = Element | null;
type ElementOrRef = PlainElement | RefObject<PlainElement>;
export function useOnClickOutside(
excludedElementRef: ElementRef | ElementRef[] | null,
excludedElement: ElementOrRef | ElementOrRef[],
onClick: (e: MouseEvent) => void,
enabled = true,
) {
useEffect(() => {
// If the search popover is expanded, close it when tabbing or
// clicking outside of it or the search form, while allowing
// tabbing or clicking inside of the popover
if (enabled) {
function handleClickOutside(event: MouseEvent) {
const excludedRefs = Array.isArray(excludedElementRef)
? excludedElementRef
: [excludedElementRef];
const handleClickOutside = useEffectEvent((event: MouseEvent) => {
const excludedRefs = Array.isArray(excludedElement)
? excludedElement
: [excludedElement];
for (const ref of excludedRefs) {
const excludedElement = ref?.current;
for (const ref of excludedRefs) {
const excludedElement = ref instanceof Element ? ref : ref?.current;
// Bail out if the clicked element or the currently focused element
// is inside of excludedElement. We're also checking the focused element
// to prevent an issue in Chrome where initiating a drag inside of an
// input (to select the text inside of it) and ending that drag outside
// of the input fires a click event, breaking our excludedElement rule.
if (
excludedElement &&
(excludedElement === event.target ||
excludedElement === document.activeElement ||
excludedElement.contains(event.target as Node) ||
excludedElement.contains(document.activeElement))
) {
return;
}
}
onClick(event);
// Bail out if the clicked element or the currently focused element
// is inside of excludedElement. We're also checking the focused element
// to prevent an issue in Chrome where initiating a drag inside of an
// input (to select the text inside of it) and ending that drag outside
// of the input fires a click event, breaking our excludedElement rule.
if (
excludedElement &&
(excludedElement === event.target ||
excludedElement === document.activeElement ||
excludedElement.contains(event.target as Node) ||
excludedElement.contains(document.activeElement))
) {
return;
}
}
onClick(event);
});
useEffect(() => {
if (enabled) {
document.addEventListener('click', handleClickOutside);
return () => {
@@ -51,5 +49,5 @@ export function useOnClickOutside(
};
}
return () => null;
}, [enabled, excludedElementRef, onClick]);
}, [enabled, excludedElement, onClick]);
}
+2 -1
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Падпісчыкі, якіх страцяць нашыя карыстальнікі",
"admin.impact_report.instance_follows": "Падпісчыкі, якіх могуць страціць іх карыстальнікі",
"admin.impact_report.title": "Агульны ўплыў",
"alert.need_reload.message": "Mastodon быў абноўлены. Некаторыя функцыі могуць працаваць некарэктна, пакуль Вы не перазагрузіце старонку.",
"alert.rate_limited.message": "Калі ласка, паспрабуйце праз {retry_time, time, medium}.",
"alert.rate_limited.title": "Ліміт перавышаны",
"alert.unexpected.message": "Узнікла нечаканая памылка.",
@@ -637,7 +638,7 @@
"empty_column.account_featured.other": "{acct} пакуль нічога не адабраў(-ла) для паказу.",
"empty_column.account_featured_self.no_collections_button": "Стварыць калекцыю",
"empty_column.account_featured_self.no_collections_hide_tab": "Або схаваць гэтую ўкладку",
"empty_column.account_featured_self.showcase_accounts": "Паказаць Вашыя ўлюбёныя ўліковыя запісы",
"empty_column.account_featured_self.showcase_accounts": "Пакажыце свае ўлюбёныя ўліковыя запісы",
"empty_column.account_featured_self.showcase_accounts_desc": "Калекцыі — спісы адабраных уліковых запісаў, якія дапамагаюць іншым знаходзіць нешта новае ў федэральным сусвеце.",
"empty_column.account_featured_unknown.other": "Гэты ўліковы запіс пакуль нічога не адабраў для паказу.",
"empty_column.account_hides_collections": "Гэты карыстальнік вырашыў схаваць гэтую інфармацыю",
+24
View File
@@ -199,7 +199,31 @@
"account_edit.field_reorder_modal.handle_label": "Přetáhněte pole \"{item}\"",
"account_edit.field_reorder_modal.title": "Přeuspořádat pole",
"account_edit.image_alt_modal.add_title": "Přidat alternativní text",
"account_edit.image_alt_modal.details_title": "Tipy: Alt text pro profilové fotky",
"account_edit.image_alt_modal.edit_title": "Upravit alt text",
"account_edit.image_alt_modal.text_hint": "Alt text pomáhá uživatelům používajícím čtečku obrazovky porozumět vašemu obsahu.",
"account_edit.image_alt_modal.text_label": "Alternativní text",
"account_edit.image_delete_modal.confirm": "Opravdu chcete smazat tento obrázek? Tuto akci nelze vrátit.",
"account_edit.image_delete_modal.delete_button": "Smazat",
"account_edit.image_delete_modal.title": "Smazat obrázek?",
"account_edit.image_edit.add_button": "Přidat obrázek",
"account_edit.image_edit.alt_add_button": "Přidat alt text",
"account_edit.image_edit.alt_edit_button": "Upravit alt text",
"account_edit.image_edit.remove_button": "Odstranit obrázek",
"account_edit.image_edit.replace_button": "Nahradit obrázek",
"account_edit.item_list.delete": "Odstranit {name}",
"account_edit.item_list.edit": "Upravit {name}",
"account_edit.name_modal.add_title": "Přidat zobrazované jméno",
"account_edit.name_modal.edit_title": "Upravit zobrazované jméno",
"account_edit.profile_tab.button_label": "Přizpůsobit",
"account_edit.save": "Uložit",
"account_edit.upload_modal.back": "Zpět",
"account_edit.upload_modal.done": "Hotovo",
"account_edit.upload_modal.next": "Další",
"account_edit.upload_modal.step_crop.zoom": "Přiblížit",
"account_edit.upload_modal.step_upload.button": "Procházet soubory",
"account_edit.upload_modal.step_upload.dragging": "Přetáhněte pro nahrání",
"account_edit.upload_modal.step_upload.header": "Vyberte obrázek",
"account_edit.upload_modal.step_upload.hint": "Formát WEBP, PNG, GIF nebo JPG, maximálně {limit}MB.{br}Obrázek bude převeden na rozměry {width}x{height}px.",
"account_edit.upload_modal.title_add.avatar": "Přidat profilovou fotku",
"account_edit.upload_modal.title_add.header": "Přidat úvodní fotku",
+4 -3
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Dilynwyr byddai ein defnyddwyr yn colli",
"admin.impact_report.instance_follows": "Dilynwyr byddai eu defnyddwyr yn colli",
"admin.impact_report.title": "Crynodeb effaith",
"alert.need_reload.message": "Mae Mastdon wedi'i ddiweddaru. Efallai na fydd rhai pethau'n gweithio'n iawn nes i chi ail-lwytho'r dudalen.",
"alert.rate_limited.message": "Ceisiwch eto ar ôl {retry_time, time, medium}.",
"alert.rate_limited.title": "Cyfradd gyfyngedig",
"alert.unexpected.message": "Digwyddodd gwall annisgwyl.",
@@ -586,9 +587,9 @@
"copypaste.copy_to_clipboard": "Copïo i'r clipfwrdd",
"custom_homepage.about": "Ynghylch",
"custom_homepage.about_this_server": "Ynghylch y gweinydd hwn",
"custom_homepage.administered_by": "Yn cael ei weinyddu gan:",
"custom_homepage.administered_by": "Yn cael ei weinyddu gan",
"custom_homepage.contact": "Cysylltiad:",
"custom_homepage.latest_activity": "Gweithred ddiwethaf:",
"custom_homepage.latest_activity": "Gweithred ddiwethaf",
"custom_homepage.these_are_the_latest_posts": "Dyma'r 40 cofnod diweddaraf o gyfrifon ar y gweinydd hwn.",
"directory.federated": "O'r ffedysawd cyfan",
"directory.local": "O {domain} yn unig",
@@ -1007,7 +1008,7 @@
"notifications.column_settings.admin.report": "Adroddiadau newydd:",
"notifications.column_settings.admin.sign_up": "Cofrestriadau newydd:",
"notifications.column_settings.alert": "Hysbysiadau bwrdd gwaith",
"notifications.column_settings.collections": "Casgliadau",
"notifications.column_settings.collections": "Casgliadau:",
"notifications.column_settings.favourite": "Ffefrynnau:",
"notifications.column_settings.filter_bar.advanced": "Dangos pob categori",
"notifications.column_settings.filter_bar.category": "Bar hidlo cyflym",
+1
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Følgere, vores brugere ville miste",
"admin.impact_report.instance_follows": "Følgere, deres brugere ville miste",
"admin.impact_report.title": "Resumé af effekt",
"alert.need_reload.message": "Mastodon er blevet opdateret. Nogle ting fungerer muligvis ikke korrekt, før du genindlæser siden.",
"alert.rate_limited.message": "Forsøg igen efter {retry_time, time, medium}.",
"alert.rate_limited.title": "Hastighedsbegrænset",
"alert.unexpected.message": "En uventet fejl opstod.",
+1
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Follower, die unsere Nutzer*innen verlieren würden",
"admin.impact_report.instance_follows": "Follower, die deren Nutzer*innen verlieren würden",
"admin.impact_report.title": "Zusammenfassung der Auswirkung",
"alert.need_reload.message": "Mastodon wurde aktualisiert. Möglicherweise funktioniert nicht alles ordnungsgemäß, bis die Seite neu geladen wurde.",
"alert.rate_limited.message": "Bitte versuche es um {retry_time, time, medium} erneut.",
"alert.rate_limited.title": "Anfragelimit überschritten",
"alert.unexpected.message": "Ein unerwarteter Fehler ist aufgetreten.",
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Seguidores que nuestros usuarios perderían",
"admin.impact_report.instance_follows": "Seguidores que perderían sus usuarios",
"admin.impact_report.title": "Resumen de impacto",
"alert.need_reload.message": "Se actualizó Mastodon. Algunas cosas pueden no funcionar correctamente hasta que recargues la página.",
"alert.rate_limited.message": "Por favor, reintentá después de las {retry_time, time, medium}.",
"alert.rate_limited.title": "Acción limitada",
"alert.unexpected.message": "Ocurrió un error.",
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Seguidores que nuestros usuarios perderían",
"admin.impact_report.instance_follows": "Seguidores que perderían sus usuarios",
"admin.impact_report.title": "Resumen de impacto",
"alert.need_reload.message": "Se ha actualizado Mastodon. Es posible que algunas cosas no funcionen correctamente hasta que refresques la página.",
"alert.rate_limited.message": "Por favor, intenta después de las {retry_time, time, medium}.",
"alert.rate_limited.title": "Tarifa limitada",
"alert.unexpected.message": "Hubo un error inesperado.",
+1
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Seguidores que nuestros usuarios perderían",
"admin.impact_report.instance_follows": "Seguidores que perderían sus usuarios",
"admin.impact_report.title": "Resumen de impacto",
"alert.need_reload.message": "Mastodon ha sido actualizado. Algunas cosas pueden no funcionar correctamente hasta que recargues la página.",
"alert.rate_limited.message": "Por favor, vuelve a intentarlo después de {retry_time, time, medium}.",
"alert.rate_limited.title": "Tráfico limitado",
"alert.unexpected.message": "Hubo un error inesperado.",
+1
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Seuraajat, jotka käyttäjämme menettäisivät",
"admin.impact_report.instance_follows": "Seuraajat, jotka heidän käyttäjänsä menettäisivät",
"admin.impact_report.title": "Vaikutusten yhteenveto",
"alert.need_reload.message": "Mastodon on päivitetty. Jotkin asiat eivät välttämättä toimi oikein, ennen kuin lataat sivun uudelleen.",
"alert.rate_limited.message": "Yritä uudelleen kello {retry_time, time, medium} jälkeen.",
"alert.rate_limited.title": "Pyyntömäärää rajoitettu",
"alert.unexpected.message": "Tapahtui odottamaton virhe.",
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Abonnés que nos utilisateurs perdraient",
"admin.impact_report.instance_follows": "Abonnées que ses utilisateurs perdraient",
"admin.impact_report.title": "Résumé de l'impact",
"alert.need_reload.message": "Mastodon a été mis à jour. Il peut y avoir des dysfonctionnements tant que vous ne rechargez pas la page.",
"alert.rate_limited.message": "Veuillez réessayer après {retry_time, time, medium}.",
"alert.rate_limited.title": "Débit limité",
"alert.unexpected.message": "Une erreur inattendue s’est produite.",
+1
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Abonné·e·s que nos utilisateur·rice·s perdraient",
"admin.impact_report.instance_follows": "Abonné·e·s que leurs utilisateur·rice·s perdraient",
"admin.impact_report.title": "Résumé de l'impact",
"alert.need_reload.message": "Mastodon a été mis à jour. Il peut y avoir des dysfonctionnements tant que vous ne rechargez pas la page.",
"alert.rate_limited.message": "Veuillez réessayer après {retry_time, time, medium}.",
"alert.rate_limited.title": "Nombre de requêtes limité",
"alert.unexpected.message": "Une erreur inattendue s’est produite.",
+1
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "As seguidoras que perderían as nosas usuarias",
"admin.impact_report.instance_follows": "As seguidoras que as súas usuarias perderían",
"admin.impact_report.title": "Resumo das consecuencias",
"alert.need_reload.message": "Actualizouse Mastodon. Pode que algunhas cousas non funcionen ben ata que volvas a cargar a páxina.",
"alert.rate_limited.message": "Téntao novamente após {retry_time, time, medium}.",
"alert.rate_limited.title": "Límite de intentos",
"alert.unexpected.message": "Aconteceu un fallo non agardado.",
+1
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "עוקבים שהמתשתמשים שלנו יאבדו",
"admin.impact_report.instance_follows": "עוקבים שהמתשתמשים שלהם יאבדו",
"admin.impact_report.title": "סיכום ההשפעה",
"alert.need_reload.message": "מסטודון שודרג. חלק מהדברים עלולים לא לעבוד כראוי עד שתרעננו את הדף.",
"alert.rate_limited.message": " נא לנסות שוב אחרי {retry_time, time, medium}.",
"alert.rate_limited.title": "חלה הגבלה על קצב התעבורה",
"alert.unexpected.message": "אירעה שגיאה בלתי צפויה.",
+1
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Követők, akiket a mi felhasználóink elveszítenének",
"admin.impact_report.instance_follows": "Követők, akiket az ő felhasználóik elveszítenének",
"admin.impact_report.title": "Hatásvizsgálat",
"alert.need_reload.message": "A Mastodon frissítve lett. Az oldal újratöltséig néhány dolog lehet, hogy nem fog megfelelően működni.",
"alert.rate_limited.message": "Próbáld újra {retry_time, time, medium} után.",
"alert.rate_limited.title": "Adatforgalom korlátozva",
"alert.unexpected.message": "Váratlan hiba történt.",
+5
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Fylgjendur sem notendur okkar myndu tapa",
"admin.impact_report.instance_follows": "Fylgjendur sem þeirra notendur myndu tapa",
"admin.impact_report.title": "Samantekt áhrifa",
"alert.need_reload.message": "Mastodon hefur verið uppfært. Sum atriði gætu virkað ekki rétt fyrr en þú hefur látið endurlesa síðuna.",
"alert.rate_limited.message": "Prófaðu aftur eftir {retry_time, time, medium}.",
"alert.rate_limited.title": "Með takmörkum",
"alert.unexpected.message": "Upp kom óvænt villa.",
@@ -561,6 +562,7 @@
"confirmations.remove_from_followers.message": "{name} mun hætta að fylgja þér. Ertu viss um að þú viljir halda áfram?",
"confirmations.remove_from_followers.title": "Fjarlægja fylgjanda?",
"confirmations.revoke_collection_inclusion.confirm": "Fjarlægja mig",
"confirmations.revoke_collection_inclusion.message": "Umsjónaraðilinn getur ekki bætt þér aftur í þetta safn í næstu 24 klukkustundir. Til að koma endanlega í veg fyrir að viðkomandi geti bætt þér í söfn ættirðu að loka á hann.",
"confirmations.revoke_collection_inclusion.title": "Á að fjarlægja þig úr þessu safni?",
"confirmations.revoke_quote.confirm": "Fjarlægja færslu",
"confirmations.revoke_quote.message": "Þessa aðgerð er ekki hægt að afturkalla.",
@@ -1137,6 +1139,9 @@
"report.categories.spam": "Ruslpóstur",
"report.categories.violation": "Efnið brýtur gegn einni eða fleiri reglum netþjónsins",
"report.category.subtitle": "Veldu hvað samsvarar best",
"report.category.title_account": "Segðu okkur hvað sé athugavert við þennan notandaaðgang",
"report.category.title_collection": "Segðu okkur hvað sé athugavert við þetta safn",
"report.category.title_status": "Segðu okkur hvað sé athugavert við þessa færslu",
"report.close": "Lokið",
"report.comment.title": "Er eitthvað annað sem þú heldur að við ættum að vita?",
"report.forward": "Áframsenda til {target}",
+1
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "I follower che i nostri utenti perderebbero",
"admin.impact_report.instance_follows": "I follower che i loro utenti perderebbero",
"admin.impact_report.title": "Riepilogo dell'impatto",
"alert.need_reload.message": "Mastodon è stato aggiornato. Alcune funzionalità potrebbero non funzionare correttamente finché non ricarichi la pagina.",
"alert.rate_limited.message": "Sei pregato di riprovare dopo le {retry_time, time, medium}.",
"alert.rate_limited.title": "Limitazione per eccesso di richieste",
"alert.unexpected.message": "Si è verificato un errore imprevisto.",
+10
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Fylgjarar som brukarane våre ville mista",
"admin.impact_report.instance_follows": "Fylgjarar som brukarane deira ville mista",
"admin.impact_report.title": "Samandrag av konsekvensane",
"alert.need_reload.message": "Mastodon er oppdatert. Nokre ting fungerer kanskje ikkje skikkeleg før du lastar sida på nytt.",
"alert.rate_limited.message": "Ver venleg å prøv på nytt etter {retry_time, time, medium}.",
"alert.rate_limited.title": "Redusert kapasitet",
"alert.unexpected.message": "Det oppstod eit uventa problem.",
@@ -561,6 +562,7 @@
"confirmations.remove_from_followers.message": "{name} vil ikkje fylgja deg meir. Vil du halda fram?",
"confirmations.remove_from_followers.title": "Fjern fylgjar?",
"confirmations.revoke_collection_inclusion.confirm": "Fjern meg",
"confirmations.revoke_collection_inclusion.message": "Kuratoren vil ikkje kunna leggja deg til att i denne samlinga på 24 timar. Du kan blokkera dei for å hindra dei i å leggja deg til i samlingar for alltid.",
"confirmations.revoke_collection_inclusion.title": "Vil du fjerna deg sjølv frå denne samlinga?",
"confirmations.revoke_quote.confirm": "Fjern innlegget",
"confirmations.revoke_quote.message": "Du kan ikkje angra denne handlinga.",
@@ -648,6 +650,7 @@
"empty_column.collections": "{acct} har ikkje laga nokon samlingar enno.",
"empty_column.collections.featured_in": "Du er ikkje lagt til i nokon samlingar enno.",
"empty_column.collections.featured_in_undiscoverable": "For at folk skal kunna leggja deg til i samlingar, må du gje dei løyve til å oppdaga deg i <link>Innstillingar > Personvern og rekkjevidd</link>",
"empty_column.collections_self": "Du har ikkje laga nokon samlingar enno.",
"empty_column.community": "Den lokale tidslina er tom. Skriv noko offentleg å få ballen til å rulle!",
"empty_column.direct": "Du har ingen private omtaler enda. Etter du har sendt eller mottatt en, så vil den dukke opp her.",
"empty_column.disabled_feed": "Administratorane på tenaren din har skrudd av denne straumen.",
@@ -779,6 +782,7 @@
"home.pending_critical_update.link": "Sjå oppdateringar",
"home.pending_critical_update.title": "Kritisk sikkerheitsoppdatering er tilgjengeleg!",
"home.show_announcements": "Vis kunngjeringar",
"ignore_notifications_modal.bots_title": "Oversjå varsel frå botar?",
"ignore_notifications_modal.disclaimer": "Mastodon kan ikkje informera brukarane at du overser varsla deira. Å oversjå varsel vil ikkje hindra at meldingane blir sende.",
"ignore_notifications_modal.filter_instead": "Filtrer i staden",
"ignore_notifications_modal.filter_to_act_users": "Du kan framleis godta, avvisa eller rapportera brukarar",
@@ -845,6 +849,7 @@
"keyboard_shortcuts.toggle_sensitivity": "Vis/gøym media",
"keyboard_shortcuts.toot": "Lag nytt tut",
"keyboard_shortcuts.top": "Flytt til toppen av lista",
"keyboard_shortcuts.translate": "Omset eit innlegg",
"keyboard_shortcuts.unfocus": "for å fokusere vekk skrive-/søkefeltet",
"keyboard_shortcuts.up": "Flytt opp på lista",
"learn_more_link.got_it": "Forstått",
@@ -1040,6 +1045,8 @@
"notifications.policy.drop": "Oversjå",
"notifications.policy.drop_hint": "Send ut i endeløysa så det aldri kjem att",
"notifications.policy.filter": "Filtrer",
"notifications.policy.filter_bots_hint": "Kontoar som er merkte som automatiske",
"notifications.policy.filter_bots_title": "Botar",
"notifications.policy.filter_hint": "Send til innboksen for filtrerte varsel",
"notifications.policy.filter_limited_accounts_hint": "Avgrensa av moderatorar på tenaren",
"notifications.policy.filter_limited_accounts_title": "Modererte kontoar",
@@ -1132,6 +1139,9 @@
"report.categories.spam": "Søppelpost",
"report.categories.violation": "Innhaldet bryt med ein eller fleire reglar for tenaren",
"report.category.subtitle": "Vel det som passar best",
"report.category.title_account": "Fortel oss kva som er i vegen med denne profilen",
"report.category.title_collection": "Fortel oss kva som er i vegen med denne samlinga",
"report.category.title_status": "Fortel oss kva som er i vegen med dette innlegget",
"report.close": "Ferdig",
"report.comment.title": "Er det noko anna du meiner me bør vite?",
"report.forward": "Vidaresend til {target}",
+47
View File
@@ -182,15 +182,18 @@
"account_edit.field_edit_modal.discard_confirm": "Odrzuć",
"account_edit.field_edit_modal.discard_message": "Masz niezapisane zmiany. Czy na pewno chcesz je odrzucić?",
"account_edit.field_edit_modal.edit_title": "Edytuj dodatkowe pole",
"account_edit.field_edit_modal.length_warning": "Przekroczono limit zalecanych znaków. Użytkownicy mobilni mogą nie widzieć Twojego pola w całości.",
"account_edit.field_edit_modal.name_hint": "Np. Strona osobista",
"account_edit.field_edit_modal.name_label": "Etykieta",
"account_edit.field_edit_modal.value_hint": "Np. \"https://example.me\"",
"account_edit.field_edit_modal.value_label": "Wartość",
"account_edit.field_reorder_modal.handle_label": "Przeciągnij pole \"{item}\"",
"account_edit.image_alt_modal.add_title": "Dodaj tekst alternatywny",
"account_edit.image_alt_modal.details_title": "Wskazówki: Tekst alternatywny dla zdjęć profilowych",
"account_edit.image_alt_modal.edit_title": "Edytuj tekst alternatywny",
"account_edit.image_alt_modal.text_hint": "Tekst alternatywny pomaga użytkownikom czytników ekranu zrozumieć twoją treść.",
"account_edit.image_alt_modal.text_label": "Tekst alternatywny",
"account_edit.image_delete_modal.confirm": "Czy na pewno chcesz usunąć ten obraz? Tej czynności nie można cofnąć.",
"account_edit.image_delete_modal.delete_button": "Usuń",
"account_edit.image_delete_modal.title": "Usunąć obraz?",
"account_edit.image_edit.add_button": "Dodaj obraz",
@@ -232,7 +235,9 @@
"account_edit.verified_modal.title": "Jak dodać zweryfikowany link",
"account_edit_tags.add_tag": "Dodaj #{tagName}",
"account_edit_tags.column_title": "Edytuj tagi",
"account_edit_tags.max_tags_reached": "Osiągnięto maksymalną liczbę wyróżnionych hasztagów.",
"account_edit_tags.search_placeholder": "Dodaj hashtag...",
"account_edit_tags.suggestions": "Propozycje:",
"account_list.hidden_notice": "To jest widoczne tylko dla Ciebie. Aby pokazać tę listę innym, przejdź do <link>{page} > {modal} > {field}</link>.",
"admin.dashboard.daily_retention": "Wskaźnik utrzymania użytkowników według dni od rejestracji",
"admin.dashboard.monthly_retention": "Wskaźnik utrzymania użytkowników według miesięcy od rejestracji",
@@ -243,6 +248,7 @@
"admin.impact_report.instance_followers": "Obserwujący, których straciliby nasi użytkownicy",
"admin.impact_report.instance_follows": "Obserwujący, których straciliby ich użytkownicy",
"admin.impact_report.title": "Podsumowanie zmian",
"alert.need_reload.message": "Mastodon został zaktualizowany. Niektóre rzeczy mogą nie działać poprawnie, dopóki nie odświeżysz strony.",
"alert.rate_limited.message": "Spróbuj ponownie po {retry_time, time, medium}.",
"alert.rate_limited.title": "Ograniczenie liczby zapytań",
"alert.unexpected.message": "Wystąpił nieoczekiwany błąd.",
@@ -326,14 +332,25 @@
"closed_registrations_modal.title": "Rejestracja na Mastodonie",
"collection.share_modal.share_link_label": "Udostępnij link",
"collection.share_modal.share_via_system": "Udostępnij…",
"collection.share_modal.title": "Udostępnij kolekcję",
"collection.share_modal.title_new": "Udostępnij swoją nową kolekcję!",
"collection.share_template_own": "Sprawdź moją nową kolekcję:",
"collections.accounts.empty_description": "Dodaj maksymalnie {count} użytkowników",
"collections.accounts.empty_editor_title": "W tej kolekcji nie ma jeszcze nikogo",
"collections.accounts.empty_title": "Ta kolekcja jest pusta",
"collections.add_to_collection": "Dodaj {name} do kolekcji",
"collections.by_account": "przez {account_handle}",
"collections.collection_description": "Opis",
"collections.collection_language": "Język",
"collections.collection_language_none": "Brak",
"collections.collection_name": "Nazwa",
"collections.collection_topic": "Temat",
"collections.confirm_account_removal": "Czy na pewno chcesz usunąć to konto z tej kolekcji?",
"collections.content_warning": "Ostrzeżenie o zawartości",
"collections.continue": "Kontynuuj",
"collections.copy_link": "Skopiuj link",
"collections.copy_link_confirmation": "Skopiowano link kolekcji do schowka",
"collections.create.accounts_title": "Kogo umieścisz w tej kolekcji?",
"collections.create.basic_details_title": "Podstawowe informacje",
"collections.create.steps": "Krok {step}/{total}",
"collections.create_collection": "Utwórz kolekcję",
@@ -343,23 +360,42 @@
"collections.detail.revoke_inclusion": "Usuń mnie",
"collections.detail.sensitive_content": "Wrażliwa zawartość",
"collections.detail.share": "Udostępnij tę kolekcję",
"collections.detail.you_are_in_this_collection": "Jesteś wyróżniony w tej kolekcji",
"collections.edit_details": "Edytuj szczegóły",
"collections.last_updated_at": "Ostatnia aktualizacja: {date}",
"collections.list.created_by_author": "Utworzone przez {name}",
"collections.list.created_by_you": "Stworzone przez Ciebie",
"collections.list.featuring_you": "Zawierające Ciebie",
"collections.manage_accounts": "Zarządzanie kontami",
"collections.mark_as_sensitive": "Oznacz jako wrażliwe",
"collections.mark_as_sensitive_hint": "Ukrywa opis kolekcji i konta za ostrzeżeniem o zawartości. Nazwa kolekcji pozostanie widoczna.",
"collections.maximum_collection_count_description": "Twój serwer pozwala na tworzenie do {count} kolekcji.",
"collections.name_length_hint": "Limit 40 znaków",
"collections.new_collection": "Nowa kolekcja",
"collections.remove_account": "Usuń",
"collections.report_collection": "Zgłoś tę kolekcję",
"collections.revoke_collection_inclusion": "Usuń się z tej kolekcji",
"collections.revoke_inclusion.confirmation": "Zostałeś(aś) usunięty(a) z \"{collection}\"",
"collections.revoke_inclusion.error": "Wystąpił błąd, proszę spróbować ponownie później.",
"collections.search_accounts_label": "Wyszukaj konto do dodania",
"collections.search_accounts_max_reached": "Przekroczono maksymalną liczbę dodanych użytkowników",
"collections.share_short": "Udostępnij",
"collections.sort_alphabetical": "Alfabetycznie",
"collections.sort_by": "Sortuj według:",
"collections.sort_date_added": "Data dodania",
"collections.sort_last_active": "Ostatnia aktywność",
"collections.sort_most_followers": "Najwięcej obserwujących",
"collections.suggestions.can_not_add": "Nie można dodać",
"collections.suggestions.can_not_add_desc": "Te konta mogły zrezygnować z funkcji odkrywania albo znajdują się na serwerze, który nie obsługuje kolekcji.",
"collections.suggestions.must_follow": "Musisz najpierw obserwować",
"collections.topic_hint": "Dodaj hasztag, który pomoże innym zrozumieć główny temat tej kolekcji.",
"collections.topic_special_chars_hint": "Znaki specjalne zostaną usunięte podczas zapisywania",
"collections.view_collection": "Pokaż kolekcję",
"collections.visibility_public": "Publiczna",
"collections.visibility_public_hint": "Widoczna w wynikach wyszukiwania i innych miejscach, gdzie pojawiają się rekomendacje.",
"collections.visibility_title": "Widoczność",
"collections.visibility_unlisted": "Niewidoczna",
"collections.visibility_unlisted_hint": "Widoczna dla każdego, kto ma link. Ukryta w wynikach wyszukiwania i rekomendacjach.",
"column.about": "O serwerze",
"column.blocks": "Zablokowani",
"column.bookmarks": "Zakładki",
@@ -426,6 +462,7 @@
"confirmations.delete.message": "Czy na pewno chcesz usunąć ten wpis?",
"confirmations.delete.title": "Usunąć wpis?",
"confirmations.delete_collection.confirm": "Usuń",
"confirmations.delete_collection.title": "Usunąć „{name}\"?",
"confirmations.delete_list.confirm": "Usuń",
"confirmations.delete_list.message": "Czy na pewno chcesz trwale usunąć tę listę?",
"confirmations.delete_list.title": "Usunąć listę?",
@@ -441,6 +478,7 @@
"confirmations.follow_to_list.confirm": "Obserwuj i dodaj do listy",
"confirmations.follow_to_list.message": "Musisz obserwować {name}, aby dodać do listy.",
"confirmations.follow_to_list.title": "Zaobserwować?",
"confirmations.hide_featured_tab.confirm": "Ukryj zakładkę",
"confirmations.hide_featured_tab.title": "Ukryć zakładkę \"Wyróżnione\"?",
"confirmations.logout.confirm": "Wyloguj",
"confirmations.logout.message": "Czy na pewno chcesz się wylogować?",
@@ -531,6 +569,7 @@
"emoji_button.travel": "Podróże i miejsca",
"empty_column.account_featured_self.no_collections_button": "Stwórz kolekcję",
"empty_column.account_featured_self.showcase_accounts": "Pokaż swoje ulubione konta",
"empty_column.account_featured_self.showcase_accounts_desc": "Kolekcje to wyselekcjonowane listy kont, które pomagają innym odkrywać więcej zakątków Fediwersum.",
"empty_column.account_hides_collections": "Ta osoba postanowiła nie udostępniać tych informacji",
"empty_column.account_suspended": "Konto zawieszone",
"empty_column.account_timeline": "Brak wpisów!",
@@ -625,6 +664,7 @@
"footer.source_code": "Zobacz kod źródłowy",
"footer.status": "Status",
"footer.terms_of_service": "Regulamin",
"form_field.optional": "(opcjonalnie)",
"getting_started.heading": "Pierwsze kroki",
"hashtag.admin_moderation": "Otwórz interfejs moderacji #{name}",
"hashtag.browse": "Przeglądaj posty z #{hashtag}",
@@ -724,6 +764,8 @@
"keyboard_shortcuts.toggle_hidden": "Pokaż lub ukryj tekst z ostrzeżeniem",
"keyboard_shortcuts.toggle_sensitivity": "Pokaż lub ukryj multimedia",
"keyboard_shortcuts.toot": "Stwórz nowy wpis",
"keyboard_shortcuts.top": "Przenieś na górę listy",
"keyboard_shortcuts.translate": "Przetłumacz wpis",
"keyboard_shortcuts.unfocus": "Opuść pole tekstowe",
"keyboard_shortcuts.up": "Przesuń w górę na liście",
"learn_more_link.got_it": "Rozumiem",
@@ -734,6 +776,7 @@
"lightbox.zoom_in": "Powiększ do rzeczywistego rozmiaru",
"lightbox.zoom_out": "Powiększ, aby dopasować",
"limited_account_hint.action": "Pokaż profil mimo to",
"limited_account_hint.title": "Ten profil lub serwer został ukryty przez moderatorów {domain}.",
"link_preview.author": "{name}",
"link_preview.more_from_author": "Więcej od {name}",
"link_preview.shares": "{count, plural, one {{counter} wpis} few {{counter} wpisy} many {{counter} wpisów} other {{counter} wpisów}}",
@@ -1127,9 +1170,11 @@
"status.quote": "Cytuj",
"status.quote.cancel": "Anuluj cytat",
"status.quote_error.blocked_account_hint.title": "Ten wpis jest ukryty, ponieważ zablokowałeś(aś) @{name}.",
"status.quote_error.blocked_domain_hint.title": "Ten wpis jest ukryty, ponieważ zablokowano {domain}.",
"status.quote_error.filtered": "Ukryte z powodu jednego z Twoich filtrów",
"status.quote_error.limited_account_hint.action": "Pokaż mimo wszystko",
"status.quote_error.limited_account_hint.title": "To konto zostało ukryte przez moderatorów {domain}.",
"status.quote_error.muted_account_hint.title": "Ten wpis jest ukryty, ponieważ wyciszono @{name}.",
"status.quote_error.not_available": "Post niedostępny",
"status.quote_error.pending_approval": "Post oczekujący",
"status.quote_error.pending_approval_popout.body": "Na Mastodon możesz kontrolować, czy ktoś może cytować twoje wpisy. Ten wpis oczekuje na zatwierdzenie przez autora.",
@@ -1180,6 +1225,7 @@
"tabs_bar.menu": "Menu",
"tabs_bar.notifications": "Powiadomienia",
"tabs_bar.publish": "Nowy post",
"tabs_bar.quick_links": "Szybki dostęp",
"tabs_bar.search": "Szukaj",
"tag.remove": "Usuń",
"terms_of_service.effective_as_of": "Obowiązuje od {date}",
@@ -1225,6 +1271,7 @@
"video.volume_down": "Zmniejsz głośność",
"video.volume_up": "Zwiększ głośność",
"visibility_modal.button_title": "Ustaw widoczność",
"visibility_modal.direct_quote_warning.text": "Jeśli zapiszesz bieżące ustawienia, osadzony cytat zostanie zamieniony na link.",
"visibility_modal.direct_quote_warning.title": "Cytaty nie mogą być osadzane we wzmiankach prywatnych",
"visibility_modal.header": "Widoczność i interakcja",
"visibility_modal.helper.direct_quoting": "Prywatne wzmianki opublikowane na Mastodonie nie mogą być cytowane przez inne osoby.",
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Seguidores que os nossos usuários perderiam",
"admin.impact_report.instance_follows": "Seguidores que os usuários deles perderiam",
"admin.impact_report.title": "Resumo do impacto",
"alert.need_reload.message": "O Mastodon foi atualizado. Algumas coisas podem não funcionar corretamente até você recarregar a página.",
"alert.rate_limited.message": "Tente novamente após {retry_time, time, medium}.",
"alert.rate_limited.title": "Tentativas limitadas",
"alert.unexpected.message": "Ocorreu um erro inesperado.",
+1
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Följare som våra användare skulle förlora",
"admin.impact_report.instance_follows": "Följare som deras användare skulle förlora",
"admin.impact_report.title": "Sammanfattning av påverkan",
"alert.need_reload.message": "Mastodon har uppdaterats. Vissa saker kanske inte fungerar korrekt förrän du laddar om sidan.",
"alert.rate_limited.message": "Vänligen försök igen efter {retry_time, time, medium}.",
"alert.rate_limited.title": "Hastighetsbegränsad",
"alert.unexpected.message": "Ett oväntat fel uppstod.",
+1
View File
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "Kullanıcılarımızın kaybedeceği takipçiler",
"admin.impact_report.instance_follows": "Kullanıcılarının kaybedeceği takipçiler",
"admin.impact_report.title": "Etki özeti",
"alert.need_reload.message": "Mastodon güncellendi. Siz sayfayı yenileyene kadar bazı şeyler çalışmayabilir.",
"alert.rate_limited.message": "Lütfen sonra tekrar deneyin {retry_time, time, medium}.",
"alert.rate_limited.title": "Aşırı istek gönderildi",
"alert.unexpected.message": "Beklenmedik bir hata oluştu.",
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "本站用户即将丢失的关注者",
"admin.impact_report.instance_follows": "对方站点用户即将丢失的关注者",
"admin.impact_report.title": "影响摘要",
"alert.need_reload.message": "Mastodon 已更新。在你刷新页面之前,部分功能可能无法正常工作。",
"alert.rate_limited.message": "请在 {retry_time, time, medium} 后重试。",
"alert.rate_limited.title": "频率受限",
"alert.unexpected.message": "发生了意外错误。",
@@ -267,6 +267,7 @@
"admin.impact_report.instance_followers": "此伺服器之跟隨者將流失",
"admin.impact_report.instance_follows": "彼伺服器之跟隨者將流失",
"admin.impact_report.title": "影響總結",
"alert.need_reload.message": "Mastodon 已完成更新。某些功能可能暫時無法使用,直至您重新整理此頁面。",
"alert.rate_limited.message": "請於 {retry_time, time, medium} 後重試。",
"alert.rate_limited.title": "已限速",
"alert.unexpected.message": "發生非預期的錯誤。",
+1 -1
View File
@@ -47,7 +47,7 @@ export interface StatusShape {
pinned: boolean;
filtered: FilterResult[];
sensitive: boolean;
collapsed: boolean;
collapsed: boolean | null;
uri: string;
url: string | null;
+4 -10
View File
@@ -731,10 +731,12 @@ table + p {
}
.email-banner-td {
padding: 24px 24px 14px;
padding: 24px;
}
.email-banner-text-td {
text-align: center;
p {
margin: 0 0 12px;
color: #fff;
@@ -743,12 +745,9 @@ table + p {
line-height: 16.8px;
}
.email-desktop-flex {
align-items: center;
}
.email-btn-table {
background-color: #fff;
margin: 0 auto;
}
.email-btn-td {
@@ -760,11 +759,6 @@ table + p {
padding-left: 10px;
padding-right: 10px;
}
div + div {
margin-inline-start: auto;
margin-bottom: 12px;
}
}
// Checklist item
+9 -14
View File
@@ -372,7 +372,7 @@
}
}
body > [data-popper-placement] {
body > [data-popover-placement] {
z-index: 9999;
}
@@ -4091,9 +4091,8 @@ a.account__display-name {
align-items: center;
gap: 8px;
width: 100%;
padding: 10px;
padding-inline-start: 14px;
overflow: hidden;
padding: 12px;
padding-inline-start: 16px;
font-size: 16px;
font-weight: 400;
text-decoration: none;
@@ -4104,7 +4103,7 @@ a.account__display-name {
var(--color-text-secondary)
);
background: transparent;
border: 2px solid transparent;
border: none;
border-radius: 4px;
&:hover,
@@ -4118,14 +4117,14 @@ a.account__display-name {
}
&:focus-visible {
outline: none;
border-color: var(--color-border-brand);
outline: var(--outline-focus-default);
outline-offset: -2px;
background: var(--color-bg-brand-softest);
}
&--logo {
padding: 8px;
padding-inline-start: 12px;
padding: 10px;
padding-inline-start: 14px;
}
}
@@ -5772,10 +5771,6 @@ a.status-card {
}
.visibility-dropdown {
&__overlay[data-popper-placement] {
z-index: 9999;
}
&.disabled {
opacity: 0.6;
cursor: default;
@@ -10715,7 +10710,7 @@ noscript {
}
}
.hover-card-controller[data-popper-reference-hidden='true'] {
.hover-card-controller[data-popover-reference-hidden='true'] {
opacity: 0;
pointer-events: none;
}
+1 -1
View File
@@ -24,7 +24,7 @@ class Multibase
case string[0]
when 'u'
Base64.decode(string[1...])
Base64.urlsafe_decode64(string[1...])
when 'z'
Base58.base58_to_binary(string[1...], :bitcoin)
else
@@ -19,17 +19,8 @@
%table.email-w-full{ cellspacing: 0, cellpadding: 0, border: 0, role: 'presentation' }
%tr
%td.email-banner-text-td
.email-desktop-flex
/[if mso]
<table border="0" cellpadding="0" cellspacing="0" align="center" style="width:100%;" role="presentation"><tr><td vertical-align:top;">
%div
%p= t('.interact_with_this_post', count: @statuses.size)
/[if mso]
</td><td style="vertical-align:top;">
%div
= render 'application/mailer/button', text: t('.create_account'), url: available_sign_up_url, has_arrow: false
/[if mso]
</td></tr></table>
%p= t('.interact_with_this_post', count: @statuses.size)
= render 'application/mailer/button', text: t('.create_account'), url: available_sign_up_url, has_arrow: false
- content_for :footer do
%p.email-footer-p= t('.footer.reason_for_email_html', name: display_name(@subscription.account), unsubscribe_path: @unsubscribe_url)
+1 -1
View File
@@ -6,4 +6,4 @@
per_page: number of items to fetch per page
remote: data-remote
%span.page.gap
!= t('pagination.truncate')
= t('pagination.truncate_html')
Loaded 100 of 178 files, more files were not shown because too many files have changed in this diff. Show more