mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 15:07:54 -04:00
* Hide notice on overview and - Removed prettier/recommended from eslint - Optimized imports * move overview check to parent * don't show recents if there is none * use useMatch
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { cva } from 'class-variance-authority';
|
|
import clsx from 'clsx';
|
|
import { PropsWithChildren } from 'react';
|
|
import { NavLink, NavLinkProps } from 'react-router-dom';
|
|
import { useOperatingSystem } from '~/hooks/useOperatingSystem';
|
|
|
|
const styles = cva(
|
|
'max-w flex grow flex-row items-center gap-0.5 truncate rounded px-2 py-1 text-sm font-medium outline-none ring-offset-sidebar focus:ring-2 focus:ring-accent focus:ring-offset-2',
|
|
{
|
|
variants: {
|
|
active: {
|
|
true: 'bg-sidebar-selected/40 text-ink',
|
|
false: 'text-ink-dull'
|
|
},
|
|
transparent: {
|
|
true: 'bg-opacity-90',
|
|
false: ''
|
|
}
|
|
}
|
|
}
|
|
);
|
|
|
|
export default ({
|
|
className,
|
|
onClick,
|
|
disabled,
|
|
...props
|
|
}: PropsWithChildren<NavLinkProps & { disabled?: boolean }>) => {
|
|
const os = useOperatingSystem();
|
|
|
|
return (
|
|
<NavLink
|
|
onClick={(e) => (disabled ? e.preventDefault() : onClick?.(e))}
|
|
className={({ isActive }) =>
|
|
clsx(
|
|
styles({ active: isActive, transparent: os === 'macOS' }),
|
|
disabled && 'pointer-events-none opacity-50',
|
|
className
|
|
)
|
|
}
|
|
{...props}
|
|
>
|
|
{props.children}
|
|
</NavLink>
|
|
);
|
|
};
|