Skip to content

Commit

Permalink
Merge pull request #42 from gunnartorfis/important
Browse files Browse the repository at this point in the history
feat: important accessibility settings for Android
  • Loading branch information
gunnartorfis authored Sep 8, 2024
2 parents 4d8b9a2 + a663f65 commit 62fc328
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/docs/sonner.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
| loading |||
| Headless |||
| Dynamic position |||
| important | ||
| important | ||
| warning variant |||

## Toaster:
Expand Down
5 changes: 4 additions & 1 deletion src/gestures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import Animated, {
} from 'react-native-reanimated';
import { easeInOutCircFn } from './easings';
import { useToastContext } from './context';
import type { ToastProps } from './types';

const { width: WINDOW_WIDTH } = Dimensions.get('window');

type ToastSwipeHandlerProps = {
type ToastSwipeHandlerProps = Pick<ToastProps, 'important'> & {
onRemove: () => void;
style?: ViewStyle | (ViewStyle | undefined)[];
className?: string;
Expand All @@ -36,6 +37,7 @@ export const ToastSwipeHandler: React.FC<
onFinalize,
enabled,
unstyled,
important,
}) => {
const translate = useSharedValue(0);
const { swipToDismissDirection: direction } = useToastContext();
Expand Down Expand Up @@ -117,6 +119,7 @@ export const ToastSwipeHandler: React.FC<
]}
className={className}
layout={LinearTransition.easing(easeInOutCircFn)}
aria-live={important ? 'assertive' : 'polite'} // https://reactnative.dev/docs/accessibility#aria-live-android
>
{children}
</Animated.View>
Expand Down
2 changes: 2 additions & 0 deletions src/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const Toast: React.FC<ToastProps> = ({
styles,
promiseOptions,
unstyled: unstyledProps,
important,
}) => {
const {
duration: durationCtx,
Expand Down Expand Up @@ -198,6 +199,7 @@ export const Toast: React.FC<ToastProps> = ({
style={[stylesCtx.toastContainer, styles?.toastContainer]}
className={cn(classNamesCtx.toastContainer, classNames?.toastContainer)}
unstyled={unstyled}
important={important}
>
<Animated.View
className={cn(className, classNamesCtx.toast, classNames?.toast)}
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export type ToastProps = StyleProps & {
description?: string;
closeButton?: boolean;
invert?: boolean;
// important?: boolean; (false) Control the sensitivity of the toast for screen readers
important?: boolean;
duration?: number;
position?: ToastPosition;
dismissible?: boolean;
Expand Down

0 comments on commit 62fc328

Please sign in to comment.