-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial commit * selected device refact
- Loading branch information
1 parent
0968cdd
commit be6b93d
Showing
29 changed files
with
762 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
interface PairingLightProps { | ||
radius?: string; | ||
color: string; | ||
speed?: 'slow' | 'normal' | 'fast'; | ||
} | ||
|
||
const PairingLight = (props: PairingLightProps) => { | ||
const { speed = 'normal', color, radius } = props; | ||
const [isBloomed, setIsBloomed] = useState(false); | ||
const getSpeed = (speed: 'fast' | 'normal' | 'slow') => { | ||
switch (speed) { | ||
case 'fast': | ||
return 0.5; | ||
case 'slow': | ||
return 1.5; | ||
default: | ||
return 1; | ||
} | ||
}; | ||
const speedInSeconds = getSpeed(speed); | ||
|
||
useEffect(() => { | ||
const interval = setInterval(() => { | ||
setIsBloomed(prevState => !prevState); | ||
}, speedInSeconds * 1000); | ||
return () => clearInterval(interval); | ||
}, [speedInSeconds]); | ||
|
||
const animationStyle: React.CSSProperties = { | ||
width: radius ? radius : '100px', | ||
height: radius ? radius : '100px', | ||
borderRadius: '50%', | ||
backgroundColor: color, | ||
boxShadow: isBloomed ? `0 0 50px 10px ${color}` : 'none', | ||
transition: `box-shadow ${speedInSeconds}s ease-in-out`, | ||
animation: 'blink 1s step-end infinite', | ||
}; | ||
|
||
const buildCircle = (x: string, y: string) => { | ||
return ( | ||
<div | ||
style={{ | ||
...animationStyle, | ||
position: 'absolute', | ||
left: x, | ||
top: y, | ||
transform: 'translate(-50%, -50%)', | ||
}} | ||
></div> | ||
); | ||
}; | ||
|
||
return ( | ||
<div | ||
style={{ | ||
position: 'relative', | ||
width: '50px', | ||
height: '50px', | ||
}} | ||
> | ||
{buildCircle('60%', '50%')} | ||
{buildCircle('40%', '50%')} | ||
{buildCircle('50%', '60%')} | ||
{buildCircle('50%', '40%')} | ||
</div> | ||
); | ||
}; | ||
|
||
export default PairingLight; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import ParallaxComponent from './ParallaxComponent'; | ||
import Pax3DeviceSvg from './Svg/Pax3DeviceSvg'; | ||
import './shakingAnimation.css'; | ||
|
||
interface Props { | ||
parallax?: boolean; | ||
serial?: { serial?: string; device: string }; | ||
} | ||
|
||
const PaxAddSerial = (props: Props) => { | ||
const svgFillColor = '#666666'; | ||
|
||
const renderWithParallax = ( | ||
multiplier: number, | ||
children: React.ReactNode, | ||
parallax?: boolean, | ||
) => { | ||
if (!parallax) { | ||
return children; | ||
} | ||
|
||
return ( | ||
<ParallaxComponent multiplier={multiplier}>{children}</ParallaxComponent> | ||
); | ||
}; | ||
|
||
return renderWithParallax( | ||
7, | ||
<div className="relative flex h-72 items-center justify-center"> | ||
<div className="absolute top-14"></div> | ||
<Pax3DeviceSvg fillColor={svgFillColor} showShadow /> | ||
<div className="absolute bottom-20"> | ||
<h1 className="text-md text-center font-bold opacity-60"> | ||
{props.serial?.device} | ||
</h1> | ||
</div> | ||
<div className="absolute bottom-16"> | ||
<h1 className="text-center text-[0.6rem]">{props.serial?.serial}</h1> | ||
</div> | ||
</div>, | ||
props.parallax, | ||
); | ||
}; | ||
|
||
export default PaxAddSerial; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default } from './PaxPairing'; | ||
export * from './PaxAddSerial'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@keyframes shake { | ||
0%, 100% { transform: rotate(0deg); } | ||
20%, 80% { transform: rotate(-10deg); } | ||
40%, 60% { transform: rotate(10deg); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default as PaxPairing } from './PaxPairingSvg'; | ||
export { default as PaxAddSerial } from './PaxPairingSvg/PaxAddSerial'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,38 @@ | ||
import { useIsMobile } from '@/hooks'; | ||
import { Pax } from '@/pax'; | ||
import { Terminal } from 'lucide-react'; | ||
import { useState } from 'react'; | ||
|
||
import AddDeviceFooter from '../AddDeviceFooter'; | ||
import { PaxPairing } from '../Graphics'; | ||
import { SUPPORTED_DEVICES } from '../DevicesModal/constants'; | ||
import { PaxAddSerial } from '../Graphics'; | ||
import { Alert, AlertDescription, AlertTitle } from '../ui/alert'; | ||
|
||
export const NoSelectedDevice = () => { | ||
const isMobile = useIsMobile(); | ||
const [isInputOnFocus, setIsInputOnFocus] = useState(false); | ||
const [serialInput, setSerialInput] = useState<string | undefined>(undefined); | ||
const defaultDevice = SUPPORTED_DEVICES[0]; | ||
const [deviceValue, setDeviceValue] = | ||
useState<Pax.lib.Devices>(defaultDevice); | ||
return ( | ||
<div className="mx-auto flex flex-col gap-6 self-center"> | ||
<PaxPairing | ||
<div className="flex flex-col gap-6 self-center"> | ||
<PaxAddSerial | ||
parallax={!isMobile} | ||
pulsatingLightSpeed={isInputOnFocus ? 'fast' : 'slow'} | ||
serial={{ serial: serialInput, device: deviceValue }} | ||
/> | ||
<AddDeviceFooter | ||
onFocus={() => setIsInputOnFocus(true)} | ||
onBlur={() => setIsInputOnFocus(false)} | ||
serialInput={serialInput} | ||
setSerialInput={setSerialInput} | ||
deviceValue={deviceValue} | ||
setDeviceValue={setDeviceValue} | ||
/> | ||
<Alert> | ||
<Terminal className="h-4 w-4" /> | ||
<AlertTitle>Heads up!</AlertTitle> | ||
<AlertDescription> | ||
Make sure to add the correct serial from the back of your device. | ||
</AlertDescription> | ||
</Alert> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.