mirror of
https://github.com/bitwarden/browser
synced 2026-03-01 19:11:22 +00:00
* Migrate CL/Navigation to use OnPush * Modernize the code * Swap to signals and class * Further tweaks * Remove this. * Replace setOpen and setClose with a public signal * fix merge issues and signal-ifying service * fix class and style bindings * fix accidental behavior change from merge conflicts * fix redundant check * fix missed ngClass * fix comment * Re-add share ng-template --------- Co-authored-by: Vicki League <vleague@bitwarden.com> Co-authored-by: Will Martin <contact@willmartian.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
82 lines
2.1 KiB
TypeScript
82 lines
2.1 KiB
TypeScript
import { Directive, output, input, model } from "@angular/core";
|
|
import { RouterLink, RouterLinkActive } from "@angular/router";
|
|
|
|
/**
|
|
* Base class for navigation components in the side navigation.
|
|
*
|
|
* `NavGroupComponent` builds upon `NavItemComponent`. This class represents the properties
|
|
* that are passed down to `NavItemComponent`.
|
|
*/
|
|
@Directive()
|
|
export abstract class NavBaseComponent {
|
|
/**
|
|
* Text to display in main content
|
|
*/
|
|
readonly text = input<string>();
|
|
|
|
/**
|
|
* `aria-label` for main content
|
|
*/
|
|
readonly ariaLabel = input<string>();
|
|
|
|
/**
|
|
* Optional icon, e.g. `"bwi-collection-shared"`
|
|
*/
|
|
readonly icon = input<string>();
|
|
|
|
/**
|
|
* If this item is used within a tree, set `variant` to `"tree"`
|
|
*/
|
|
readonly variant = input<"default" | "tree">("default");
|
|
|
|
/**
|
|
* Depth level when nested inside of a `'tree'` variant
|
|
*/
|
|
readonly treeDepth = model(0);
|
|
|
|
/**
|
|
* Optional route to be passed to internal `routerLink`. If not provided, the nav component will render as a button.
|
|
*
|
|
* See: {@link RouterLink.routerLink}
|
|
*
|
|
* ---
|
|
*
|
|
* @remarks
|
|
* We can't name this "routerLink" because Angular will mount the `RouterLink` directive.
|
|
*
|
|
* @see {@link RouterLink.routerLink}
|
|
* @see {@link https://github.com/angular/angular/issues/24482}
|
|
*/
|
|
readonly route = input<RouterLink["routerLink"]>();
|
|
|
|
/**
|
|
* Passed to internal `routerLink`
|
|
*
|
|
* @see {@link RouterLink.relativeTo}
|
|
*/
|
|
readonly relativeTo = input<RouterLink["relativeTo"]>();
|
|
|
|
/**
|
|
* Passed to internal `routerLink`
|
|
*
|
|
* @default { paths: "subset", queryParams: "ignored", fragment: "ignored", matrixParams: "ignored" }
|
|
* @see {@link RouterLinkActive.routerLinkActiveOptions}
|
|
*/
|
|
readonly routerLinkActiveOptions = input<RouterLinkActive["routerLinkActiveOptions"]>({
|
|
paths: "subset",
|
|
queryParams: "ignored",
|
|
fragment: "ignored",
|
|
matrixParams: "ignored",
|
|
});
|
|
|
|
/**
|
|
* If `true`, do not change styles when nav item is active.
|
|
*/
|
|
readonly hideActiveStyles = input(false);
|
|
|
|
/**
|
|
* Fires when main content is clicked
|
|
*/
|
|
readonly mainContentClicked = output<void>();
|
|
}
|