diff --git a/ui/src/components/CompanyRail.tsx b/ui/src/components/CompanyRail.tsx index b5e7ea2a..4509561c 100644 --- a/ui/src/components/CompanyRail.tsx +++ b/ui/src/components/CompanyRail.tsx @@ -24,30 +24,10 @@ import { TooltipTrigger, } from "@/components/ui/tooltip"; import type { Company } from "@paperclip/shared"; - -const COMPANY_COLORS = [ - "#6366f1", // indigo - "#8b5cf6", // violet - "#ec4899", // pink - "#f43f5e", // rose - "#f97316", // orange - "#eab308", // yellow - "#22c55e", // green - "#14b8a6", // teal - "#06b6d4", // cyan - "#3b82f6", // blue -]; +import { CompanyPatternIcon } from "./CompanyPatternIcon"; const ORDER_STORAGE_KEY = "paperclip.companyOrder"; -function companyColor(name: string): string { - let hash = 0; - for (let i = 0; i < name.length; i++) { - hash = name.charCodeAt(i) + ((hash << 5) - hash); - } - return COMPANY_COLORS[Math.abs(hash) % COMPANY_COLORS.length]!; -} - function getStoredOrder(): string[] { try { const raw = localStorage.getItem(ORDER_STORAGE_KEY); @@ -107,15 +87,16 @@ function SortableCompanyItem({ opacity: isDragging ? 0.8 : 1, }; - const color = companyColor(company.name); - const initial = company.name.charAt(0).toUpperCase(); - return (
- +

{company.name}

diff --git a/ui/src/context/CompanyContext.tsx b/ui/src/context/CompanyContext.tsx index f4ad4758..00a45d98 100644 --- a/ui/src/context/CompanyContext.tsx +++ b/ui/src/context/CompanyContext.tsx @@ -35,7 +35,22 @@ const CompanyContext = createContext(null); export function CompanyProvider({ children }: { children: ReactNode }) { const queryClient = useQueryClient(); const [selectedCompanyId, setSelectedCompanyIdState] = useState( - () => localStorage.getItem(STORAGE_KEY) + () => { + // Check URL param first (supports "open in new tab" from company rail) + const urlParams = new URLSearchParams(window.location.search); + const companyParam = urlParams.get("company"); + if (companyParam) { + localStorage.setItem(STORAGE_KEY, companyParam); + // Clean up the URL param + urlParams.delete("company"); + const newSearch = urlParams.toString(); + const newUrl = + window.location.pathname + (newSearch ? `?${newSearch}` : ""); + window.history.replaceState({}, "", newUrl); + return companyParam; + } + return localStorage.getItem(STORAGE_KEY); + } ); const { data: companies = [], isLoading, error } = useQuery({