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:
@@ -11,11 +11,11 @@ export function DeepLinkProvider({ children }: DeepLinkProviderProps) {
|
||||
const eventHandlers: { [key: string]: (event: Event) => void } = {
|
||||
click: (event: Event) => {
|
||||
const e = event as MouseEvent
|
||||
console.log("Click event:", { x: e.clientX, y: e.clientY })
|
||||
// console.log("Click event:", { x: e.clientX, y: e.clientY })
|
||||
},
|
||||
keydown: (event: Event) => {
|
||||
const e = event as KeyboardEvent
|
||||
console.log("Keydown event:", { key: e.key, code: e.code })
|
||||
// console.log("Keydown event:", { key: e.key, code: e.code })
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,22 @@ export const randomId = () => {
|
||||
return Math.random().toString(36).substring(7)
|
||||
}
|
||||
|
||||
export const toTitleCase = (str: string): string => {
|
||||
return str
|
||||
.replace(/([A-Z])/g, " $1")
|
||||
.replace(/^./, str => str.toUpperCase())
|
||||
.trim()
|
||||
}
|
||||
|
||||
function escapeRegExp(string: string) {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
|
||||
}
|
||||
|
||||
export const searchSafeRegExp = (inputValue: string) => {
|
||||
const escapedChars = inputValue.split("").map(escapeRegExp)
|
||||
return new RegExp(escapedChars.join(".*"), "i")
|
||||
}
|
||||
|
||||
export * from "./urls"
|
||||
export * from "./slug"
|
||||
export * from "./keyboard"
|
||||
|
||||
Reference in New Issue
Block a user