make kbar theme aware, improve note actions
This commit is contained in:
parent
a890cfab96
commit
3b6cf4f3b7
1 changed files with 11 additions and 7 deletions
|
@ -18,8 +18,7 @@ const searchStyle = {
|
||||||
fontSize: "16px",
|
fontSize: "16px",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
boxSizing: "border-box",
|
boxSizing: "border-box",
|
||||||
outline: "none",
|
outline: "none"
|
||||||
border: "none"
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const animatorStyle = {
|
const animatorStyle = {
|
||||||
|
@ -83,9 +82,9 @@ const ResultItem = React.forwardRef(
|
||||||
<div
|
<div
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
"flex justify-between items-center cursor-pointer px-4 py-3",
|
"flex justify-between items-center cursor-pointer px-4 py-3 dark:text-white",
|
||||||
{
|
{
|
||||||
"bg-emerald-50": active,
|
"bg-emerald-50 dark:bg-emerald-900": active,
|
||||||
"border-l-2 border-emerald-300": active
|
"border-l-2 border-emerald-300": active
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
@ -223,7 +222,9 @@ const staticActions = [
|
||||||
keywords: "settings edit",
|
keywords: "settings edit",
|
||||||
perform: () => (window.location.pathname = "admin/settings/edit"),
|
perform: () => (window.location.pathname = "admin/settings/edit"),
|
||||||
}
|
}
|
||||||
]
|
].map(function(a) {
|
||||||
|
return {...a, section: "Pages"}
|
||||||
|
})
|
||||||
|
|
||||||
function DynamicResultsProvider() {
|
function DynamicResultsProvider() {
|
||||||
const [actions, setActions] = useState([])
|
const [actions, setActions] = useState([])
|
||||||
|
@ -236,9 +237,12 @@ function DynamicResultsProvider() {
|
||||||
.then(json => setNotes(json.notes))
|
.then(json => setNotes(json.notes))
|
||||||
}, [rerender])
|
}, [rerender])
|
||||||
|
|
||||||
|
|
||||||
const noteActions = useMemo(() => notes.map(note => createAction({
|
const noteActions = useMemo(() => notes.map(note => createAction({
|
||||||
id: note.slug,
|
id: note.slug,
|
||||||
name: note.name,
|
name: note.name,
|
||||||
|
subtitle: note.channels.map(c => c.name).join(", "),
|
||||||
|
section: "Notes",
|
||||||
keywords: note.channels.map(c => c.name),
|
keywords: note.channels.map(c => c.name),
|
||||||
perform: () => (window.location.pathname = `/admin/notes/${note.id}`),
|
perform: () => (window.location.pathname = `/admin/notes/${note.id}`),
|
||||||
})), [notes])
|
})), [notes])
|
||||||
|
@ -252,8 +256,8 @@ export default function KBar() {
|
||||||
<DynamicResultsProvider />
|
<DynamicResultsProvider />
|
||||||
<KBarPortal>
|
<KBarPortal>
|
||||||
<KBarPositioner>
|
<KBarPositioner>
|
||||||
<KBarAnimator style={animatorStyle} className="bg-gray-50 border border-gray-100 shadow-lg">
|
<KBarAnimator style={animatorStyle} className="bg-gray-50 border border-gray-100 shadow-sm dark:bg-gray-900 dark:border-gray-800">
|
||||||
<KBarSearch style={searchStyle} className="bg-gray-200" />
|
<KBarSearch style={searchStyle} className="bg-gray-50 dark:bg-gray-900 border-b border-gray-100" />
|
||||||
<RenderResults />
|
<RenderResults />
|
||||||
</KBarAnimator>
|
</KBarAnimator>
|
||||||
</KBarPositioner>
|
</KBarPositioner>
|
||||||
|
|
Loading…
Reference in a new issue