oneslash-design-system 1.1.17 → 1.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/menuItem.tsx +22 -21
- package/package.json +1 -1
package/components/menuItem.tsx
CHANGED
|
@@ -15,19 +15,17 @@ interface MenuItemProps {
|
|
|
15
15
|
onClick?: any;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export default function MenuItem({
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
export default function MenuItem({
|
|
19
|
+
href = '#',
|
|
20
|
+
iconName,
|
|
21
21
|
userHandle,
|
|
22
22
|
userImgUrl,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
: MenuItemProps) {
|
|
23
|
+
label,
|
|
24
|
+
isSelected,
|
|
25
|
+
onClick,
|
|
26
|
+
}: MenuItemProps) {
|
|
27
|
+
const [IconLeft, setIconLeft] = useState<IconType | null>(null);
|
|
27
28
|
|
|
28
|
-
const [IconLeft, setIconLeft] = useState<IconType | null>(null);
|
|
29
|
-
|
|
30
|
-
// Import icon dynamically
|
|
31
29
|
const loadIcon = useCallback(async (iconName?: string) => {
|
|
32
30
|
if (!iconName) return null;
|
|
33
31
|
try {
|
|
@@ -49,28 +47,31 @@ export default function MenuItem({
|
|
|
49
47
|
fetchIcon();
|
|
50
48
|
}, [iconName, loadIcon]);
|
|
51
49
|
|
|
52
|
-
|
|
53
50
|
return (
|
|
54
51
|
<NextLink href={href}>
|
|
55
|
-
<div
|
|
52
|
+
<div
|
|
56
53
|
className={`
|
|
57
54
|
flex items-center space-x-2 p-2 rounded-[8px] cursor-pointer justify-start
|
|
58
|
-
${isSelected
|
|
59
|
-
? 'bg-light-background-accent200 dark:bg-dark-background-accent200 hover:bg-light-background-accent300 dark:hover:bg-dark-background-accent300'
|
|
55
|
+
${isSelected
|
|
56
|
+
? 'bg-light-background-accent200 dark:bg-dark-background-accent200 hover:bg-light-background-accent300 dark:hover:bg-dark-background-accent300'
|
|
60
57
|
: 'hover:bg-light-background-accent100 hover:dark:bg-dark-background-accent100'}
|
|
61
58
|
`}
|
|
62
59
|
style={{ width: '100%' }}
|
|
63
60
|
onClick={onClick}
|
|
64
61
|
>
|
|
65
|
-
{/*
|
|
62
|
+
{/* Render UserImage or dynamic icon */}
|
|
66
63
|
{userImgUrl || userHandle ? (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
<UserImage userHandle={userHandle || ''} userImgUrl={userImgUrl || ''} />
|
|
65
|
+
) : (
|
|
66
|
+
IconLeft && (
|
|
67
|
+
<IconLeft
|
|
68
|
+
className="w-6 h-6 text-light-text-secondary dark:text-dark-text-secondary"
|
|
69
|
+
/>
|
|
70
|
+
)
|
|
71
|
+
)}
|
|
71
72
|
|
|
72
|
-
{/*
|
|
73
|
-
<span className="whitespace-nowrap text-body1 px-2 text-light-text-
|
|
73
|
+
{/* Label */}
|
|
74
|
+
<span className="whitespace-nowrap text-body1 px-2 text-light-text-primary dark:text-dark-text-primary">
|
|
74
75
|
{label}
|
|
75
76
|
</span>
|
|
76
77
|
</div>
|