Skip to content

Commit

Permalink
darkmode hotkey onboarding without animation
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Mar 11, 2024
1 parent addbfaf commit 4bbb5bb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
2 changes: 2 additions & 0 deletions core/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export enum NativeRoute {
hideMainWindow = 'hideMainWindow',
showMainWindow = 'showMainWindow',

getSelectedText = 'getSelectedText',

quickAskSizeUpdated = 'quickAskSizeUpdated',
setQuickAskHotKey = 'setQuickAskHotKey',
}
Expand Down
4 changes: 4 additions & 0 deletions electron/handlers/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,8 @@ export function handleAppIPCs() {
windowManager.setQuickAskHotKey(hotKey)
}
)

ipcMain.handle(NativeRoute.getSelectedText, async (_event) => {
windowManager.getSelectedText()
})
}
6 changes: 5 additions & 1 deletion electron/managers/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BrowserWindow, app, shell } from 'electron'
import { quickAskWindowConfig } from './quickAskWindowConfig'
import { AppEvent } from '@janhq/core'
import { mainWindowConfig } from './mainWindowConfig'
import { registerShortcut } from '../utils/selectedText'
import { getSelectedText, registerShortcut } from '../utils/selectedText'

/**
* Manages the current window instance.
Expand Down Expand Up @@ -131,6 +131,10 @@ class WindowManager {
}
}

getSelectedText(): void {
getSelectedText()
}

cleanUp(): void {
this.mainWindow?.destroy()
this._quickAskWindow?.destroy()
Expand Down
24 changes: 12 additions & 12 deletions web/containers/OnBoarding/Hotkey/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ const HotkeyOnBoarding = () => {
const onContinueClick = async () => {
if (checkboxState) {
setOnBoardingStep(onBoardingStep + 1)
await window.core?.api?.getSelectedText()
} else {
setModalOnboardingAccesibility(true)
}

if (isValid && keys.size > 0) {
const keyCombination = convertKeyToAccelerator(Array.from(keys)).join('+')

await window.core?.api?.setQuickAskHotKey(keyCombination)
await window.core?.api?.updateAppConfiguration({
quick_ask_hotkey: keyCombination,
Expand Down Expand Up @@ -259,17 +259,17 @@ const HotkeyOnBoarding = () => {
</div>
</div>
<div className="flex items-center justify-center">
<div className="relative -right-2 flex h-full w-full">
<object
type="image/svg+xml"
data={
resolvedTheme === 'dark'
? 'images/quick-ask-animation-dark.svg'
: 'images/quick-ask-animation.svg'
}
className="mx-auto h-full w-full"
/>
</div>
{resolvedTheme === 'light' ? (
<div className="relative -right-2 flex h-full w-full">
<object
type="image/svg+xml"
data="images/quick-ask-animation.svg"
className="mx-auto h-full w-full"
/>
</div>
) : (
<img src="images/quick-ask-dark.png" alt="Dark mode" />
)}
</div>
</div>
<ModalAccesibility />
Expand Down
Binary file added web/public/images/quick-ask-dark.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4bbb5bb

Please sign in to comment.