1
- import { Select } from '@kobalte/core'
2
- import { FaSolidCheck } from 'solid-icons/fa'
3
- import { HiSolidSelector } from 'solid-icons/hi'
4
- import { createSignal } from 'solid-js'
1
+ import { type Component , createSignal } from 'solid-js'
2
+ import Selection from '@components/Selection'
5
3
import { useAppAPIContext } from '@src/store/context/api'
6
- import './styles.css'
7
4
8
- export const FirmwareList = ( ) => {
5
+ const FirmwareList : Component = ( ) => {
9
6
const [ firmwareVersion , setFirmwareVersion ] = createSignal ( '' )
10
7
11
8
const { getFirmwareAssets, getFirmwareVersion } = useAppAPIContext ( )
@@ -21,49 +18,15 @@ export const FirmwareList = () => {
21
18
22
19
if ( getFirmwareVersion ) setFirmwareVersion ( getFirmwareVersion ( ) )
23
20
24
- const [ value , setValue ] = createSignal ( defaultValue )
25
-
26
- // TODO: call api to download firmware assets
27
- const handleSubmit = ( e : SubmitEvent ) => {
28
- e . preventDefault ( )
29
- console . log ( '[Firmware Select]: ' , value ( ) )
30
- }
31
-
32
21
return (
33
- < form onSubmit = { handleSubmit } >
34
- < Select . Root
35
- name = "board-select"
36
- value = { value ( ) }
37
- onValueChange = { setValue }
38
- defaultValue = { defaultValue }
39
- options = { boardNames }
40
- placeholder = "Select a board..."
41
- valueComponent = { ( props ) => props . item . rawValue }
42
- itemComponent = { ( props ) => (
43
- < Select . Item item = { props . item } class = "select__item" >
44
- < Select . ItemLabel > { props . item . rawValue } </ Select . ItemLabel >
45
- < Select . ItemIndicator class = "select__item-indicator" >
46
- < FaSolidCheck />
47
- </ Select . ItemIndicator >
48
- </ Select . Item >
49
- ) } >
50
- < Select . Trigger class = "select__trigger" aria-label = "ESP_Boards" >
51
- < Select . Value class = "select__value" />
52
- < Select . Icon class = "select__icon" >
53
- < HiSolidSelector />
54
- </ Select . Icon >
55
- </ Select . Trigger >
56
- < Select . Description > Firmware - { firmwareVersion ( ) } </ Select . Description >
57
- < Select . Portal >
58
- < Select . Content class = "select__content" >
59
- < Select . Listbox class = "select__listbox" />
60
- </ Select . Content >
61
- </ Select . Portal >
62
- </ Select . Root >
63
- < div >
64
- < button type = "reset" > Reset</ button >
65
- < button > Submit</ button >
66
- </ div >
67
- </ form >
22
+ < Selection
23
+ name = "firmware"
24
+ options = { boardNames }
25
+ placeholder = "Select a board"
26
+ defaultValue = { defaultValue }
27
+ description = { `Firmware version: ${ firmwareVersion ( ) } ` }
28
+ />
68
29
)
69
30
}
31
+
32
+ export default FirmwareList
0 commit comments