Skip to content
Open
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
4 changes: 4 additions & 0 deletions docs/components/buttons-menus/content-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ The content action bar groups primary and secondary actions and adjusts to the a
- If the primary requirement is simply to have a menu that remains consistently collapsed,
use a tertiary [circle button](../buttons-menus/buttons.md) with a [menu](../buttons-menus/menu.md).

### Best practices

- Since tooltips are temporary, easy to miss and generally not accessible on touch devices, avoid using them or use them for non-essential information only.

## Design ---

### Elements
Expand Down
1 change: 1 addition & 0 deletions docs/components/buttons-menus/menu.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ They are one of the most effective and highly used command surfaces, and can be
- Keep disabled actions visible.
- Do not use more than 2 submenus in a nested way.
- Do not have a long and flat list of actions, which might not have space on a small screen.
- Since tooltips are temporary, easy to miss and generally not accessible on touch devices, avoid using them or use them for non-essential information only.

## Design ---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
si-menu-item
[attr.data-id]="primaryAction.id"
[attr.aria-label]="primaryAction.label | translate"
[siTooltip]="primaryAction.iconOnly ? (primaryAction.label | translate) : ''"
[siTooltip]="primaryAction.iconOnly ? (primaryAction.label | translate) : (primaryAction.tooltip ?? '' | translate)"
[badge]="primaryAction.badge"
[badgeColor]="primaryAction.badgeColor ?? 'secondary'"
[disabled]="primaryAction.disabled || disabled()"
Expand All @@ -45,7 +45,7 @@
si-menu-item-checkbox
[attr.data-id]="primaryAction.id"
[attr.aria-label]="primaryAction.label | translate"
[siTooltip]="primaryAction.iconOnly ? (primaryAction.label | translate) : ''"
[siTooltip]="primaryAction.iconOnly ? (primaryAction.label | translate) : (primaryAction.tooltip ?? '' | translate)"
[checked]="primaryAction.checked"
[badge]="primaryAction.badge"
[badgeColor]="primaryAction.badgeColor ?? 'secondary'"
Expand All @@ -66,7 +66,7 @@
si-menu-item
[attr.data-id]="primaryAction.id"
[attr.aria-label]="primaryAction.label | translate"
[siTooltip]="primaryAction.iconOnly ? (primaryAction.label | translate) : ''"
[siTooltip]="primaryAction.iconOnly ? (primaryAction.label | translate) : (primaryAction.tooltip ?? '' | translate)"
[badge]="primaryAction.badge"
[badgeColor]="primaryAction.badgeColor ?? 'secondary'"
[disabled]="primaryAction.disabled || disabled()"
Expand All @@ -88,7 +88,7 @@
si-menu-item
[attr.data-id]="primaryAction.id"
[attr.aria-label]="primaryAction.label | translate"
[siTooltip]="primaryAction.iconOnly ? (primaryAction.label | translate) : ''"
[siTooltip]="primaryAction.iconOnly ? (primaryAction.label | translate) : (primaryAction.tooltip ?? '' | translate)"
[badge]="primaryAction.badge"
[badgeColor]="primaryAction.badgeColor ?? 'secondary'"
[disabled]="primaryAction.disabled || disabled()"
Expand All @@ -114,7 +114,7 @@
si-menu-item
[attr.data-id]="primaryAction.id"
[attr.aria-label]="primaryAction.label | translate"
[siTooltip]="primaryAction.iconOnly ? (primaryAction.label | translate) : ''"
[siTooltip]="primaryAction.iconOnly ? (primaryAction.label | translate) : (primaryAction.tooltip ?? '' | translate)"
[badge]="primaryAction.badge"
[badgeColor]="primaryAction.badgeColor ?? 'secondary'"
[disabled]="primaryAction.disabled || disabled()"
Expand Down
2 changes: 2 additions & 0 deletions projects/element-ng/menu/si-menu-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export interface MenuItemBase {
badgeColor?: string;
/** Whether the menu item id disabled. */
disabled?: boolean;
/** Tooltip that is shown when the user hovers over the menu item. */
tooltip?: TranslatableString;
}

export interface MenuItemGroup extends MenuItemBase {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
[expanded]="
(item.id ? uiStateExpandedItems()[item.id] : undefined) ?? item.expanded ?? false
"
[siTooltip]="item.label | translate"
[isDisabled]="!collapsed()"
[siTooltip]="(collapsed() ? item.label : (item.tooltip ?? '')) | translate"
[isDisabled]="!collapsed() && !item.tooltip"
>
{{ item.label | translate }}
</button>
Expand All @@ -99,8 +99,8 @@
placement="end"
[si-navbar-vertical-item]="item"
[activeOverride]="item.active"
[siTooltip]="item.label | translate"
[isDisabled]="!collapsed()"
[siTooltip]="(collapsed() ? item.label : (item.tooltip ?? '')) | translate"
[isDisabled]="!collapsed() && !item.tooltip"
>
{{ item.label | translate }}
</button>
Expand All @@ -120,8 +120,8 @@
[preserveFragment]="item.extras?.preserveFragment"
[skipLocationChange]="item.extras?.skipLocationChange"
[replaceUrl]="item.extras?.replaceUrl"
[siTooltip]="item.label | translate"
[isDisabled]="!collapsed()"
[siTooltip]="(collapsed() ? item.label : (item.tooltip ?? '')) | translate"
[isDisabled]="!collapsed() && !item.tooltip"
>
{{ item.label | translate }}
</a>
Expand All @@ -132,8 +132,8 @@
[si-navbar-vertical-item]="item"
[href]="item.href"
[target]="item.target"
[siTooltip]="item.label | translate"
[isDisabled]="!collapsed()"
[siTooltip]="(collapsed() ? item.label : (item.tooltip ?? '')) | translate"
[isDisabled]="!collapsed() && !item.tooltip"
>
{{ item.label | translate }}
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export interface NavbarVerticalItemBase {
* By default, badges are always visible (both expanded and collapsed).
*/
hideBadgeWhenCollapsed?: boolean;
/** Tooltip that is shown when the user hovers over the menu item. */
tooltip?: TranslatableString;
}

/** Use this type to create a group that can hold multiple items. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export class SampleComponent {
{ type: 'action', label: 'Previous action 3', action: () => alert('Undo action 3') }
]
},
{ type: 'action', label: 'Undo', icon: 'element-undo', action: () => alert('Undo') },
{ type: 'action', label: 'Redo', icon: 'element-redo', action: () => alert('Redo') }
{ type: 'action', label: 'Undo', icon: 'element-undo', tooltip: 'Undo last change', action: () => alert('Undo') },
{ type: 'action', label: 'Redo', icon: 'element-redo', tooltip: 'Redo last change', action: () => alert('Redo') }
];

primaryActionsIcons: ContentActionBarMainItem[] = [
Expand Down
3 changes: 2 additions & 1 deletion src/app/examples/si-navbar-vertical/si-navbar-vertical.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export class SampleComponent implements OnInit {
label: 'Home',
id: 'home',
icon: 'element-home',
routerLink: 'home'
routerLink: 'home',
tooltip: 'Go to home page'
},
{ type: 'header', label: 'Modules' },
{
Expand Down