Skip to content
Draft
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
40 changes: 40 additions & 0 deletions src/card/card.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,46 @@ export const ArticleRole = () => (
</div>
);

export const CardWithAccessibleFloatingHref = () => (
<div style={{ display: 'flex', flexDirection: 'row', gap: '1rem' }}>
<Card
atomic={false}
href={GOOGLE_URL}
hrefExternal
style={{ width: 'auto' }}
floatingAnchorProps={
{
'aria-hidden': false,
'aria-label': "Google.com",
'tabIndex': 0,
}
}
>
<Section padding={false} name="Google.com (accessible floating href)" />
<Paragraph style={{ display: 'flex', gap: '1rem', flexWrap: 'wrap' }}>
<Button
onClick={(event) => {
event.stopPropagation();
alert('Dismiss clicked');
}}
buttonType={BUTTON_TYPES.secondary}
>
Dismiss
</Button>
<Button
onClick={(event) => {
event.stopPropagation();
alert('Quack clicked');
}}
buttonType={BUTTON_TYPES.secondary}
>
Quack
</Button>
</Paragraph>
</Card>
</div>
);

const nonAtomicActionsStyle = {
display: 'flex',
gap: '1rem',
Expand Down
3 changes: 3 additions & 0 deletions src/card/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
highlighted?: boolean;
theme?: any;
anchorComponent?: React.ComponentType;
floatingAnchorProps?: React.HTMLAttributes<HTMLAnchorElement | HTMLDivElement>;
}

const Card = React.forwardRef<HTMLElement, CardProps>((props, ref) => {
Expand All @@ -43,6 +44,7 @@ const Card = React.forwardRef<HTMLElement, CardProps>((props, ref) => {
highlighted,
theme,
anchorComponent,
floatingAnchorProps,
...rest
} = props;

Expand All @@ -67,6 +69,7 @@ const Card = React.forwardRef<HTMLElement, CardProps>((props, ref) => {
tabIndex={-1}
aria-hidden="true"
{...targettingProps}
{...floatingAnchorProps}
/>
)}
<BackgroundImageContainer
Expand Down
Loading