diff options
| author | Oliver <oliver@mohlin.dev> | 2025-02-21 13:05:52 +0100 |
|---|---|---|
| committer | Tobias Järvelöv <tobias.jarvelov@mullvad.net> | 2025-05-28 10:28:14 +0200 |
| commit | e8c12071375ee7147cc2b50fa2790d0060cfa308 (patch) | |
| tree | 229c91d67e7a7fe3746b650f3d4d755e628f3a13 | |
| parent | a1c4b9a66280cd1d490305bad38b9de96217d4be (diff) | |
| download | mullvadvpn-e8c12071375ee7147cc2b50fa2790d0060cfa308.tar.xz mullvadvpn-e8c12071375ee7147cc2b50fa2790d0060cfa308.zip | |
Add NavigationListItem component
| -rw-r--r-- | desktop/packages/mullvad-vpn/src/renderer/components/NavigationListItem.tsx | 24 |
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> + ); +} |
