@codecademy/brand 0.13.38-alpha.8ed52557eb.0 → 0.13.39-alpha.1fdb413ca3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AppHeader/index.js +5 -7
- package/dist/GlobalHeader/GlobalHeaderVariants.d.ts +2 -2
- package/dist/GlobalHeader/GlobalHeaderVariants.js +6 -6
- package/dist/GlobalHeader/index.d.ts +0 -1
- package/dist/GlobalHeader/index.js +38 -43
- package/dist/GlobalHeader/types.d.ts +0 -1
- package/dist/StudyPlan/ContentItemDetail.d.ts +10 -0
- package/dist/StudyPlan/ContentItemDetail.js +114 -0
- package/dist/StudyPlan/CreateStudyPlanSectionContent.d.ts +14 -0
- package/dist/StudyPlan/CreateStudyPlanSectionContent.js +90 -0
- package/dist/StudyPlan/ShowMoreContentItemsButton.d.ts +9 -0
- package/dist/StudyPlan/ShowMoreContentItemsButton.js +44 -0
- package/dist/StudyPlan/StudyPlanDeleteDialog.d.ts +6 -0
- package/dist/StudyPlan/StudyPlanDeleteDialog.js +26 -0
- package/dist/StudyPlan/StudyPlanDescription.d.ts +10 -0
- package/dist/StudyPlan/StudyPlanDescription.js +50 -0
- package/dist/StudyPlan/StudyPlanModal/StudyPlanForm.d.ts +10 -0
- package/dist/StudyPlan/StudyPlanModal/StudyPlanForm.js +138 -0
- package/dist/StudyPlan/StudyPlanModal/StudyPlanModalFooter.d.ts +14 -0
- package/dist/StudyPlan/StudyPlanModal/StudyPlanModalFooter.js +64 -0
- package/dist/StudyPlan/StudyPlanModal/index.d.ts +18 -0
- package/dist/StudyPlan/StudyPlanModal/index.js +120 -0
- package/dist/StudyPlan/SuggestedContentItemsSectionHeader.d.ts +8 -0
- package/dist/StudyPlan/SuggestedContentItemsSectionHeader.js +58 -0
- package/dist/StudyPlan/assets/studyPlanBanner.svg +9 -0
- package/dist/StudyPlan/helpers.d.ts +75 -0
- package/dist/StudyPlan/helpers.js +165 -0
- package/dist/StudyPlan/index.d.ts +8 -0
- package/dist/StudyPlan/index.js +8 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/catalogList/index.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface StudyPlanDescriptionProps {
|
|
3
|
+
containerPercentComplete?: number | null;
|
|
4
|
+
containerTimeToComplete?: number | null;
|
|
5
|
+
handleEditStudyPlanClick?: () => void;
|
|
6
|
+
sessionLength: number;
|
|
7
|
+
sessionsPerWeek: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const StudyPlanDescription: React.FC<StudyPlanDescriptionProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _styled from "@emotion/styled/base";
|
|
2
|
+
import { Anchor, Box, FlexBox, Text } from '@codecademy/gamut';
|
|
3
|
+
import { css } from '@codecademy/gamut-styles';
|
|
4
|
+
import React, { useMemo } from 'react';
|
|
5
|
+
import { calculateTargetTimeFrame, formatStudyPlanText, formatTargetTimeFrameText } from './helpers';
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
+
const StyledAnchor = /*#__PURE__*/_styled(Anchor, {
|
|
8
|
+
target: "e1xee0m00",
|
|
9
|
+
label: "StyledAnchor"
|
|
10
|
+
})(css({
|
|
11
|
+
color: 'black'
|
|
12
|
+
}), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9TdHVkeVBsYW4vU3R1ZHlQbGFuRGVzY3JpcHRpb24udHN4Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQVdxQiIsImZpbGUiOiIuLi8uLi9zcmMvU3R1ZHlQbGFuL1N0dWR5UGxhbkRlc2NyaXB0aW9uLnRzeCIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydC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A8VGV4dCB0ZXh0Q29sb3I9XCJ0ZXh0LXNlY29uZGFyeVwiIGRpc3BsYXk9XCJpbmxpbmVcIiBtcj17OH0+XG4gICAgICAgICAge3N0dWR5UGxhblN1bW1hcnl9XG4gICAgICAgIDwvVGV4dD5cbiAgICAgICAge2hhbmRsZUVkaXRTdHVkeVBsYW5DbGljayAmJiAoXG4gICAgICAgICAgPFN0eWxlZEFuY2hvclxuICAgICAgICAgICAgYXJpYS1sYWJlbD1cIkVkaXQgc3R1ZHkgcGxhblwiXG4gICAgICAgICAgICBvbkNsaWNrPXtoYW5kbGVFZGl0U3R1ZHlQbGFuQ2xpY2t9XG4gICAgICAgICAgPlxuICAgICAgICAgICAgRWRpdFxuICAgICAgICAgIDwvU3R5bGVkQW5jaG9yPlxuICAgICAgICApfVxuICAgICAgPC9Cb3g+XG4gICAgPC9GbGV4Qm94PlxuICApO1xufTtcbiJdfQ== */");
|
|
13
|
+
export const StudyPlanDescription = _ref => {
|
|
14
|
+
let {
|
|
15
|
+
containerPercentComplete,
|
|
16
|
+
containerTimeToComplete,
|
|
17
|
+
handleEditStudyPlanClick,
|
|
18
|
+
sessionLength,
|
|
19
|
+
sessionsPerWeek
|
|
20
|
+
} = _ref;
|
|
21
|
+
const targetTimeFrameInWeeks = useMemo(() => {
|
|
22
|
+
return calculateTargetTimeFrame(sessionsPerWeek, sessionLength / 60, containerPercentComplete, containerTimeToComplete);
|
|
23
|
+
}, [containerPercentComplete, containerTimeToComplete, sessionLength, sessionsPerWeek]);
|
|
24
|
+
const targetTimeFrameText = formatTargetTimeFrameText(targetTimeFrameInWeeks);
|
|
25
|
+
const targetTimeFrameSummary = `On track to finish in ${targetTimeFrameText}`;
|
|
26
|
+
const studyPlanSummary = formatStudyPlanText(sessionLength, sessionsPerWeek);
|
|
27
|
+
return /*#__PURE__*/_jsx(FlexBox, {
|
|
28
|
+
mt: 24,
|
|
29
|
+
children: /*#__PURE__*/_jsxs(Box, {
|
|
30
|
+
"data-testid": "created-study-plan-text",
|
|
31
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
32
|
+
display: "inline",
|
|
33
|
+
children: targetTimeFrameSummary
|
|
34
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
35
|
+
mx: 4,
|
|
36
|
+
"aria-hidden": true,
|
|
37
|
+
children: "-"
|
|
38
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
39
|
+
textColor: "text-secondary",
|
|
40
|
+
display: "inline",
|
|
41
|
+
mr: 8,
|
|
42
|
+
children: studyPlanSummary
|
|
43
|
+
}), handleEditStudyPlanClick && /*#__PURE__*/_jsx(StyledAnchor, {
|
|
44
|
+
"aria-label": "Edit study plan",
|
|
45
|
+
onClick: handleEditStudyPlanClick,
|
|
46
|
+
children: "Edit"
|
|
47
|
+
})]
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StudyPlanInputErrorMessageValues, StudyPlanInputValues } from '../helpers';
|
|
3
|
+
interface StudyPlanFormProps {
|
|
4
|
+
handleInputChange: (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => void;
|
|
5
|
+
studyPlanInputErrorMessage: StudyPlanInputErrorMessageValues;
|
|
6
|
+
studyPlanInputValues: StudyPlanInputValues;
|
|
7
|
+
targetTimeFrameInWeeks: number;
|
|
8
|
+
}
|
|
9
|
+
export declare const StudyPlanForm: React.FC<StudyPlanFormProps>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Box, FlexBox, Form, Input, Text } from '@codecademy/gamut';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { formatTargetTimeFrameText, studyPlanDefaultInputValues, studyPlanIncrementValues } from '../helpers';
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
export const StudyPlanForm = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
handleInputChange,
|
|
8
|
+
studyPlanInputErrorMessage,
|
|
9
|
+
studyPlanInputValues,
|
|
10
|
+
targetTimeFrameInWeeks
|
|
11
|
+
} = _ref;
|
|
12
|
+
const {
|
|
13
|
+
sessionLength,
|
|
14
|
+
sessionsPerWeek
|
|
15
|
+
} = studyPlanInputValues;
|
|
16
|
+
const {
|
|
17
|
+
sessionLength: sessionLengthInputErrorMessage,
|
|
18
|
+
sessionsPerWeek: sessionsPerWeekInputErrorMessage
|
|
19
|
+
} = studyPlanInputErrorMessage;
|
|
20
|
+
const {
|
|
21
|
+
sessionLength: sessionLengthDefault,
|
|
22
|
+
sessionsPerWeek: sessionsPerWeekDefault
|
|
23
|
+
} = studyPlanDefaultInputValues;
|
|
24
|
+
const {
|
|
25
|
+
sessionLength: sessionLengthIncrement,
|
|
26
|
+
sessionsPerWeek: sessionsPerWeekIncrement
|
|
27
|
+
} = studyPlanIncrementValues;
|
|
28
|
+
const targetTimeFrameText = formatTargetTimeFrameText(targetTimeFrameInWeeks);
|
|
29
|
+
return /*#__PURE__*/_jsxs(FlexBox, {
|
|
30
|
+
column: true,
|
|
31
|
+
borderRadius: "md",
|
|
32
|
+
bg: "background-selected",
|
|
33
|
+
children: [/*#__PURE__*/_jsxs(FlexBox, {
|
|
34
|
+
column: true,
|
|
35
|
+
px: 24,
|
|
36
|
+
pt: 24,
|
|
37
|
+
pb: 16,
|
|
38
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
39
|
+
fontWeight: 700,
|
|
40
|
+
mb: 12,
|
|
41
|
+
children: "What\u2019s a good time commitment?"
|
|
42
|
+
}), /*#__PURE__*/_jsx(Form, {
|
|
43
|
+
children: /*#__PURE__*/_jsxs(FlexBox, {
|
|
44
|
+
column: true,
|
|
45
|
+
children: [/*#__PURE__*/_jsxs(FlexBox, {
|
|
46
|
+
justifyContent: "space-between",
|
|
47
|
+
center: true,
|
|
48
|
+
mb: sessionsPerWeekInputErrorMessage ? 8 : 16,
|
|
49
|
+
children: [/*#__PURE__*/_jsxs(FlexBox, {
|
|
50
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
51
|
+
children: "Days per week"
|
|
52
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
53
|
+
as: "span",
|
|
54
|
+
"aria-hidden": true,
|
|
55
|
+
children: "*"
|
|
56
|
+
})]
|
|
57
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
58
|
+
width: "100%",
|
|
59
|
+
maxWidth: 100,
|
|
60
|
+
children: /*#__PURE__*/_jsx(Input, {
|
|
61
|
+
htmlFor: "sessionsPerWeek",
|
|
62
|
+
required: true,
|
|
63
|
+
"aria-label": "Days per week",
|
|
64
|
+
name: "sessionsPerWeek",
|
|
65
|
+
type: "number",
|
|
66
|
+
max: 7,
|
|
67
|
+
min: sessionsPerWeekIncrement,
|
|
68
|
+
step: sessionsPerWeekIncrement,
|
|
69
|
+
error: !!sessionsPerWeekInputErrorMessage,
|
|
70
|
+
defaultValue: sessionsPerWeek || sessionsPerWeekDefault,
|
|
71
|
+
onChange: handleInputChange
|
|
72
|
+
})
|
|
73
|
+
})]
|
|
74
|
+
}), sessionsPerWeekInputErrorMessage && /*#__PURE__*/_jsx(FlexBox, {
|
|
75
|
+
alignSelf: "flex-end",
|
|
76
|
+
mb: 16,
|
|
77
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
78
|
+
fontSize: 14,
|
|
79
|
+
textColor: "red-600",
|
|
80
|
+
children: sessionsPerWeekInputErrorMessage
|
|
81
|
+
})
|
|
82
|
+
}), /*#__PURE__*/_jsxs(FlexBox, {
|
|
83
|
+
justifyContent: "space-between",
|
|
84
|
+
center: true,
|
|
85
|
+
children: [/*#__PURE__*/_jsxs(FlexBox, {
|
|
86
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
87
|
+
children: "Hours per day"
|
|
88
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
89
|
+
as: "span",
|
|
90
|
+
"aria-hidden": true,
|
|
91
|
+
children: "*"
|
|
92
|
+
})]
|
|
93
|
+
}), /*#__PURE__*/_jsx(Box, {
|
|
94
|
+
width: "100%",
|
|
95
|
+
maxWidth: 100,
|
|
96
|
+
children: /*#__PURE__*/_jsx(Input, {
|
|
97
|
+
htmlFor: "sessionLength",
|
|
98
|
+
name: "sessionLength",
|
|
99
|
+
required: true,
|
|
100
|
+
"aria-label": "Hours per day",
|
|
101
|
+
type: "number",
|
|
102
|
+
max: 8,
|
|
103
|
+
min: sessionLengthIncrement,
|
|
104
|
+
step: sessionLengthIncrement,
|
|
105
|
+
error: !!sessionLengthInputErrorMessage,
|
|
106
|
+
defaultValue: sessionLength || sessionLengthDefault,
|
|
107
|
+
onChange: handleInputChange
|
|
108
|
+
})
|
|
109
|
+
})]
|
|
110
|
+
}), sessionLengthInputErrorMessage && /*#__PURE__*/_jsx(FlexBox, {
|
|
111
|
+
alignSelf: "flex-end",
|
|
112
|
+
fontSize: 14,
|
|
113
|
+
mt: 8,
|
|
114
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
115
|
+
textColor: "red-600",
|
|
116
|
+
children: sessionLengthInputErrorMessage
|
|
117
|
+
})
|
|
118
|
+
})]
|
|
119
|
+
})
|
|
120
|
+
})]
|
|
121
|
+
}), /*#__PURE__*/_jsxs(FlexBox, {
|
|
122
|
+
borderTop: 1,
|
|
123
|
+
borderColor: "background-selected",
|
|
124
|
+
px: 24,
|
|
125
|
+
py: 16,
|
|
126
|
+
justifyContent: "space-between",
|
|
127
|
+
bg: "background-selected",
|
|
128
|
+
center: true,
|
|
129
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
130
|
+
children: "Estimated time to finish"
|
|
131
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
132
|
+
fontSize: 20,
|
|
133
|
+
fontWeight: 700,
|
|
134
|
+
children: targetTimeFrameText
|
|
135
|
+
})]
|
|
136
|
+
})]
|
|
137
|
+
});
|
|
138
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StudyPlanInputValues } from '../helpers';
|
|
3
|
+
interface StudyPlanModalFooterProps {
|
|
4
|
+
hasStudyPlanFormInputErrors?: boolean;
|
|
5
|
+
handleDeleteStudyPlanClick: () => void;
|
|
6
|
+
isEditModal?: boolean;
|
|
7
|
+
isSaveLoading: boolean;
|
|
8
|
+
onCreateStudyPlanSave: () => void;
|
|
9
|
+
onRequestClose: () => void;
|
|
10
|
+
studyPlanInputValues: StudyPlanInputValues;
|
|
11
|
+
targetTimeFrameInWeeks: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const StudyPlanModalFooter: React.FC<StudyPlanModalFooterProps>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { FillButton, FlexBox, StrokeButton, Text, TextButton } from '@codecademy/gamut';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { formatStudyPlanSummaryText, formatTargetTimeFrameText } from '../helpers';
|
|
4
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
export const StudyPlanModalFooter = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
hasStudyPlanFormInputErrors,
|
|
8
|
+
handleDeleteStudyPlanClick,
|
|
9
|
+
isEditModal,
|
|
10
|
+
isSaveLoading,
|
|
11
|
+
onCreateStudyPlanSave,
|
|
12
|
+
onRequestClose,
|
|
13
|
+
studyPlanInputValues,
|
|
14
|
+
targetTimeFrameInWeeks
|
|
15
|
+
} = _ref;
|
|
16
|
+
const {
|
|
17
|
+
sessionsPerWeek,
|
|
18
|
+
sessionLength
|
|
19
|
+
} = studyPlanInputValues;
|
|
20
|
+
const primaryCtaText = isEditModal ? 'Update study plan' : 'Make study plan';
|
|
21
|
+
const targetTimeFrameText = formatTargetTimeFrameText(targetTimeFrameInWeeks);
|
|
22
|
+
const targetStudyPlanSummaryTime = formatStudyPlanSummaryText(sessionLength, sessionsPerWeek, targetTimeFrameText);
|
|
23
|
+
return /*#__PURE__*/_jsxs(FlexBox, {
|
|
24
|
+
column: true,
|
|
25
|
+
mt: 24,
|
|
26
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
27
|
+
mb: 16,
|
|
28
|
+
children: targetStudyPlanSummaryTime
|
|
29
|
+
}), /*#__PURE__*/_jsxs(FlexBox, {
|
|
30
|
+
justifyContent: {
|
|
31
|
+
_: 'flex-start',
|
|
32
|
+
xs: isEditModal ? 'space-between' : 'flex-end'
|
|
33
|
+
},
|
|
34
|
+
flexDirection: {
|
|
35
|
+
_: 'column',
|
|
36
|
+
xs: 'row'
|
|
37
|
+
},
|
|
38
|
+
gap: 8,
|
|
39
|
+
mt: 12,
|
|
40
|
+
children: [isEditModal && /*#__PURE__*/_jsx(FlexBox, {
|
|
41
|
+
children: /*#__PURE__*/_jsx(StrokeButton, {
|
|
42
|
+
variant: "danger",
|
|
43
|
+
onClick: handleDeleteStudyPlanClick,
|
|
44
|
+
children: "Delete"
|
|
45
|
+
})
|
|
46
|
+
}), /*#__PURE__*/_jsxs(FlexBox, {
|
|
47
|
+
children: [!isEditModal && /*#__PURE__*/_jsx(TextButton, {
|
|
48
|
+
"data-testid": "secondary-modal-cta",
|
|
49
|
+
onClick: onRequestClose,
|
|
50
|
+
mr: 12,
|
|
51
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
52
|
+
color: "black",
|
|
53
|
+
children: "Cancel"
|
|
54
|
+
})
|
|
55
|
+
}), /*#__PURE__*/_jsx(FillButton, {
|
|
56
|
+
disabled: hasStudyPlanFormInputErrors || isSaveLoading,
|
|
57
|
+
onClick: onCreateStudyPlanSave,
|
|
58
|
+
"data-testid": "primary-modal-cta",
|
|
59
|
+
children: primaryCtaText
|
|
60
|
+
})]
|
|
61
|
+
})]
|
|
62
|
+
})]
|
|
63
|
+
});
|
|
64
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StudyPlanInputValues } from '../helpers';
|
|
3
|
+
interface StudyPlanModalProps {
|
|
4
|
+
containerTimeToComplete?: number | null;
|
|
5
|
+
containerPercentComplete?: number | null;
|
|
6
|
+
containerTitle?: string | null;
|
|
7
|
+
containerType?: string;
|
|
8
|
+
handleDeleteStudyPlanClick: () => void;
|
|
9
|
+
isEditModal?: boolean;
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
isSaveLoading: boolean;
|
|
12
|
+
onCreateStudyPlanSave: () => void;
|
|
13
|
+
onRequestClose: () => void;
|
|
14
|
+
setStudyPlanInputValues: React.Dispatch<React.SetStateAction<StudyPlanInputValues>>;
|
|
15
|
+
studyPlanInputValues: StudyPlanInputValues;
|
|
16
|
+
}
|
|
17
|
+
export declare const StudyPlanModal: React.FC<StudyPlanModalProps>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Box, FlexBox, Modal, Text } from '@codecademy/gamut';
|
|
2
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import formImage from '../assets/studyPlanBanner.svg';
|
|
4
|
+
import { calculateTargetTimeFrame, calculateTimeLeftToComplete, formatContainerTimeToCompleteText, formatContainerType, formatFormErrorMessage, validateStudyPlanFormInput } from '../helpers';
|
|
5
|
+
import { StudyPlanForm } from './StudyPlanForm';
|
|
6
|
+
import { StudyPlanModalFooter } from './StudyPlanModalFooter';
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
export const StudyPlanModal = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
containerTimeToComplete,
|
|
11
|
+
containerPercentComplete,
|
|
12
|
+
containerTitle,
|
|
13
|
+
containerType = 'Course',
|
|
14
|
+
handleDeleteStudyPlanClick,
|
|
15
|
+
isEditModal,
|
|
16
|
+
isOpen,
|
|
17
|
+
isSaveLoading,
|
|
18
|
+
onCreateStudyPlanSave,
|
|
19
|
+
onRequestClose,
|
|
20
|
+
setStudyPlanInputValues,
|
|
21
|
+
studyPlanInputValues
|
|
22
|
+
} = _ref;
|
|
23
|
+
const [studyPlanInputError, setStudyPlanInputError] = useState({
|
|
24
|
+
sessionLength: undefined,
|
|
25
|
+
sessionsPerWeek: undefined
|
|
26
|
+
});
|
|
27
|
+
const hasStudyPlanFormInputErrors = !!studyPlanInputError.sessionLength || !!studyPlanInputError.sessionsPerWeek;
|
|
28
|
+
const handleStudyPlanFormInputChange = e => {
|
|
29
|
+
const {
|
|
30
|
+
name,
|
|
31
|
+
value
|
|
32
|
+
} = e.target;
|
|
33
|
+
const {
|
|
34
|
+
isValidFormInputValue
|
|
35
|
+
} = validateStudyPlanFormInput(name, value);
|
|
36
|
+
const errorMessage = formatFormErrorMessage(name, value);
|
|
37
|
+
if (!isValidFormInputValue) {
|
|
38
|
+
return setStudyPlanInputError(prev => ({
|
|
39
|
+
...prev,
|
|
40
|
+
[name]: errorMessage
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
setStudyPlanInputError(prev => ({
|
|
44
|
+
...prev,
|
|
45
|
+
[name]: undefined
|
|
46
|
+
}));
|
|
47
|
+
setStudyPlanInputValues(prev => ({
|
|
48
|
+
...prev,
|
|
49
|
+
[name]: Number(value)
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
const timeLeftToCompleteContainer = calculateTimeLeftToComplete(containerTimeToComplete, containerPercentComplete);
|
|
53
|
+
const containerTimeToCompleteText = formatContainerTimeToCompleteText(timeLeftToCompleteContainer, containerTitle);
|
|
54
|
+
const targetTimeFrameInWeeks = useMemo(() => {
|
|
55
|
+
return calculateTargetTimeFrame(studyPlanInputValues.sessionsPerWeek, studyPlanInputValues.sessionLength, containerPercentComplete, containerTimeToComplete);
|
|
56
|
+
}, [containerPercentComplete, containerTimeToComplete, studyPlanInputValues.sessionLength, studyPlanInputValues.sessionsPerWeek]);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
setStudyPlanInputValues(prev => ({
|
|
59
|
+
...prev,
|
|
60
|
+
targetTimeFrame: targetTimeFrameInWeeks * 7 // save to db as days,
|
|
61
|
+
}));
|
|
62
|
+
}, [targetTimeFrameInWeeks, setStudyPlanInputValues]);
|
|
63
|
+
const modalTitleText = `${formatContainerType(containerType)} study plan`;
|
|
64
|
+
const modalTitle = /*#__PURE__*/_jsx(Box, {
|
|
65
|
+
pb: 12,
|
|
66
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
67
|
+
children: modalTitleText
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
return /*#__PURE__*/_jsx(Modal, {
|
|
71
|
+
isOpen: isOpen,
|
|
72
|
+
onRequestClose: onRequestClose,
|
|
73
|
+
title: modalTitle,
|
|
74
|
+
size: "small",
|
|
75
|
+
children: /*#__PURE__*/_jsxs(FlexBox, {
|
|
76
|
+
height: "100%",
|
|
77
|
+
"data-testid": "study-plan-modal",
|
|
78
|
+
column: true,
|
|
79
|
+
p: 0,
|
|
80
|
+
mb: 4,
|
|
81
|
+
children: [/*#__PURE__*/_jsx(FlexBox, {
|
|
82
|
+
maxHeight: 94,
|
|
83
|
+
center: true,
|
|
84
|
+
width: "100%",
|
|
85
|
+
mb: 12,
|
|
86
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
87
|
+
width: "100%",
|
|
88
|
+
height: 94,
|
|
89
|
+
minWidth: "calc(100% + 48px)",
|
|
90
|
+
position: "relative",
|
|
91
|
+
backgroundImage: `url(${formImage})`
|
|
92
|
+
})
|
|
93
|
+
}), /*#__PURE__*/_jsxs(FlexBox, {
|
|
94
|
+
overflowY: "auto",
|
|
95
|
+
overflowX: "hidden",
|
|
96
|
+
height: "100%",
|
|
97
|
+
column: true,
|
|
98
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
99
|
+
mb: 24,
|
|
100
|
+
mt: 16,
|
|
101
|
+
children: containerTimeToCompleteText
|
|
102
|
+
}), /*#__PURE__*/_jsx(StudyPlanForm, {
|
|
103
|
+
handleInputChange: handleStudyPlanFormInputChange,
|
|
104
|
+
studyPlanInputErrorMessage: studyPlanInputError,
|
|
105
|
+
studyPlanInputValues: studyPlanInputValues,
|
|
106
|
+
targetTimeFrameInWeeks: targetTimeFrameInWeeks
|
|
107
|
+
}), /*#__PURE__*/_jsx(StudyPlanModalFooter, {
|
|
108
|
+
hasStudyPlanFormInputErrors: hasStudyPlanFormInputErrors,
|
|
109
|
+
handleDeleteStudyPlanClick: handleDeleteStudyPlanClick,
|
|
110
|
+
isEditModal: isEditModal,
|
|
111
|
+
isSaveLoading: isSaveLoading,
|
|
112
|
+
onCreateStudyPlanSave: onCreateStudyPlanSave,
|
|
113
|
+
onRequestClose: onRequestClose,
|
|
114
|
+
studyPlanInputValues: studyPlanInputValues,
|
|
115
|
+
targetTimeFrameInWeeks: targetTimeFrameInWeeks
|
|
116
|
+
})]
|
|
117
|
+
})]
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface SuggestedContentItemsSectionHeaderProps {
|
|
3
|
+
title: string;
|
|
4
|
+
totalSuggestedContentItemsProgress?: number;
|
|
5
|
+
isEnrolledSyllabus?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const SuggestedContentItemsSectionHeader: React.FC<SuggestedContentItemsSectionHeaderProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Box, FlexBox, RadialProgress, Text } from '@codecademy/gamut';
|
|
2
|
+
import { CheckIcon } from '@codecademy/gamut-icons';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
+
export const SuggestedContentItemsSectionHeader = _ref => {
|
|
6
|
+
let {
|
|
7
|
+
title,
|
|
8
|
+
totalSuggestedContentItemsProgress,
|
|
9
|
+
isEnrolledSyllabus
|
|
10
|
+
} = _ref;
|
|
11
|
+
const totalProgressAriaLabel = `Study plan suggested content progress is ${totalSuggestedContentItemsProgress}%`;
|
|
12
|
+
const isTotalProgressCompleted = totalSuggestedContentItemsProgress === 100;
|
|
13
|
+
const shouldShowTotalProgress = totalSuggestedContentItemsProgress !== undefined;
|
|
14
|
+
return /*#__PURE__*/_jsxs(FlexBox, {
|
|
15
|
+
center: true,
|
|
16
|
+
fontWeight: 700,
|
|
17
|
+
justifyContent: "flex-start",
|
|
18
|
+
gap: 16,
|
|
19
|
+
mb: isEnrolledSyllabus ? {
|
|
20
|
+
_: 8,
|
|
21
|
+
sm: 12
|
|
22
|
+
} : 12,
|
|
23
|
+
children: [shouldShowTotalProgress && /*#__PURE__*/_jsx(_Fragment, {
|
|
24
|
+
children: isTotalProgressCompleted ? /*#__PURE__*/_jsx(FlexBox, {
|
|
25
|
+
center: true,
|
|
26
|
+
dimensions: 44,
|
|
27
|
+
bg: "yellow",
|
|
28
|
+
color: "black",
|
|
29
|
+
borderRadius: "full",
|
|
30
|
+
"aria-label": "Study plan suggested content progress is 100%",
|
|
31
|
+
children: /*#__PURE__*/_jsx(CheckIcon, {
|
|
32
|
+
size: 24
|
|
33
|
+
})
|
|
34
|
+
}) : /*#__PURE__*/_jsx(Box, {
|
|
35
|
+
height: 44,
|
|
36
|
+
"aria-label": totalProgressAriaLabel,
|
|
37
|
+
children: /*#__PURE__*/_jsx(RadialProgress, {
|
|
38
|
+
"aria-hidden": true,
|
|
39
|
+
baseColor: "var(--color-paleYellow)",
|
|
40
|
+
color: "var(--color-yellow-500)",
|
|
41
|
+
size: 44,
|
|
42
|
+
value: totalSuggestedContentItemsProgress,
|
|
43
|
+
children: /*#__PURE__*/_jsx(Box, {
|
|
44
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
45
|
+
"aria-hidden": true,
|
|
46
|
+
fontSize: 14,
|
|
47
|
+
textAlign: "center",
|
|
48
|
+
children: `${totalSuggestedContentItemsProgress}%`
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
}), /*#__PURE__*/_jsx(Text, {
|
|
54
|
+
fontSize: isEnrolledSyllabus ? 22 : 20,
|
|
55
|
+
children: title
|
|
56
|
+
})]
|
|
57
|
+
});
|
|
58
|
+
};
|