Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
thecybernanny-webapp
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
asranov0003
thecybernanny-webapp
Commits
127f1e19
Commit
127f1e19
authored
Jul 12, 2025
by
asranov0003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add cdeviceselect
parent
fc09caf6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
174 additions
and
10 deletions
+174
-10
CDeviceSelect.css
src/components/CDeviceSelect/CDeviceSelect.css
+84
-0
CDeviceSelect.tsx
src/components/CDeviceSelect/CDeviceSelect.tsx
+69
-0
CDeviceSelect.types.ts
src/components/CDeviceSelect/CDeviceSelect.types.ts
+11
-0
index.ts
src/components/CDeviceSelect/index.ts
+1
-0
Header.tsx
src/layouts/Header/Header.tsx
+9
-10
No files found.
src/components/CDeviceSelect/CDeviceSelect.css
0 → 100644
View file @
127f1e19
.cdeviceselect-container
{
width
:
100%
;
border-radius
:
10px
;
padding
:
0.75rem
1rem
;
background
:
var
(
--background-color
);
color
:
var
(
--text-color
);
border
:
1px
solid
var
(
--gray-color
);
cursor
:
pointer
;
user-select
:
none
;
position
:
relative
;
transition
:
0.3s
;
}
.cdeviceselect-disabled
{
background
:
var
(
--light-gray-color
);
cursor
:
not-allowed
;
opacity
:
0.6
;
}
.cdeviceselect-selected
{
display
:
flex
;
align-items
:
center
;
justify-content
:
space-between
;
}
.cdeviceselect-img
{
width
:
20px
;
height
:
20px
;
margin-right
:
8px
;
border-radius
:
50%
;
object-fit
:
cover
;
}
.cdeviceselect-dropdown
{
position
:
absolute
;
top
:
100%
;
left
:
0
;
right
:
0
;
background
:
var
(
--background-color
);
border-radius
:
10px
;
margin-top
:
4px
;
z-index
:
100
;
box-shadow
:
0
2px
6px
rgba
(
0
,
0
,
0
,
0.1
);
max-height
:
200px
;
overflow-y
:
auto
;
}
.cdeviceselect-option
{
padding
:
0.75rem
1rem
;
display
:
flex
;
align-items
:
center
;
cursor
:
pointer
;
transition
:
0.2s
;
}
.cdeviceselect-option
:hover
{
background
:
rgba
(
0
,
0
,
0
,
0.05
);
}
.cdeviceselect-option.selected
{
background
:
var
(
--primary-color
);
color
:
var
(
--on-text-color
);
}
.cdeviceselect-arrow
{
margin-left
:
auto
;
font-size
:
0.8rem
;
}
.cdeviceselect-img
{
width
:
20px
;
height
:
20px
;
margin-right
:
8px
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
}
.cdeviceselect-option.disabled
{
color
:
#888
;
pointer-events
:
none
;
cursor
:
default
;
}
\ No newline at end of file
src/components/CDeviceSelect/CDeviceSelect.tsx
0 → 100644
View file @
127f1e19
import
React
,
{
useEffect
,
useRef
,
useState
}
from
"react"
;
import
"./CDeviceSelect.css"
;
import
type
{
CDeviceSelectProps
}
from
"./CDeviceSelect.types"
;
import
{
FaChevronDown
,
FaChevronUp
}
from
"react-icons/fa"
;
const
CDeviceSelect
:
React
.
FC
<
CDeviceSelectProps
>
=
({
devices
,
selectedDevice
,
onDeviceChange
,
disabled
,
style
,
className
,
placeholder
=
"Select Device"
,
})
=>
{
const
[
open
,
setOpen
]
=
useState
(
false
);
const
ref
=
useRef
<
HTMLDivElement
>
(
null
);
useEffect
(()
=>
{
const
handleClickOutside
=
(
e
:
MouseEvent
)
=>
{
if
(
ref
.
current
&&
!
ref
.
current
.
contains
(
e
.
target
as
Node
))
{
setOpen
(
false
);
}
};
document
.
addEventListener
(
"mousedown"
,
handleClickOutside
);
return
()
=>
document
.
removeEventListener
(
"mousedown"
,
handleClickOutside
);
},
[]);
return
(
<>
<
div
ref=
{
ref
}
className=
{
`cdeviceselect-container ${className || ""} ${
disabled ? "cdeviceselect-disabled" : ""
}`
}
style=
{
style
}
onClick=
{
()
=>
!
disabled
&&
setOpen
(
!
open
)
}
>
<
div
className=
"cdeviceselect-selected"
>
<
span
>
{
selectedDevice
?.
name
||
placeholder
}
</
span
>
<
span
className=
"cdeviceselect-arrow"
>
{
open
?
<
FaChevronUp
/>
:
<
FaChevronDown
/>
}
</
span
>
</
div
>
{
open
&&
(
<
div
className=
"cdeviceselect-dropdown"
>
{
devices
.
map
((
device
)
=>
(
<
div
key=
{
device
.
id
}
className=
{
`cdeviceselect-option ${
device.name === selectedDevice?.name ? "selected" : ""
}`
}
onClick=
{
(
e
)
=>
{
e
.
stopPropagation
();
onDeviceChange
?.(
device
.
id
);
setOpen
(
false
);
}
}
>
<
span
>
{
device
.
name
}
</
span
>
</
div
>
))
}
</
div
>
)
}
</
div
>
</>
);
};
export
default
CDeviceSelect
;
src/components/CDeviceSelect/CDeviceSelect.types.ts
0 → 100644
View file @
127f1e19
import
type
{
IDevice
}
from
"../../types/device.types"
;
export
interface
CDeviceSelectProps
{
devices
:
IDevice
[];
selectedDevice
:
IDevice
|
null
;
onDeviceChange
:
(
deviceId
:
string
)
=>
void
;
disabled
?:
boolean
;
style
?:
React
.
CSSProperties
;
className
?:
string
;
placeholder
?:
string
;
}
src/components/CDeviceSelect/index.ts
0 → 100644
View file @
127f1e19
export
{
default
}
from
"./CDeviceSelect"
;
src/layouts/Header/Header.tsx
View file @
127f1e19
...
...
@@ -23,6 +23,7 @@ import {
fetchDevices
,
setSelectedDevice
,
}
from
"../../stores/slices/deviceSlice"
;
import
CDeviceSelect
from
"../../components/CDeviceSelect"
;
const
Header
:
React
.
FC
=
()
=>
{
const
[
isSidebarOpen
,
setIsSidebarOpen
]
=
useState
(
false
);
...
...
@@ -73,16 +74,14 @@ const Header: React.FC = () => {
</
div
>
<
div
className=
"header__devices"
>
<
select
onChange=
{
(
e
)
=>
dispatch
(
setSelectedDevice
(
e
.
target
.
value
))
}
defaultValue=
{
selectedDevice
?.
id
}
>
{
devices
.
map
((
device
)
=>
(
<
option
key=
{
device
.
id
}
value=
{
device
.
id
}
>
{
device
.
name
}
</
option
>
))
}
</
select
>
<
CDeviceSelect
devices=
{
devices
}
selectedDevice=
{
selectedDevice
}
onDeviceChange=
{
(
name
)
=>
dispatch
(
setSelectedDevice
(
name
))
}
disabled=
{
!
devices
.
length
}
style=
{
{
width
:
"220px"
}
}
className=
"header__device-select"
/>
</
div
>
</
div
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment