Skip to content

Commit 0a234c9

Browse files
committed
docs: update story
1 parent 374bc72 commit 0a234c9

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

packages/menu/demo/stories/MenuStory.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ type MenuItemProps = {
3333
isSelected?: boolean;
3434
};
3535

36-
/**
37-
* [1] For a disabled link to be valid, it must have:
38-
* - `aria-disabled="true"`
39-
* - `role="link"`, or `role="menuitem"` if within a menu
40-
* - an `undefined` `href`
41-
*
42-
* @example <a role="link" aria-disabled="true">Learn something!</a>
43-
* @see https://www.scottohara.me/blog/2021/05/28/disabled-links.html
44-
*/
4536
const Item = ({ item, getItemProps, focusedValue, isSelected }: MenuItemProps) => {
4637
const itemProps = getItemProps({ item });
4738

@@ -63,13 +54,12 @@ const Item = ({ item, getItemProps, focusedValue, isSelected }: MenuItemProps) =
6354
'cursor-pointer': !item.disabled,
6455
'cursor-default': item.disabled
6556
})}
66-
role={itemProps.href ? 'none' : undefined}
67-
{...(!itemProps.href && (itemProps as LiHTMLAttributes<HTMLLIElement>))}
57+
role={item.href ? 'none' : undefined}
58+
{...(!item.href && (itemProps as LiHTMLAttributes<HTMLLIElement>))}
6859
>
69-
{itemProps.href ? (
60+
{item.href ? (
7061
<a
7162
{...(itemProps as AnchorHTMLAttributes<HTMLAnchorElement>)}
72-
href={item.disabled ? undefined : itemProps.href}
7363
className={classNames(
7464
' w-full rounded-sm outline-offset-0 transition-none border-width-none',
7565
{
@@ -79,7 +69,7 @@ const Item = ({ item, getItemProps, focusedValue, isSelected }: MenuItemProps) =
7969
)}
8070
>
8171
{itemChildren}
82-
{!!item.isExternal && (
72+
{!!item.external && (
8373
<>
8474
<span aria-hidden="true"></span>
8575
<span className="sr-only">(opens in new window)</span>

packages/menu/demo/stories/data.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@ export const ITEMS: MenuItem[] = [
1616
value: 'plant-04',
1717
label: 'Aloe Vera',
1818
href: 'https://en.wikipedia.org/wiki/Aloe_vera',
19-
isExternal: false
19+
external: false
2020
},
21-
{ value: 'plant-05', label: 'Succulent' },
21+
{
22+
value: 'plant-05',
23+
label: 'Palm tree',
24+
href: 'https://en.wikipedia.org/wiki/Palm_tree',
25+
external: true,
26+
disabled: true
27+
},
28+
{ value: 'plant-06', label: 'Succulent' },
2229
{
2330
label: 'Choose favorites',
2431
items: [

0 commit comments

Comments
 (0)