summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOliver <oliver@mohlin.dev>2025-02-21 13:05:52 +0100
committerTobias Järvelöv <tobias.jarvelov@mullvad.net>2025-05-28 10:28:14 +0200
commite8c12071375ee7147cc2b50fa2790d0060cfa308 (patch)
tree229c91d67e7a7fe3746b650f3d4d755e628f3a13
parenta1c4b9a66280cd1d490305bad38b9de96217d4be (diff)
downloadmullvadvpn-e8c12071375ee7147cc2b50fa2790d0060cfa308.tar.xz
mullvadvpn-e8c12071375ee7147cc2b50fa2790d0060cfa308.zip
Add NavigationListItem component
-rw-r--r--desktop/packages/mullvad-vpn/src/renderer/components/NavigationListItem.tsx24
1 files changed, 24 insertions, 0 deletions
diff --git a/desktop/packages/mullvad-vpn/src/renderer/components/NavigationListItem.tsx b/desktop/packages/mullvad-vpn/src/renderer/components/NavigationListItem.tsx
new file mode 100644
index 0000000000..c03867d6a6
--- /dev/null
+++ b/desktop/packages/mullvad-vpn/src/renderer/components/NavigationListItem.tsx
@@ -0,0 +1,24 @@
+import React from 'react';
+
+import { ListItem, ListItemProps } from '../lib/components/list-item';
+import { useHistory } from '../lib/history';
+import { RoutePath } from '../lib/routes';
+
+export type NavigationListItemProps = ListItemProps & {
+ to: RoutePath;
+};
+
+export function NavigationListItem({ to, children, ...props }: NavigationListItemProps) {
+ const history = useHistory();
+ const navigate = React.useCallback(() => history.push(to), [history, to]);
+
+ return (
+ <ListItem {...props}>
+ <ListItem.Item>
+ <ListItem.Trigger onClick={navigate}>
+ <ListItem.Content>{children}</ListItem.Content>
+ </ListItem.Trigger>
+ </ListItem.Item>
+ </ListItem>
+ );
+}