1+ import { HidUsageLabel } from "./HidUsageLabel" ;
2+
3+ export interface KeyBinding {
4+ param1 : number ;
5+ param2 : number ;
6+ }
7+
8+ const renderIndicator = ( numbers : 0 | 1 | 2 | 3 = 1 ) : JSX . Element => (
9+ < div className = "absolute ml-0.5 h-full flex flex-col justify-evenly py-1" >
10+ { Array . from ( { length : Math . max ( 1 , numbers ) } , ( _ , i ) => (
11+ < div
12+ key = { i }
13+ className = "bg-gray-900 opacity-80 rounded-full"
14+ style = { {
15+ width : '.2rem' ,
16+ height : numbers === 0 ? '0.8rem' : '.2rem' ,
17+ } }
18+ />
19+ ) ) }
20+ </ div >
21+ ) ;
22+
23+ export const getBindingChildren = (
24+ header : string ,
25+ binding : KeyBinding ,
26+ ) : JSX . Element | JSX . Element [ ] => {
27+ if ( header === "Layer-Tap" ) {
28+ return [
29+ < div className = "relative text-sm" >
30+ { renderIndicator ( 1 ) }
31+ < HidUsageLabel hid_usage = { binding . param2 } />
32+ </ div > ,
33+ < div className = "text-xs truncate relative" >
34+ { renderIndicator ( 0 ) }
35+ < svg className = "inline-block mb-0.5 mr-1" xmlns = "http://www.w3.org/2000/svg" width = "12" height = "12" fill = "currentColor" viewBox = "0 0 16 16" >
36+ < path d = "M8.235 1.559a.5.5 0 0 0-.47 0l-7.5 4a.5.5 0 0 0 0 .882L3.188 8 .264 9.559a.5.5 0 0 0 0 .882l7.5 4a.5.5 0 0 0 .47 0l7.5-4a.5.5 0 0 0 0-.882L12.813 8l2.922-1.559a.5.5 0 0 0 0-.882zm3.515 7.008L14.438 10 8 13.433 1.562 10 4.25 8.567l3.515 1.874a.5.5 0 0 0 .47 0zM8 9.433 1.562 6 8 2.567 14.438 6z" />
37+ </ svg >
38+ { binding . param1 }
39+ </ div >
40+ ] ;
41+ }
42+
43+ if ( header === "Mod-Tap" ) {
44+ return [
45+ < div className = "relative" >
46+ { renderIndicator ( 1 ) }
47+ < span className = "text-sm" >
48+ < HidUsageLabel hid_usage = { binding . param2 } />
49+ </ span >
50+ </ div > ,
51+ < div className = "text-xs relative" >
52+ { renderIndicator ( 0 ) }
53+ < HidUsageLabel hid_usage = { binding . param1 } />
54+ </ div >
55+ ] ;
56+ }
57+
58+ return (
59+ < div className = "relative" >
60+ < span className = "text-base" >
61+ < HidUsageLabel
62+ hid_usage = { binding . param1 }
63+ />
64+ </ span >
65+ </ div >
66+ ) ;
67+ } ;
0 commit comments