Skip to content

Commit 1e57685

Browse files
shreeyash07frozenhelium
authored andcommitted
finalize scenario preview
1 parent d0cf9f1 commit 1e57685

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

manager-dashboard/app/views/NewTutorial/ScenarioPageInput/FootprintGeoJsonPreview/index.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import { _cs } from '@togglecorp/fujs';
33

44
import GeoJsonPreview from '#components/GeoJsonPreview';
5+
import { CustomOptionPreviewType } from '#views/NewTutorial/utils';
56
import { IconKey, iconMap } from '#utils/common';
67

78
import styles from './styles.css';
@@ -15,13 +16,15 @@ interface Props {
1516
icon?: IconKey;
1617
}
1718
url: string | undefined;
19+
customOptionsPreview?: CustomOptionPreviewType[] | undefined;
1820
}
1921
export default function FootprintGeoJsonPreview(props: Props) {
2022
const {
2123
className,
2224
geoJson,
2325
url,
2426
previewPopUp,
27+
customOptionsPreview,
2528
} = props;
2629

2730
const Comp = previewPopUp?.icon ? iconMap[previewPopUp.icon] : undefined;
@@ -49,7 +52,18 @@ export default function FootprintGeoJsonPreview(props: Props) {
4952
geoJson={geoJson}
5053
/>
5154
<div className={styles.footerOption}>
52-
Footer Option
55+
{customOptionsPreview?.map((option) => {
56+
const Icon = iconMap[option.icon];
57+
return (
58+
<div
59+
key={option.id}
60+
className={styles.previewIcon}
61+
style={{ backgroundColor: option.iconColor }}
62+
>
63+
<Icon />
64+
</div>
65+
);
66+
})}
5367
</div>
5468
</div>
5569
);

manager-dashboard/app/views/NewTutorial/ScenarioPageInput/FootprintGeoJsonPreview/styles.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,15 @@
4747

4848
.footer-option {
4949
display: flex;
50+
flex-direction: column;
51+
gap: var(--spacing-large);
52+
53+
.preview-icon {
54+
display: flex;
55+
align-items: center;
56+
border-radius: 50%;
57+
padding: 3px;
58+
font-size: 30px;
59+
}
5060
}
5161
}

manager-dashboard/app/views/NewTutorial/ScenarioPageInput/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Heading from '#components/Heading';
2323
import SelectInput from '#components/SelectInput';
2424
import ScenarioGeoJsonPreview from './ScenarioGeoJsonPreview';
2525
import SegmentInput from '#components/SegmentInput';
26+
import { CustomOptionPreviewType } from '../utils';
2627
import FootprintGeoJsonPreview from './FootprintGeoJsonPreview';
2728
import ChangeDetectionGeoJsonPreview from './ChangeDetectionGeoJsonPreview';
2829

@@ -72,6 +73,7 @@ interface Props {
7273
projectType: ProjectType | undefined;
7374
url: string | undefined;
7475
urlB: string | undefined;
76+
customOptionsPreview?: CustomOptionPreviewType[] | undefined;
7577
}
7678

7779
export default function ScenarioPageInput(props: Props) {
@@ -84,6 +86,7 @@ export default function ScenarioPageInput(props: Props) {
8486
url,
8587
projectType,
8688
urlB,
89+
customOptionsPreview,
8790
} = props;
8891

8992
const [activeSegmentInput, setActiveInput] = React.useState<ScenarioSegmentType['value']>('instruction');
@@ -223,6 +226,7 @@ export default function ScenarioPageInput(props: Props) {
223226
<FootprintGeoJsonPreview
224227
geoJson={geoJson}
225228
url={url}
229+
customOptionsPreview={customOptionsPreview}
226230
/>
227231
)}
228232
<SegmentInput

manager-dashboard/app/views/NewTutorial/index.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
unique,
66
getElementAround,
77
isNotDefined,
8+
randomString,
89
} from '@togglecorp/fujs';
910
import {
1011
useForm,
@@ -81,6 +82,8 @@ import {
8182
infoPageTemplateoptions,
8283
infoPageBlocksMap,
8384
tileServerUrls,
85+
ColorKey,
86+
CustomOptionPreviewType,
8487
} from './utils';
8588
import CustomOptionInput from './CustomOptionInput';
8689
import ScenarioPageInput from './ScenarioPageInput';
@@ -482,6 +485,21 @@ function NewTutorial(props: Props) {
482485
return tileServerUrls[tileServerName];
483486
}, [value.tileServerB?.name, value.tileServerB?.url]);
484487

488+
const customOptionsPreview: CustomOptionPreviewType[] | undefined = React.useMemo(() => {
489+
const customOptions = value?.customOptions;
490+
if (isNotDefined(customOptions)) {
491+
return undefined;
492+
}
493+
const finalValue = customOptions.map((custom) => (
494+
{
495+
id: randomString(),
496+
icon: custom.icon ?? 'removeOutline',
497+
iconColor: custom.iconColor as ColorKey ?? 'gray',
498+
}
499+
));
500+
return finalValue;
501+
}, [value.customOptions]);
502+
485503
return (
486504
<div className={_cs(styles.newTutorial, className)}>
487505
<div className={styles.container}>
@@ -598,13 +616,13 @@ function NewTutorial(props: Props) {
598616
<SelectInput
599617
name=""
600618
label="Page Template"
619+
className={styles.instructionPopup}
601620
nonClearable
602621
value={selectedInfoPageTemplate}
603622
onChange={setSelectedInfoPageTemplate}
604623
options={infoPageTemplateoptions}
605624
keySelector={(infoPageTemplate) => infoPageTemplate.key}
606625
labelSelector={(infoPageTemplate) => infoPageTemplate.label}
607-
className={styles.instructionPopup}
608626
/>
609627
<Button
610628
name={selectedInfoPageTemplate}
@@ -752,6 +770,7 @@ function NewTutorial(props: Props) {
752770
projectType={value.projectType}
753771
onChange={onScenarioFormChange}
754772
error={scenarioError?.[task.scenarioId]}
773+
customOptionsPreview={customOptionsPreview}
755774
geoJson={previewGeoJson}
756775
url={tileServerAUrl}
757776
urlB={tileServerBUrl}

manager-dashboard/app/views/NewTutorial/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ export const colorKeyToColorMap: Record<ColorKey, string> = {
6262
gray: '#757575',
6363
};
6464

65+
export interface CustomOptionPreviewType {
66+
id: string;
67+
icon: IconKey,
68+
iconColor: ColorKey,
69+
}
70+
6571
export interface ColorOptions {
6672
key: ColorKey;
6773
label: string;

0 commit comments

Comments
 (0)