mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
feat: command palette (#140)
* wip * feat: new command palette * chore: add universal search * chore: cleanup * feat: use title class for heading * feat: add topic * chore: advance search
This commit is contained in:
67
web/components/custom/command-palette/command-data.ts
Normal file
67
web/components/custom/command-palette/command-data.ts
Normal file
@@ -0,0 +1,67 @@
|
||||
import { icons } from "lucide-react"
|
||||
import { useCommandActions } from "./hooks/use-command-actions"
|
||||
import { LaAccount } from "@/lib/schema"
|
||||
|
||||
export type CommandAction = string | (() => void)
|
||||
|
||||
export type CommandItemType = {
|
||||
icon?: keyof typeof icons
|
||||
label: string
|
||||
action: CommandAction
|
||||
payload?: any
|
||||
shortcut?: string
|
||||
}
|
||||
|
||||
export type CommandGroupType = {
|
||||
heading?: string
|
||||
items: CommandItemType[]
|
||||
}[]
|
||||
|
||||
export const createCommandGroups = (
|
||||
actions: ReturnType<typeof useCommandActions>,
|
||||
me: LaAccount
|
||||
): Record<string, CommandGroupType> => ({
|
||||
home: [
|
||||
{
|
||||
heading: "General",
|
||||
items: [
|
||||
{ icon: "SunMoon", label: "Change Theme...", action: "CHANGE_PAGE", payload: "changeTheme" },
|
||||
{
|
||||
icon: "Copy",
|
||||
label: "Copy Current URL",
|
||||
action: actions.copyCurrentURL
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
heading: "Personal Links",
|
||||
items: [
|
||||
{ icon: "TextSearch", label: "Search Links...", action: "CHANGE_PAGE", payload: "searchLinks" },
|
||||
{ icon: "Plus", label: "Create New Link...", action: () => actions.navigateTo("/") }
|
||||
]
|
||||
},
|
||||
{
|
||||
heading: "Personal Pages",
|
||||
items: [
|
||||
{ icon: "FileSearch", label: "Search Pages...", action: "CHANGE_PAGE", payload: "searchPages" },
|
||||
{
|
||||
icon: "Plus",
|
||||
label: "Create New Page...",
|
||||
action: () => actions.createNewPage(me)
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
searchLinks: [],
|
||||
searchPages: [],
|
||||
topics: [],
|
||||
changeTheme: [
|
||||
{
|
||||
items: [
|
||||
{ icon: "Moon", label: "Change Theme to Dark", action: () => actions.changeTheme("dark") },
|
||||
{ icon: "Sun", label: "Change Theme to Light", action: () => actions.changeTheme("light") },
|
||||
{ icon: "Monitor", label: "Change Theme to System", action: () => actions.changeTheme("system") }
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
Reference in New Issue
Block a user