File tree Expand file tree Collapse file tree 3 files changed +81
-3
lines changed 
src/dashboardWebView/components Expand file tree Collapse file tree 3 files changed +81
-3
lines changed Original file line number Diff line number Diff line change 1+ import  {  XCircleIcon  }  from  '@heroicons/react/24/solid' ; 
2+ import  *  as  React  from  'react' ; 
3+ 
4+ export  interface  INumberFieldProps  { 
5+   name : string ; 
6+   value ?: string ; 
7+   placeholder ?: string ; 
8+   description ?: string ; 
9+   icon ?: JSX . Element ; 
10+   disabled ?: boolean ; 
11+   autoFocus ?: boolean ; 
12+   onChange ?: ( value : string )  =>  void ; 
13+   onReset ?: ( )  =>  void ; 
14+ } 
15+ 
16+ export  const  NumberField : React . FunctionComponent < INumberFieldProps >  =  ( { 
17+   name, 
18+   value, 
19+   placeholder, 
20+   description, 
21+   icon, 
22+   autoFocus, 
23+   disabled, 
24+   onChange, 
25+   onReset
26+ } : React . PropsWithChildren < INumberFieldProps > )  =>  { 
27+   return  ( 
28+     < > 
29+       < div  className = "relative flex justify-center" > 
30+         { 
31+           icon  &&  ( 
32+             < div  className = "absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none" > 
33+               { icon } 
34+             </ div > 
35+           ) 
36+         } 
37+ 
38+         < input 
39+           type = "number" 
40+           name = { name } 
41+           className = { `block w-full py-2 ${ icon  ? "pl-10"  : "pl-2" }   pr-2 sm:text-sm appearance-none disabled:opacity-50 rounded bg-[var(--vscode-input-background)] text-[var(--vscode-input-foreground)] placeholder-[var(--vscode-input-placeholderForeground)] border-[var(--frontmatter-border)] focus:border-[var(--vscode-focusBorder)] focus:outline-0` } 
42+           style = { { 
43+             boxShadow : "none" 
44+           } } 
45+           placeholder = { placeholder  ||  "" } 
46+           value = { value } 
47+           autoFocus = { ! ! autoFocus } 
48+           onChange = { ( e )  =>  onChange  &&  onChange ( e . target . value ) } 
49+           disabled = { ! ! disabled } 
50+         /> 
51+ 
52+         { ( value  &&  onReset )  &&  ( 
53+           < button  onClick = { onReset }  className = "absolute inset-y-0 right-0 pr-3 flex items-center text-[var(--vscode-input-foreground)] hover:text-[var(--vscode-textLink-activeForeground)]" > 
54+             < XCircleIcon  className = { `h-5 w-5` }  aria-hidden = "true"  /> 
55+           </ button > 
56+         ) } 
57+       </ div > 
58+ 
59+       { 
60+         description  &&  ( 
61+           < p  className = "text-xs text-[var(--vscode--settings-headerForeground)] opacity-75 mt-2 mx-2" > 
62+             { description } 
63+           </ p > 
64+         ) 
65+       } 
66+     </ > 
67+   ) ; 
68+ } ; 
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { ChevronDownIcon } from '@heroicons/react/24/outline';
33import  {  Choice ,  SnippetField ,  SnippetInfoField  }  from  '../../../models' ; 
44import  {  useEffect  }  from  'react' ; 
55import  {  TextField  }  from  '../Common/TextField' ; 
6+ import  {  NumberField  }  from  '../Common/NumberField' ; 
67
78export  interface  ISnippetInputFieldProps  { 
89  field : SnippetField ; 
@@ -78,6 +79,17 @@ export const SnippetInputField: React.FunctionComponent<ISnippetInputFieldProps>
7879    ) ; 
7980  } 
8081
82+   if  ( field . type  ===  'number' )  { 
83+     return  ( 
84+       < NumberField 
85+         name = { field . name } 
86+         value = { field . value  as  string  ||  '' } 
87+         description = { field . description } 
88+         onChange = { ( e )  =>  onValueChange ( field ,  e ) } 
89+       /> 
90+     ) ; 
91+   } 
92+ 
8193  return  ( 
8294    < TextField 
8395      name = { field . name } 
Original file line number Diff line number Diff line change @@ -21,9 +21,7 @@ import { DEFAULT_DASHBOARD_FEATURE_FLAGS } from '../../../constants/DefaultFeatu
2121
2222export  interface  ISnippetsProps  {  } 
2323
24- export  const  Snippets : React . FunctionComponent < ISnippetsProps >  =  ( 
25-   _ : React . PropsWithChildren < ISnippetsProps > 
26- )  =>  { 
24+ export  const  Snippets : React . FunctionComponent < ISnippetsProps >  =  ( )  =>  { 
2725  const  settings  =  useRecoilValue ( SettingsSelector ) ; 
2826  const  viewData  =  useRecoilValue ( ViewDataSelector ) ; 
2927  const  mode  =  useRecoilValue ( ModeAtom ) ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments