mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 23:15:36 +00:00
feat: create new dashboard (layout, navbar, list of links)
This commit is contained in:
26
inertia/components/common/external_link_styled.tsx
Normal file
26
inertia/components/common/external_link_styled.tsx
Normal file
@@ -0,0 +1,26 @@
|
||||
import { Anchor } from '@mantine/core';
|
||||
import { AnchorHTMLAttributes, CSSProperties, ReactNode } from 'react';
|
||||
|
||||
export function ExternalLinkStyled({
|
||||
children,
|
||||
title,
|
||||
...props
|
||||
}: AnchorHTMLAttributes<HTMLAnchorElement> & {
|
||||
children: ReactNode;
|
||||
style?: CSSProperties;
|
||||
title?: string;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<Anchor<'a'>
|
||||
component="a"
|
||||
underline="never"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
title={title}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</Anchor>
|
||||
);
|
||||
}
|
||||
60
inertia/components/common/mantine_user_card.tsx
Normal file
60
inertia/components/common/mantine_user_card.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
import { Avatar, Group, Menu, Text, UnstyledButton } from '@mantine/core';
|
||||
import { forwardRef } from 'react';
|
||||
import { TbChevronRight } from 'react-icons/tb';
|
||||
import useUser from '~/hooks/use_user';
|
||||
|
||||
interface UserButtonProps extends React.ComponentPropsWithoutRef<'button'> {
|
||||
image: string;
|
||||
name: string;
|
||||
email: string;
|
||||
icon?: React.ReactNode;
|
||||
}
|
||||
|
||||
const UserButton = forwardRef<HTMLButtonElement, UserButtonProps>(
|
||||
({ image, name, email, icon, ...others }: UserButtonProps, ref) => (
|
||||
<UnstyledButton
|
||||
ref={ref}
|
||||
style={{
|
||||
color: 'var(--mantine-color-text)',
|
||||
borderRadius: 'var(--mantine-radius-sm)',
|
||||
}}
|
||||
{...others}
|
||||
>
|
||||
<Group>
|
||||
<Avatar src={image} radius="xl" />
|
||||
|
||||
<div style={{ flex: 1 }}>
|
||||
<Text size="sm" fw={500}>
|
||||
{name}
|
||||
</Text>
|
||||
|
||||
<Text c="dimmed" size="xs">
|
||||
{email}
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
{icon || <TbChevronRight size="1rem" />}
|
||||
</Group>
|
||||
</UnstyledButton>
|
||||
)
|
||||
);
|
||||
|
||||
export function MantineUserCard() {
|
||||
const { user, isAuthenticated } = useUser();
|
||||
return (
|
||||
isAuthenticated && (
|
||||
<Menu withArrow>
|
||||
<Menu.Target>
|
||||
<UserButton
|
||||
image={user.avatarUrl}
|
||||
name={user.fullname}
|
||||
email={user.email}
|
||||
/>
|
||||
</Menu.Target>
|
||||
<Menu.Dropdown>
|
||||
<Menu.Item>Logout</Menu.Item>
|
||||
</Menu.Dropdown>
|
||||
</Menu>
|
||||
)
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user