Dropdown

Popover menus. The Department list opens from the Department switcher in the sidebar.

Open in Figma

Usage

import { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuItem } from '@pilar-amoda/ui/dropdown';

Department list

DropdownMenuContent: 320 wide, align start, sideOffset 4. Each DropdownMenuItem has an icon (size 20, in a 32 × 32 tile), a title and a description. selected marks the current department: muted fill, white tile and a check.

'use client';

import { useState } from 'react';

import { Button } from '@pilar-amoda/ui/button';
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuGroup,
  DropdownMenuItem,
  DropdownMenuLabel,
  DropdownMenuTrigger,
} from '@pilar-amoda/ui/dropdown';
import { ChevronDownIcon, type IconName } from '@pilar-amoda/ui/icons';

const departments: readonly { name: string; icon: IconName; modules: string }[] = [
  { name: 'Sales & BD', icon: 'trend-chart', modules: 'Unifying code generator, Deals' },
  { name: 'Product', icon: 'layers', modules: 'Master data material, Vendor, Project, RAB' },
  { name: 'Operations', icon: 'clipboard', modules: 'Cash advance, RAP, Request order' },
  {
    name: 'Procurement',
    icon: 'cart',
    modules: 'Approval material, Reserve stock, Fulfillment, Payment request',
  },
  { name: 'Warehouse', icon: 'warehouse', modules: 'Inbound order, Outbound order' },
  { name: 'Finance', icon: 'wallet', modules: 'Process payment request, Pencairan cash advance' },
  { name: 'People / HR', icon: 'user', modules: 'Reimbursement, Transfer ke team member' },
];

/** Department switcher: one check, on the current department. */
export const DropdownDepartmentSwitcher = () => {
  const [current, setCurrent] = useState('Procurement');

  return (
    <DropdownMenu>
      <DropdownMenuTrigger
        data-testid="btnDropdown_Department"
        render={<Button variant="outline" />}
      >
        {current}
        <ChevronDownIcon size={12} />
      </DropdownMenuTrigger>
      <DropdownMenuContent>
        <DropdownMenuGroup>
          <DropdownMenuLabel>Pindah departemen</DropdownMenuLabel>
          {departments.map((department) => (
            <DropdownMenuItem
              key={department.name}
              data-testid={`itmDropdown_${department.icon}`}
              icon={department.icon}
              description={department.modules}
              selected={department.name === current}
              onClick={() => setCurrent(department.name)}
            >
              {department.name}
            </DropdownMenuItem>
          ))}
        </DropdownMenuGroup>
      </DropdownMenuContent>
    </DropdownMenu>
  );
};

Do and don't

Do: describe each department with the modules it contains.
Don't: show a check on more than one department.