From 4e576c11b678cf722c4ac0de9f003861ff8e63ef Mon Sep 17 00:00:00 2001 From: Elena Schramme Date: Fri, 31 May 2024 17:15:16 +0200 Subject: [PATCH] improvements for escalation mode --- .../Element/Complex/EscalationModeElement.tsx | 31 +++++++-- src/components/Widget/EscalationWidget.tsx | 68 +++++++++++-------- src/prototype/lpd/stress/highLPD.ts | 4 +- tailwind.config.js | 8 +-- 4 files changed, 70 insertions(+), 41 deletions(-) diff --git a/src/components/Element/Complex/EscalationModeElement.tsx b/src/components/Element/Complex/EscalationModeElement.tsx index b58bbd6..950b3e4 100644 --- a/src/components/Element/Complex/EscalationModeElement.tsx +++ b/src/components/Element/Complex/EscalationModeElement.tsx @@ -1,4 +1,4 @@ -import { Key, useEffect, useState } from 'react'; +import { type Dispatch, Key, type SetStateAction, useEffect, useState } from 'react'; import { v4 as uuid } from 'uuid'; import { useAppSelector } from 'src/redux/hooks'; import { getGazesAndKeys } from 'src/redux/slices/gazeSlice'; @@ -8,17 +8,23 @@ import MissileIcon from 'src/assets/icons/threats/missile-lg-emph.svg'; type EscalationModeElementProps = { element: EscalationModeElementType; + animation: string + animationClass: string + setAnimation: (action: 'approve' | 'deny') => void; + setAnimationClass: Dispatch> onAction?: (action: 'approve' | 'deny') => void; }; const EscalationModeElement = ({ element, + onAction, + setAnimation, + setAnimationClass, + animation, + animationClass }: EscalationModeElementProps) => { - const [animation, setAnimation] = useState<'approve' | 'deny' | 'moreInfo' | 'up' | undefined>(undefined,); - const [animationClass, setAnimationClass] = useState('animate-slide-in-right'); - const gazesAndKeys = useAppSelector(getGazesAndKeys); const approveDenyButtonElement = { id: uuid(), @@ -47,6 +53,16 @@ const EscalationModeElement = ({ borderRight: '0px' } + const handleApprove = () => { + setAnimation('approve'); + if (onAction) onAction('approve'); + }; + + const handleDeny = () => { + setAnimation('deny'); + if (onAction) onAction('deny'); + }; + useEffect(() => { if (animation === 'approve' || animation === 'deny') { setAnimationClass('animate-blur-away'); @@ -72,7 +88,8 @@ const EscalationModeElement = ({ return ( - <>
+ <>
+ <>
@@ -98,7 +115,7 @@ const EscalationModeElement = ({
-
+

Additional Information

@@ -154,7 +171,7 @@ const EscalationModeElement = ({
-
+
); }; diff --git a/src/components/Widget/EscalationWidget.tsx b/src/components/Widget/EscalationWidget.tsx index 7cdad9e..d2dc3a7 100644 --- a/src/components/Widget/EscalationWidget.tsx +++ b/src/components/Widget/EscalationWidget.tsx @@ -1,39 +1,51 @@ -import NOTCH from 'src/assets/icons/Ownship Notch.svg'; +import { useState, useEffect } from 'react'; import type { EscalationModeWidget as EscalationModeWidgetType } from 'src/types/widget'; import type { EscalationModeElement as EscalationModeElementType } from 'src/types/element'; import EscalationModeElement from 'src/components/Element/Complex/EscalationModeElement'; type EscalationWidgetProps = { - widget: EscalationModeWidgetType; + widget: EscalationModeWidgetType; }; -const EscalationWidget = ({ widget}: EscalationWidgetProps) => { - const { x, y, h, w, elements } = widget; +const EscalationWidget = ({ widget }: EscalationWidgetProps) => { + const { x, y, h, w, elements } = widget; + const [initial, setInitial] = useState(true); + const [animation, setAnimation] = useState<'approve' | 'deny' | undefined>(undefined,); + const [animationClass, setAnimationClass] = useState('animate-slide-in-right'); - var firstElements = structuredClone(elements); + useEffect(() => { + const timer = setTimeout(() => setInitial(false), 10000); // remove slide-in after 10 seconds + return () => clearTimeout(timer); + }, []); - return( -
- {firstElements.map((element) => ( - { - // Handle any additional logic when action is taken, e.g., logging, state updates - }} - /> - ))} -
- ) + const handleAction = (action: 'approve' | 'deny') => { + // Logic to handle approve/deny action + }; + + return ( +
+ {elements.map((element) => ( + + ))} +
+ ); }; -export default EscalationWidget; \ No newline at end of file +export default EscalationWidget; diff --git a/src/prototype/lpd/stress/highLPD.ts b/src/prototype/lpd/stress/highLPD.ts index a189f54..b6c6eb7 100644 --- a/src/prototype/lpd/stress/highLPD.ts +++ b/src/prototype/lpd/stress/highLPD.ts @@ -222,10 +222,10 @@ const missileToOwnshipDetectedMessageHigh = ( id: minimapWidgetId1, // this should be something static? sectionType: 'minimap', type: 'escalation', - x: 560, + x: 0, y: 85, h: 979, - w: 1360, + w: 1919, screen: '/minimap', canOverlap: false, useElementLocation: false, diff --git a/tailwind.config.js b/tailwind.config.js index 81c94be..63926e1 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -4,7 +4,7 @@ const config = { extend: { animation: { "slide-in-right": 'slide-in-right 2s ease-out forwards', - "blur-away": 'blur-away 7s ease-out forwards', + "blur-away": 'blur-away 9s ease-out forwards', }, keyframes: { "slide-in-right": { @@ -13,7 +13,7 @@ const config = { opacity: 0, }, '100%': { - transform: 'translateX(560px)', + transform: 'translateX(0%)', opacity: 1, }, }, @@ -21,11 +21,11 @@ const config = { '0%': { opacity: 1, }, - '20%': { + '80%': { opacity: 1, }, '100%': { - opacity: 1, + opacity: 0, }, }, },