plebdevs/src/components/menutab/CommunityMenuTab.js

68 lines
2.4 KiB
JavaScript
Raw Normal View History

import React, { useState, useEffect } from 'react';
2024-09-02 12:09:27 -05:00
import { TabMenu } from 'primereact/tabmenu';
2024-09-10 15:44:08 -05:00
import GenericButton from '@/components/buttons/GenericButton';
2024-09-02 12:09:27 -05:00
import Image from 'next/image';
import StackerNewsIcon from '../../../public/images/sn.svg';
import NostrIcon from '../../../public/images/nostr.png';
2024-09-02 12:09:27 -05:00
const CommunityMenuTab = ({ selectedTopic, onTabChange }) => {
const allItems = ['global', 'nostr', 'discord', 'stackernews'];
const menuItems = allItems.map((item, index) => {
let icon;
switch (item) {
case 'global':
icon = 'pi pi-globe';
break;
case 'nostr':
icon = (<div className='mr-4 flex items-center'>
<Image src={NostrIcon} alt="Nostr" width={18} height={18} className='absolute left-3' />
</div>);
break;
case 'discord':
icon = 'pi pi-discord';
break;
case 'stackernews':
icon = (<div className='mr-5 flex items-center'>
<Image src={StackerNewsIcon} alt="StackerNews" width={20} height={20} className='absolute left-3' />
</div>);
break;
}
return {
label: (
2024-09-10 15:44:08 -05:00
<GenericButton
2024-09-02 12:09:27 -05:00
className={`${selectedTopic === item ? 'bg-primary text-white' : ''}`}
onClick={() => onTabChange(item)}
outlined={selectedTopic !== item}
rounded
2024-09-10 15:44:08 -05:00
size="small"
2024-09-02 12:09:27 -05:00
label={item}
icon={icon}
/>
),
command: () => onTabChange(item)
};
});
return (
<div className="w-full">
<TabMenu
model={menuItems}
activeIndex={allItems.indexOf(selectedTopic)}
onTabChange={(e) => onTabChange(allItems[e.index])}
pt={{
2024-09-16 16:10:28 -05:00
menu: { className: 'bg-transparent border-none ml-2 my-4 py-1' },
2024-09-02 12:09:27 -05:00
action: ({ context, parent }) => ({
className: 'cursor-pointer select-none flex items-center relative no-underline overflow-hidden border-b-2 p-2 font-bold rounded-t-lg',
style: { top: '2px' }
}),
menuitem: { className: 'mr-0' }
}}
/>
</div>
);
}
export default CommunityMenuTab;