@codecademy/brand 0.13.38-alpha.8ed52557eb.0 → 0.13.38
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/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,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
|
+
};
|