mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
42 lines
886 B
TypeScript
42 lines
886 B
TypeScript
import React from 'react';
|
|
import { QRcodeSteps } from '../utils/utils.js';
|
|
interface LEDProps {
|
|
size?: number;
|
|
connectionStatus?: number;
|
|
}
|
|
|
|
const green = '#31F040';
|
|
const blue = '#424AD8';
|
|
const gray = '#95a5a6';
|
|
|
|
const LED: React.FC<LEDProps> = ({
|
|
size = 8,
|
|
connectionStatus = QRcodeSteps.DISCONNECTED,
|
|
}) => {
|
|
const getColor = () => {
|
|
if (connectionStatus >= QRcodeSteps.MOBILE_CONNECTED) {
|
|
return green;
|
|
} else if (connectionStatus >= QRcodeSteps.WAITING_FOR_MOBILE) {
|
|
return blue;
|
|
} else {
|
|
return gray;
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div
|
|
style={{
|
|
width: `${size}px`,
|
|
height: `${size}px`,
|
|
borderRadius: '50%',
|
|
backgroundColor: getColor(),
|
|
boxShadow: `0 0 ${size * 1.5}px ${getColor()}`,
|
|
transition: 'all 0.3s ease',
|
|
marginBottom: '8px',
|
|
}}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default LED;
|