Skip to content

Commit 0f91893

Browse files
authored
Added Sight guidelines EPHEMERAL option (#907)
1 parent 66e17c6 commit 0f91893

File tree

27 files changed

+437
-91
lines changed

27 files changed

+437
-91
lines changed

apps/demo-app/src/local-config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"workflow": "photo",
55
"allowSkipRetake": true,
66
"addDamage": "part_select",
7-
"enableSightGuidelines": true,
7+
"enableSightGuidelines": "ephemeral",
88
"allowVehicleTypeSelection": true,
99
"allowManualLogin": true,
1010
"fetchFromSearchParams": true,

documentation/docs/configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ The following table lists the available configuration options in the `PhotoCaptu
126126
| allowSkipRetake | `boolean` | If compliance is enabled, this prop indicate if the user is allowed to skip the retaking process if some pictures are not compliant. | | `false` |
127127
| addDamage | `AddDamage` | Options for Add Damage. If disabled, the `Add Damage` button will be hidden. | | `AddDamage.PART_SELECT` |
128128
| sightGuidelines | `sightGuideline[]` | A collection of sight guidelines in different language with a list of sightIds associate to it. | | |
129-
| enableSightGuideline | `boolean` | Boolean indicating whether the sight guideline feature is enabled. If disabled, the guideline text will be hidden. | | `true` |
129+
| enableSightGuidelines | `PhotoCaptureSightGuidelinesOption` | Option for displaying the Sight guidelines. If disabled, the guideline text will be hidden. | | `PhotoCaptureSightGuidelines.EPHEMERAL` |
130130
| defaultVehicleType | `VehicleType` | Default vehicle type to use if no vehicle type has been specified. | ✔️ | |
131131
| allowVehicleTypeSelection | `boolean` | Indicates if manual vehicle type selection should be enabled if the vehicle type is not defined. | ✔️ | |
132132
| enableTutorial | `PhotoCaptureTutorialOption` | Options for displaying the photo capture tutorial. | | `PhotoCaptureTutorialOption.FIRST_TIME_ONLY` |

documentation/src/utils/schemas.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
DeviceOrientation,
99
MileageUnit,
1010
MonkApiPermission,
11+
PhotoCaptureSightGuidelinesOption,
1112
PhotoCaptureTutorialOption,
1213
SteeringWheelPosition,
1314
TaskName,
@@ -309,7 +310,7 @@ export const LiveConfigSchema = z
309310
useAdaptiveImageQuality: z.boolean().optional(),
310311
allowSkipRetake: z.boolean().optional(),
311312
addDamage: z.nativeEnum(AddDamage).optional(),
312-
enableSightGuidelines: z.boolean().optional(),
313+
enableSightGuidelines: z.nativeEnum(PhotoCaptureSightGuidelinesOption).optional(),
313314
sightGuidelines: z.array(SightGuidelineSchema).optional(),
314315
enableTutorial: z.nativeEnum(PhotoCaptureTutorialOption).optional(),
315316
allowSkipTutorial: z.boolean().optional(),

documentation/src/utils/schemas/photoCaptureConfig.schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { SharedCaptureAppConfigSchema } from '@site/src/utils/schemas/sharedConf
33
import { ComplianceOptionsSchema } from '@site/src/utils/schemas/compliance.schema';
44
import {
55
CaptureWorkflow,
6+
PhotoCaptureSightGuidelinesOption,
67
PhotoCaptureTutorialOption,
78
TaskName,
89
VehicleType,
@@ -27,7 +28,7 @@ export const PhotoCaptureAppConfigSchema = z
2728
maxUploadDurationWarning: z.number().optional(),
2829
useAdaptiveImageQuality: z.boolean().optional(),
2930
sightGuidelines: z.array(SightGuidelineSchema).optional(),
30-
enableSightGuidelines: z.boolean().optional(),
31+
enableSightGuidelines: z.nativeEnum(PhotoCaptureSightGuidelinesOption).optional(),
3132
defaultVehicleType: z.nativeEnum(VehicleType),
3233
allowVehicleTypeSelection: z.boolean(),
3334
enableTutorial: z.nativeEnum(PhotoCaptureTutorialOption).optional(),

packages/inspection-capture-web/src/PhotoCapture/PhotoCapture.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
ComplianceOptions,
1616
MonkPicture,
1717
PhotoCaptureAppConfig,
18+
PhotoCaptureSightGuidelinesOption,
1819
PhotoCaptureTutorialOption,
1920
Sight,
2021
VehicleType,
@@ -37,6 +38,7 @@ import {
3738
useComplianceAnalytics,
3839
usePhotoCaptureSightState,
3940
usePhotoCaptureTutorial,
41+
usePhotoCaptureSightGuidelines,
4042
} from './hooks';
4143

4244
/**
@@ -137,7 +139,7 @@ export function PhotoCapture({
137139
enableTutorial = PhotoCaptureTutorialOption.FIRST_TIME_ONLY,
138140
allowSkipTutorial = true,
139141
enableSightTutorial = true,
140-
enableSightGuidelines = true,
142+
enableSightGuidelines = PhotoCaptureSightGuidelinesOption.EPHEMERAL,
141143
useAdaptiveImageQuality = true,
142144
lang,
143145
enforceOrientation,
@@ -202,6 +204,9 @@ export function PhotoCapture({
202204
enableSightGuidelines,
203205
enableSightTutorial,
204206
});
207+
const { showSightGuidelines, handleDisableSightGuidelines } = usePhotoCaptureSightGuidelines({
208+
enableSightGuidelines,
209+
});
205210
const {
206211
isBadConnectionWarningDialogDisplayed,
207212
closeBadConnectionWarningDialog,
@@ -277,10 +282,11 @@ export function PhotoCapture({
277282
addDamage,
278283
onValidateVehicleParts: addDamageHandle.handleValidateVehicleParts,
279284
sightGuidelines,
280-
enableSightGuidelines,
285+
showSightGuidelines,
281286
currentTutorialStep,
282287
onNextTutorialStep: goToNextTutorialStep,
283288
onCloseTutorial: closeTutorial,
289+
onDisableSightGuidelines: handleDisableSightGuidelines,
284290
allowSkipTutorial,
285291
enforceOrientation,
286292
vehicleType,

packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUD.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export interface PhotoCaptureHUDProps
2626
extends CameraHUDProps,
2727
Pick<
2828
PhotoCaptureAppConfig,
29-
| 'enableSightGuidelines'
3029
| 'sightGuidelines'
3130
| 'addDamage'
3231
| 'showCloseButton'
@@ -109,6 +108,10 @@ export interface PhotoCaptureHUDProps
109108
* Callback called when the user clicks on the "Validate" button of the Add Damage mode.
110109
*/
111110
onValidateVehicleParts: () => void;
111+
/**
112+
* Callback called when the user clicks on both: 'disable' checkbox and 'okay' button.
113+
*/
114+
onDisableSightGuidelines: () => void;
112115
/**
113116
* Callback called when the user clicks on the close button. If this callback is not provided, the close button is not
114117
* displayed.
@@ -122,6 +125,10 @@ export interface PhotoCaptureHUDProps
122125
* The vehicle type of the inspection.
123126
*/
124127
vehicleType: VehicleType;
128+
/**
129+
* Boolean indicating whether the sight guidelines should be displayed.
130+
*/
131+
showSightGuidelines: boolean;
125132
}
126133

127134
/**
@@ -153,13 +160,14 @@ export function PhotoCaptureHUD({
153160
images,
154161
addDamage,
155162
sightGuidelines,
156-
enableSightGuidelines,
163+
showSightGuidelines,
157164
currentTutorialStep,
158165
allowSkipTutorial,
159166
onNextTutorialStep,
160167
onCloseTutorial,
161168
enforceOrientation,
162169
vehicleType,
170+
onDisableSightGuidelines,
163171
}: PhotoCaptureHUDProps) {
164172
const { t } = useTranslation();
165173
const [showCloseModal, setShowCloseModal] = useState(false);
@@ -203,9 +211,10 @@ export function PhotoCaptureHUD({
203211
images={images}
204212
addDamage={addDamage}
205213
sightGuidelines={sightGuidelines}
206-
enableSightGuidelines={enableSightGuidelines}
214+
showSightGuidelines={showSightGuidelines}
207215
tutorialStep={currentTutorialStep}
208216
vehicleType={vehicleType}
217+
onDisableSightGuidelines={onDisableSightGuidelines}
209218
/>
210219
</div>
211220
{mode !== CaptureMode.ADD_DAMAGE_PART_SELECT && (

packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElements/PhotoCaptureHUDElements.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { CaptureMode } from '../../../types';
1515
* Props of the PhotoCaptureHUDElements component.
1616
*/
1717
export interface PhotoCaptureHUDElementsProps
18-
extends Pick<PhotoCaptureAppConfig, 'enableSightGuidelines' | 'sightGuidelines' | 'addDamage'> {
18+
extends Pick<PhotoCaptureAppConfig, 'sightGuidelines' | 'addDamage'> {
1919
/**
2020
* The currently selected sight in the PhotoCapture component : the sight that the user needs to capture.
2121
*/
@@ -64,6 +64,10 @@ export interface PhotoCaptureHUDElementsProps
6464
* Callback called when the user clicks on the "Validate" button of the Add Damage mode.
6565
*/
6666
onValidateVehicleParts: () => void;
67+
/**
68+
* Callback called when the user clicks on both: 'disable' checkbox and 'okay' button.
69+
*/
70+
onDisableSightGuidelines?: () => void;
6771
/**
6872
* The effective pixel dimensions of the Camera video stream on the screen.
6973
*/
@@ -84,6 +88,10 @@ export interface PhotoCaptureHUDElementsProps
8488
* The vehicle type of the inspection.
8589
*/
8690
vehicleType: VehicleType;
91+
/**
92+
* Boolean indicating whether the sight guidelines should be displayed.
93+
*/
94+
showSightGuidelines?: boolean;
8795
}
8896

8997
/**
@@ -106,8 +114,9 @@ export function PhotoCaptureHUDElements(params: PhotoCaptureHUDElementsProps) {
106114
images={params.images}
107115
addDamage={params.addDamage}
108116
sightGuidelines={params.sightGuidelines}
109-
enableSightGuidelines={params.enableSightGuidelines}
117+
showSightGuidelines={params.showSightGuidelines}
110118
tutorialStep={params.tutorialStep}
119+
onDisableSightGuidelines={params.onDisableSightGuidelines}
111120
/>
112121
);
113122
}

packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/PhotoCaptureHUDElementsSight.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ export function PhotoCaptureHUDElementsSight({
1818
onSelectedSight = () => {},
1919
onRetakeSight = () => {},
2020
onAddDamage = () => {},
21+
onDisableSightGuidelines = () => {},
2122
sightsTaken,
2223
previewDimensions,
2324
images,
2425
addDamage,
2526
sightGuidelines,
26-
enableSightGuidelines,
27+
showSightGuidelines,
2728
tutorialStep,
2829
}: PhotoCaptureHUDElementsSightProps) {
2930
const style = usePhotoCaptureHUDSightPreviewStyle({ previewDimensions });
@@ -39,8 +40,9 @@ export function PhotoCaptureHUDElementsSight({
3940
<SightGuideline
4041
sightId={selectedSight.id}
4142
sightGuidelines={sightGuidelines}
42-
enableSightGuidelines={enableSightGuidelines}
43+
disabled={!showSightGuidelines}
4344
addDamage={addDamage}
45+
onDisableSightGuidelines={onDisableSightGuidelines}
4446
/>
4547
<AddDamageButton onAddDamage={onAddDamage} addDamage={addDamage} />
4648
</div>

packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/SightGuideline.styles.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,29 @@ export const styles: Styles = {
1414
width: `calc(98% - (${PHOTO_CAPTURE_HUD_BUTTONS_BAR_WIDTH * 4}px))`,
1515
justifyContent: 'center',
1616
},
17-
button: {
18-
textAlign: 'start',
17+
guideline: {
18+
display: 'flex',
19+
flexDirection: 'column',
20+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
1921
borderRadius: '12px',
20-
fontSize: 14,
21-
flexDirection: 'row-reverse',
22-
paddingRight: 0,
23-
alignItems: 'start',
24-
gap: 10,
22+
justifyContent: 'start',
23+
padding: '10px',
24+
gap: '8px',
25+
letterSpacing: '0.15px',
26+
fontSize: '14',
27+
},
28+
buttonContainer: {
29+
display: 'flex',
30+
justifyContent: 'space-between',
31+
padding: '0px 10px 0px',
32+
},
33+
checkbox: {
34+
display: 'flex',
35+
cursor: 'pointer',
36+
gap: '5px',
37+
},
38+
button: {
39+
all: 'unset',
40+
cursor: 'pointer',
2541
},
2642
};

packages/inspection-capture-web/src/PhotoCapture/PhotoCaptureHUD/PhotoCaptureHUDElementsSight/SightGuideline/SightGuideline.tsx

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import { useEffect, useState } from 'react';
2-
import { Button } from '@monkvision/common-ui-web';
3-
import { AddDamage, PhotoCaptureAppConfig } from '@monkvision/types';
2+
import { PhotoCaptureAppConfig } from '@monkvision/types';
43
import { useTranslation } from 'react-i18next';
54
import { getLanguage } from '@monkvision/common';
65
import { styles } from './SightGuideline.styles';
7-
import { useColorBackground } from '../../../../hooks';
6+
import { useSightGuidelineStyle } from './hooks';
87

98
/**
109
* Props of the SightGuideline component.
1110
*/
1211
export interface SightGuidelineProps
13-
extends Pick<PhotoCaptureAppConfig, 'addDamage' | 'sightGuidelines' | 'enableSightGuidelines'> {
12+
extends Pick<PhotoCaptureAppConfig, 'addDamage' | 'sightGuidelines'> {
1413
/**
1514
* The id of the sight.
1615
*/
@@ -21,6 +20,16 @@ export interface SightGuidelineProps
2120
* @default false
2221
*/
2322
enableDefaultMessage?: boolean;
23+
/**
24+
* Boolean indicating if the sight guidelines are enabled.
25+
*
26+
* @default true
27+
*/
28+
disabled?: boolean;
29+
/**
30+
* Callback called when the user clicks on both: 'disable' checkbox and 'okay' button.
31+
*/
32+
onDisableSightGuidelines?: () => void;
2433
}
2534

2635
/**
@@ -29,15 +38,16 @@ export interface SightGuidelineProps
2938
export function SightGuideline({
3039
sightId,
3140
sightGuidelines,
32-
enableSightGuidelines,
3341
addDamage,
3442
enableDefaultMessage = false,
43+
disabled = false,
44+
onDisableSightGuidelines = () => {},
3545
}: SightGuidelineProps) {
3646
const [showGuideline, setShowGuideline] = useState(true);
37-
const primaryColor = useColorBackground();
38-
const { i18n, t } = useTranslation();
47+
const [checked, setChecked] = useState(false);
3948

40-
const style = addDamage === AddDamage.DISABLED ? styles['containerWide'] : styles['container'];
49+
const { i18n, t } = useTranslation();
50+
const style = useSightGuidelineStyle({ addDamage });
4151

4252
const guidelineFound = sightGuidelines?.find((value) => value.sightIds.includes(sightId));
4353

@@ -47,19 +57,46 @@ export function SightGuideline({
4757

4858
const guideline = guidelineFound ? guidelineFound[getLanguage(i18n.language)] : defaultMessage;
4959

60+
const handleShowSightGuidelines = () => {
61+
if (checked) {
62+
onDisableSightGuidelines();
63+
}
64+
setShowGuideline(false);
65+
};
66+
5067
useEffect(() => setShowGuideline(true), [sightId]);
5168

5269
return (
53-
<div style={style}>
54-
{enableSightGuidelines && showGuideline && guideline && (
55-
<Button
56-
icon='close'
57-
primaryColor={primaryColor}
58-
style={styles['button']}
59-
onClick={() => setShowGuideline(false)}
60-
>
70+
<div style={style.container} data-testid='container'>
71+
{!disabled && showGuideline && guideline && (
72+
<div style={style.guideline} data-testid='guideline'>
6173
{guideline}
62-
</Button>
74+
<div style={styles['buttonContainer']}>
75+
<div
76+
style={styles['checkbox']}
77+
role='checkbox'
78+
aria-checked={checked}
79+
tabIndex={0}
80+
onClick={() => setChecked(!checked)}
81+
onKeyDown={(e) => {
82+
if (e.key === 'Enter' || e.key === ' ') {
83+
setChecked(!checked);
84+
}
85+
}}
86+
data-testid='checkbox-container'
87+
>
88+
<input type='checkbox' checked={checked} onChange={(e) => e.stopPropagation()} />
89+
<span>{t('photo.hud.guidelines.disable')}</span>
90+
</div>
91+
<button
92+
style={styles['button']}
93+
onClick={handleShowSightGuidelines}
94+
data-testid='button'
95+
>
96+
{t('photo.hud.guidelines.validate')}
97+
</button>
98+
</div>
99+
</div>
63100
)}
64101
</div>
65102
);

0 commit comments

Comments
 (0)