@codecademy/brand 0.13.37 → 0.13.38-alpha.6dbb02c273.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.
@@ -1,18 +0,0 @@
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 {};
@@ -1,120 +0,0 @@
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
- };
@@ -1,8 +0,0 @@
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 {};
@@ -1,58 +0,0 @@
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
- };