Fade in window contents (Layout)

This commit is contained in:
Gregory Schier
2024-05-31 09:16:52 -07:00
parent 1ce50e0c1b
commit 995cd2aa7b
47 changed files with 778 additions and 1689 deletions

View File

@@ -1,5 +1,6 @@
import { readText, writeText } from '@tauri-apps/plugin-clipboard-manager';
import { useCallback, useEffect } from 'react';
import { useToast } from '../components/ToastContext';
import { useWindowFocus } from './useWindowFocus';
import { createGlobalState } from 'react-use';
@@ -8,6 +9,7 @@ const useClipboardTextState = createGlobalState<string>('');
export function useClipboardText() {
const [value, setValue] = useClipboardTextState();
const focused = useWindowFocus();
const toast = useToast();
useEffect(() => {
readText().then(setValue);
@@ -16,9 +18,14 @@ export function useClipboardText() {
const setText = useCallback(
(text: string) => {
writeText(text).catch(console.error);
toast.show({
id: 'copied',
variant: 'copied',
message: 'Copied to clipboard',
});
setValue(text);
},
[setValue],
[setValue, toast],
);
return [value, setText] as const;