feat(ui-shell): add isSelected prop to HeaderNavItem

This commit is contained in:
Eric Y Liu 2021-06-26 13:31:49 -07:00
commit 00422d1ab8
4 changed files with 23 additions and 5 deletions

View file

@ -1653,11 +1653,12 @@ None.
### Props
| Prop name | Kind | Reactive | Type | Default value | Description |
| :-------- | :--------------- | :------- | :----------------------------------------- | ----------------- | --------------------------------------------- |
| ref | <code>let</code> | Yes | <code>null &#124; HTMLAnchorElement</code> | <code>null</code> | Obtain a reference to the HTML anchor element |
| href | <code>let</code> | No | <code>string</code> | -- | Specify the `href` attribute |
| text | <code>let</code> | No | <code>string</code> | -- | Specify the text |
| Prop name | Kind | Reactive | Type | Default value | Description |
| :--------- | :--------------- | :------- | :----------------------------------------- | ----------------- | --------------------------------------------- |
| ref | <code>let</code> | Yes | <code>null &#124; HTMLAnchorElement</code> | <code>null</code> | Obtain a reference to the HTML anchor element |
| href | <code>let</code> | No | <code>string</code> | -- | Specify the `href` attribute |
| text | <code>let</code> | No | <code>string</code> | -- | Specify the text |
| isSelected | <code>let</code> | No | -- | -- | Set to `true` to select the item |
### Slots

View file

@ -4078,6 +4078,14 @@
"constant": false,
"reactive": false
},
{
"name": "isSelected",
"kind": "let",
"description": "Set to `true` to select the item",
"isFunction": false,
"constant": false,
"reactive": false
},
{
"name": "ref",
"kind": "let",

View file

@ -11,6 +11,9 @@
*/
export let text = undefined;
/** Set to `true` to select the item */
export let isSelected = undefined;
/** Obtain a reference to the HTML anchor element */
export let ref = null;
</script>
@ -23,6 +26,7 @@
href="{href}"
rel="{$$restProps.target === '_blank' ? 'noopener noreferrer' : undefined}"
class:bx--header__menu-item="{true}"
aria-current="{isSelected ? 'page' : undefined}"
{...$$restProps}
on:click
on:mouseover

View file

@ -13,6 +13,11 @@ export interface HeaderNavItemProps
*/
text?: string;
/**
* Set to `true` to select the item
*/
isSelected?: undefined;
/**
* Obtain a reference to the HTML anchor element
* @default null