|
| 1 | +import { BaseModal } from '@/components/commons/BaseModal'; |
| 2 | +import { Button } from '@/components/commons/Button'; |
| 3 | +import { Typography } from '@/components/commons/Typography'; |
| 4 | +import { |
| 5 | + DetectRelaxedPoseButton, |
| 6 | + ResetRelaxedPoseButton, |
| 7 | +} from '@/components/stay-aligned/RelaxedPose'; |
| 8 | +import { useLocalization } from '@fluent/react'; |
| 9 | +import { Dispatch, ReactNode, SetStateAction } from 'react'; |
| 10 | +import { StayAlignedRelaxedPose } from 'solarxr-protocol'; |
| 11 | + |
| 12 | +function StaAlignedPoseModal({ |
| 13 | + open, |
| 14 | + title, |
| 15 | + descriptionKeys, |
| 16 | + children, |
| 17 | + relaxedPose, |
| 18 | +}: { |
| 19 | + open: [boolean, Dispatch<SetStateAction<boolean>>]; |
| 20 | + title: string; |
| 21 | + descriptionKeys: string[]; |
| 22 | + children: ReactNode; |
| 23 | + relaxedPose: StayAlignedRelaxedPose; |
| 24 | + lastStep?: boolean; |
| 25 | +}) { |
| 26 | + const { l10n } = useLocalization(); |
| 27 | + |
| 28 | + return ( |
| 29 | + <BaseModal |
| 30 | + isOpen={open[0]} |
| 31 | + appendClasses={'w-xl max-w-xl mobile:w-full'} |
| 32 | + closeable |
| 33 | + onRequestClose={() => { |
| 34 | + open[1](false); |
| 35 | + }} |
| 36 | + > |
| 37 | + <div className="flex flex-col"> |
| 38 | + <div className="pb-4"> |
| 39 | + <Typography variant="main-title">{l10n.getString(title)}</Typography> |
| 40 | + </div> |
| 41 | + <div className="flex flex-col gap-1"> |
| 42 | + {descriptionKeys.map((descriptionKey) => ( |
| 43 | + <Typography color="secondary"> |
| 44 | + {l10n.getString(descriptionKey)} |
| 45 | + </Typography> |
| 46 | + ))} |
| 47 | + </div> |
| 48 | + <div className="flex pt-1 items-center fill-background-50 justify-center px-12"> |
| 49 | + {children} |
| 50 | + </div> |
| 51 | + <div className="flex justify-between"> |
| 52 | + <Button variant={'tertiary'} onClick={() => open[1](false)}> |
| 53 | + {l10n.getString('settings-stay_aligned-relaxed_poses-close')} |
| 54 | + </Button> |
| 55 | + <div className="flex gap-2"> |
| 56 | + <ResetRelaxedPoseButton |
| 57 | + variant="tertiary" |
| 58 | + onClick={() => { |
| 59 | + open[1](false); |
| 60 | + }} |
| 61 | + pose={relaxedPose} |
| 62 | + > |
| 63 | + {l10n.getString('settings-stay_aligned-relaxed_poses-reset_pose')} |
| 64 | + </ResetRelaxedPoseButton> |
| 65 | + <DetectRelaxedPoseButton |
| 66 | + onClick={() => { |
| 67 | + open[1](false); |
| 68 | + }} |
| 69 | + pose={relaxedPose} |
| 70 | + /> |
| 71 | + </div> |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + </BaseModal> |
| 75 | + ); |
| 76 | +} |
| 77 | + |
| 78 | +export const StandingRelaxedPoseModal = ({ |
| 79 | + open, |
| 80 | +}: { |
| 81 | + open: [boolean, Dispatch<SetStateAction<boolean>>]; |
| 82 | +}) => ( |
| 83 | + <StaAlignedPoseModal |
| 84 | + open={open} |
| 85 | + title={'onboarding-stay_aligned-relaxed_poses-standing-title'} |
| 86 | + descriptionKeys={[ |
| 87 | + 'onboarding-stay_aligned-relaxed_poses-standing-step-0', |
| 88 | + 'onboarding-stay_aligned-relaxed_poses-standing-step-2', |
| 89 | + ]} |
| 90 | + relaxedPose={StayAlignedRelaxedPose.STANDING} |
| 91 | + > |
| 92 | + <img |
| 93 | + src={'/images/stay-aligned/StayAlignedStanding.webp'} |
| 94 | + width={260} |
| 95 | + alt="Reset position" |
| 96 | + /> |
| 97 | + </StaAlignedPoseModal> |
| 98 | +); |
| 99 | + |
| 100 | +export const SittingRelaxedPoseModal = ({ |
| 101 | + open, |
| 102 | +}: { |
| 103 | + open: [boolean, Dispatch<SetStateAction<boolean>>]; |
| 104 | +}) => ( |
| 105 | + <StaAlignedPoseModal |
| 106 | + open={open} |
| 107 | + title={'onboarding-stay_aligned-relaxed_poses-sitting-title'} |
| 108 | + descriptionKeys={[ |
| 109 | + 'onboarding-stay_aligned-relaxed_poses-sitting-step-0', |
| 110 | + 'onboarding-stay_aligned-relaxed_poses-sitting-step-2', |
| 111 | + ]} |
| 112 | + relaxedPose={StayAlignedRelaxedPose.SITTING} |
| 113 | + > |
| 114 | + <img |
| 115 | + src={'/images/stay-aligned/StayAlignedSitting.webp'} |
| 116 | + width={260} |
| 117 | + alt="Reset position" |
| 118 | + /> |
| 119 | + </StaAlignedPoseModal> |
| 120 | +); |
| 121 | + |
| 122 | +export const FlatRelaxedPoseModal = ({ |
| 123 | + open, |
| 124 | +}: { |
| 125 | + open: [boolean, Dispatch<SetStateAction<boolean>>]; |
| 126 | +}) => ( |
| 127 | + <StaAlignedPoseModal |
| 128 | + open={open} |
| 129 | + title={'onboarding-stay_aligned-relaxed_poses-flat-title'} |
| 130 | + descriptionKeys={[ |
| 131 | + 'onboarding-stay_aligned-relaxed_poses-flat-step-0', |
| 132 | + 'onboarding-stay_aligned-relaxed_poses-flat-step-2', |
| 133 | + ]} |
| 134 | + relaxedPose={StayAlignedRelaxedPose.FLAT} |
| 135 | + > |
| 136 | + <img |
| 137 | + src={'/images/stay-aligned/StayAlignedFloor.webp'} |
| 138 | + width={560} |
| 139 | + alt="Reset position" |
| 140 | + /> |
| 141 | + </StaAlignedPoseModal> |
| 142 | +); |
0 commit comments