Fun picker: Emoji skin tones picker and recent gifs

This commit is contained in:
Jamie Kyle
2025-04-10 12:32:36 -07:00
committed by GitHub
parent b22aaaec7e
commit 8301e69e05
33 changed files with 834 additions and 100 deletions

View File

@@ -1,29 +1,65 @@
// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { MouseEvent as ReactMouseEvent, ReactNode } from 'react';
import React from 'react';
import type { ForwardedRef, MouseEvent, ReactNode } from 'react';
import React, { forwardRef } from 'react';
import {
mergeProps,
type PressEvent,
useLongPress,
usePress,
} from 'react-aria';
import type { LongPressEvent } from '@react-types/shared';
/**
* Button
*/
export type FunItemButtonProps = Readonly<{
'aria-label': string;
tabIndex: number;
onClick: (event: ReactMouseEvent) => void;
children: ReactNode;
}>;
export type FunItemButtonLongPressProps = Readonly<
| {
longPressAccessibilityDescription?: never;
onLongPress?: never;
}
| {
longPressAccessibilityDescription: string;
onLongPress: (event: LongPressEvent) => void;
}
>;
export type FunItemButtonProps = Readonly<
{
'aria-label': string;
tabIndex: number;
onPress: (event: PressEvent) => void;
onContextMenu?: (event: MouseEvent) => void;
children: ReactNode;
} & FunItemButtonLongPressProps
>;
export const FunItemButton = forwardRef(function FunItemButton(
props: FunItemButtonProps,
ref: ForwardedRef<HTMLButtonElement>
): JSX.Element {
const { pressProps } = usePress({
onPress: props.onPress,
});
const { longPressProps } = useLongPress({
isDisabled: props.onLongPress == null,
accessibilityDescription: props.longPressAccessibilityDescription,
onLongPress: props.onLongPress,
});
export function FunItemButton(props: FunItemButtonProps): JSX.Element {
return (
<button
ref={ref}
type="button"
className="FunItem__Button"
aria-label={props['aria-label']}
onClick={props.onClick}
tabIndex={props.tabIndex}
{...mergeProps(pressProps, longPressProps)}
onContextMenu={props.onContextMenu}
>
{props.children}
</button>
);
}
});