1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-06-05 22:09:38 +02:00

chore: Usa solo href nel DrawerEntry

This commit is contained in:
Maicol Battistini
2023-06-01 17:28:13 +02:00
parent 84f348e3f7
commit 201f59bd55

View File

@@ -14,22 +14,21 @@ import {ValueOf} from 'type-fest';
type Icons = ValueOf<typeof MaterialIcons>; type Icons = ValueOf<typeof MaterialIcons>;
export interface DrawerEntryAttributes extends Attributes { export interface DrawerEntryAttributes extends Attributes, ListItemLink {
route: string;
icon: Icons; icon: Icons;
} }
export class DrawerEntry<A extends DrawerEntryAttributes = DrawerEntryAttributes> extends Component<A> { export class DrawerEntry<A extends DrawerEntryAttributes = DrawerEntryAttributes> extends Component<A> {
view(vnode: Vnode<A>) { view(vnode: Vnode<A>) {
return ( return (
<md-list-item-link headline={vnode.children as string} active={this.isRouteActive(vnode.attrs.route)} href={route(vnode.attrs.route)} onclick={this.navigateToRoute.bind(this)}> <md-list-item-link headline={vnode.children as string} active={this.isRouteActive(vnode.attrs.href)} href={vnode.attrs.href} onclick={this.navigateToRoute.bind(this)} {...this.attrs.all()}>
<MdIcon icon={vnode.attrs.icon} slot="start"/> <MdIcon icon={vnode.attrs.icon} slot="start"/>
</md-list-item-link> </md-list-item-link>
); );
} }
isRouteActive(routeName: string) { isRouteActive(href: string) {
return route().current(routeName); return route(route().current()!) === href;
} }
navigateToRoute(event: Event) { navigateToRoute(event: Event) {