Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/avatars/demo/avatar.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import README from '../README.md';
name="Avatar"
args={{ type: TYPE[1] }}
argTypes={{
'aria-hidden': { control: 'boolean' },
backgroundColor: { control: 'color' },
badge: { control: 'text' },
foregroundColor: { control: 'color' },
Expand Down
12 changes: 12 additions & 0 deletions packages/avatars/src/elements/Avatar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ describe('Avatar', () => {
expect(element).toBeInTheDocument();
});

it('does not render status with `aria-hidden`', () => {
const label = 'test status';
const { queryByText } = render(
<Avatar aria-hidden badge="0" statusLabel={label}>
<img alt="" />
</Avatar>
);
const element = queryByText(label);

expect(element).not.toBeInTheDocument();
});

it('renders with status and applies default label for available status', () => {
const { getByText } = render(
<Avatar status="available">
Expand Down
6 changes: 4 additions & 2 deletions packages/avatars/src/elements/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Text } from './components/Text';
const AvatarComponent = forwardRef<HTMLElement, IAvatarProps>(
(
{
'aria-hidden': ariaHidden,
backgroundColor,
badge,
children,
Expand Down Expand Up @@ -59,7 +60,7 @@ const AvatarComponent = forwardRef<HTMLElement, IAvatarProps>(
return ['status'].concat(statusMessage || []).join(': ');
}, [computedStatus, badge]);

const shouldValidate = computedStatus !== undefined;
const shouldValidate = computedStatus !== undefined && ariaHidden !== true;
const label = useText(
AvatarComponent,
{ statusLabel },
Expand All @@ -78,6 +79,7 @@ const AvatarComponent = forwardRef<HTMLElement, IAvatarProps>(
$backgroundColor={backgroundColor}
$foregroundColor={foregroundColor}
aria-atomic="true"
aria-hidden={ariaHidden}
aria-live="polite"
{...other}
>
Expand All @@ -89,7 +91,7 @@ const AvatarComponent = forwardRef<HTMLElement, IAvatarProps>(
$surfaceColor={surfaceColor}
as="figcaption"
>
<Span hidden>{label}</Span>
{ariaHidden !== true && <Span hidden>{label}</Span>}
{computedStatus === 'active' ? (
<span aria-hidden>{badge}</span>
) : (
Expand Down
8 changes: 7 additions & 1 deletion packages/modals/src/elements/Close.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ export const Close = forwardRef<HTMLButtonElement, ButtonHTMLAttributes<HTMLButt
return () => setIsCloseButtonPresent(false);
});

const ariaLabel = useText(Close, props, 'aria-label', 'Close modal');
const ariaLabel = useText(
Close,
props,
'aria-label',
'Close modal',
props['aria-describedby'] === undefined /* has tooltip */
);

return (
<StyledClose
Expand Down
8 changes: 7 additions & 1 deletion packages/modals/src/elements/Drawer/Close.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ const CloseComponent = forwardRef<HTMLButtonElement, ButtonHTMLAttributes<HTMLBu
return () => setIsCloseButtonPresent(false);
});

const ariaLabel = useText(CloseComponent, props, 'aria-label', 'Close drawer');
const ariaLabel = useText(
CloseComponent,
props,
'aria-label',
'Close drawer',
props['aria-describedby'] === undefined /* has tooltip */
);

return (
<StyledDrawerClose
Expand Down
8 changes: 7 additions & 1 deletion packages/modals/src/elements/TooltipDialog/Close.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ const CloseComponent = forwardRef<HTMLButtonElement, ButtonHTMLAttributes<HTMLBu
(props, ref) => {
const { getCloseProps } = useTooltipDialogContext();

const ariaLabel = useText(CloseComponent, props, 'aria-label', 'Close tooltip');
const ariaLabel = useText(
CloseComponent,
props,
'aria-label',
'Close tooltip',
props['aria-describedby'] === undefined /* has tooltip */
);

return (
<StyledTooltipDialogClose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const ToastSlot = ({ toasts, placement, zIndex, limit, ...props }: IToast
>
<StyledFadeInTransition
ref={transitionRef}
placement={placement}
$placement={placement}
$isHidden={isHidden(index)}
>
<Toast toast={toast} pauseTimers={pauseTimers || isHidden(index)} />
Expand Down
8 changes: 4 additions & 4 deletions packages/notifications/src/elements/toaster/styled.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const TRANSITION_CLASS = 'garden-toast-transition';

const DEFAULT_DURATION = '400ms';

export const StyledFadeInTransition = styled.div<{ $isHidden: boolean; placement: Placement }>`
export const StyledFadeInTransition = styled.div<{ $isHidden: boolean; $placement: Placement }>`
transition: opacity ${DEFAULT_DURATION} ease-in 300ms;
opacity: ${p => (p.$isHidden ? '0 !important' : 1)};
margin-bottom: ${p => p.theme.space.base * 2}px;
Expand All @@ -24,9 +24,9 @@ export const StyledFadeInTransition = styled.div<{ $isHidden: boolean; placement
transform: translateY(
${props => {
if (
props.placement === 'bottom-start' ||
props.placement === 'bottom' ||
props.placement === 'bottom-end'
props.$placement === 'bottom-start' ||
props.$placement === 'bottom' ||
props.$placement === 'bottom-end'
) {
return '100px';
}
Expand Down