-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDashboard.tsx
More file actions
37 lines (33 loc) · 991 Bytes
/
Dashboard.tsx
File metadata and controls
37 lines (33 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { useState } from 'react';
import { useKbsGlobal } from '../component/index.ts';
import Playground from './Playground.tsx';
import { useCounter } from './useCounter.ts';
export default function Dashboard() {
const [counter, shortcuts] = useCounter({ maxFrequency: 2 });
const [color, setColor] = useState('white');
useKbsGlobal([
...shortcuts,
{
shortcut: { key: 'b', shift: true },
handler() {
setColor('black');
return () => setColor('white');
},
},
]);
return (
<div
className={`p-4 space-y-8 ${color === 'white' ? 'bg-white text-black' : 'bg-black text-white'}`}
>
<p>
Dashboard counter: {counter}. Press I or C to increment (max 2 per
second if held down) and D to decrement.
</p>
<p>
Press <kbd>Shift+B</kbd> to invert the background color of the page.
Release <kbd>Shift</kbd> or <kbd>B</kbd> to reset.
</p>
<Playground />
</div>
);
}