-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add focusable elements, add keyboard shortcuts for query input
- Loading branch information
Showing
9 changed files
with
190 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
import { defineAction } from 'solid-command-palette'; | ||
import { useAppSelector } from "services/Context"; | ||
import { ActionContext, defineAction } from "solid-command-palette"; | ||
|
||
const minimalAction = defineAction({ | ||
id: 'minimal', | ||
title: 'Minimal Action', | ||
run: () => { | ||
console.log('ran minimal action'); | ||
}, | ||
}); | ||
|
||
const incrementCounterAction = defineAction({ | ||
id: 'increment-counter', | ||
title: 'Increment Counter by 1', | ||
subtitle: 'Press CMD + E to trigger this.', | ||
shortcut: '$mod+e', // $mod = Command on Mac & Control on Windows. | ||
const showThemeSwitcher = defineAction({ | ||
id: "toggle-theme-switcher", | ||
title: "Toggle Theme Switcher", | ||
run: ({ rootContext }) => { | ||
rootContext.increment(); | ||
(rootContext as any).showThemeSwitcher(); | ||
}, | ||
}); | ||
|
||
// const incrementCounterAction = defineAction({ | ||
// id: "increment-counter", | ||
// title: "Increment Counter by 1", | ||
// subtitle: "Press CMD + E to trigger this.", | ||
// shortcut: "$mod+e", // $mod = Command on Mac & Control on Windows. | ||
// run: ({ rootContext }) => { | ||
// (rootContext as ActionsContext).increment(); | ||
// }, | ||
// }); | ||
|
||
export const actions = { | ||
[minimalAction.id]: minimalAction, | ||
[incrementCounterAction.id]: incrementCounterAction, | ||
[showThemeSwitcher.id]: showThemeSwitcher, | ||
// [incrementCounterAction.id]: incrementCounterAction, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,54 @@ | ||
import { For } from "solid-js" | ||
import { titleCase } from "../../utils/formatters" | ||
const THEMES = ["light", "dark", "aqua", "synthwave", "dracula", "night", "cupcake"] as const; | ||
import { onMount } from 'solid-js' | ||
import { For, Show } from "solid-js"; | ||
import { titleCase } from "../../utils/formatters"; | ||
const THEMES = [ | ||
"light", | ||
"dark", | ||
"aqua", | ||
"synthwave", | ||
"dracula", | ||
"night", | ||
"cupcake", | ||
] as const; | ||
import { onMount } from "solid-js"; | ||
import { t } from "i18next"; | ||
import { useAppSelector } from "services/Context"; | ||
|
||
export const ThemeSwitch = () => { | ||
const { | ||
appService: { appStore }, | ||
} = useAppSelector(); | ||
onMount(async () => { | ||
const theme = localStorage.getItem("theme") || "dark" | ||
document.documentElement.dataset.theme = theme | ||
}) | ||
const theme = localStorage.getItem("theme") || "dark"; | ||
document.documentElement.dataset.theme = theme; | ||
}); | ||
|
||
const select = (theme: typeof THEMES[number]) => { | ||
document.documentElement.dataset.theme = theme | ||
localStorage.setItem("theme", theme) | ||
} | ||
const select = (theme: (typeof THEMES)[number]) => { | ||
document.documentElement.dataset.theme = theme; | ||
localStorage.setItem("theme", theme); | ||
}; | ||
|
||
return ( | ||
<div class="dropdown dropdown-left"> | ||
<label tabindex="0" class="m-1 btn btn-xs">{t('components.theme_switch.theme')}</label> | ||
<ul tabindex="0" class="p-2 shadow menu dropdown-content z-[1] bg-base-100 rounded-box w-52"> | ||
<For each={THEMES}> | ||
{(theme) => <li class="py-1"><a onClick={() => select(theme)}>{titleCase(theme)}</a></li>} | ||
</For> | ||
</ul> | ||
</div> | ||
) | ||
} | ||
<Show when={appStore.showThemeSwitcher}> | ||
<div class="dropdown dropdown-left"> | ||
<label id="theme-switch" tabindex="0" class="m-1 btn btn-xs"> | ||
{t("components.theme_switch.theme")} | ||
</label> | ||
<ul | ||
tabindex={0} | ||
class="p-2 shadow menu dropdown-content z-[1] | ||
bg-base-100 rounded-box w-52" | ||
> | ||
<For each={THEMES}> | ||
{(theme) => ( | ||
<li class="py-1"> | ||
<button onClick={() => select(theme)}> | ||
{titleCase(theme)} | ||
</button> | ||
</li> | ||
)} | ||
</For> | ||
</ul> | ||
</div> | ||
</Show> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.