@codecademy/brand 2.3.0-alpha.e4b81367fe.0 → 2.4.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.
Files changed (52) hide show
  1. package/dist/AppHeader/AppHeaderElements/AppHeaderCatalogSection/elements.d.ts +5 -0
  2. package/dist/AppHeader/AppHeaderElements/AppHeaderCatalogSection/elements.js +56 -12
  3. package/dist/AppHeader/AppHeaderElements/AppHeaderCatalogSection/index.js +5 -3
  4. package/dist/CareerPathCard/index.d.ts +1 -4
  5. package/dist/CareerPathCard/index.js +7 -15
  6. package/dist/CertificationPathCard/index.d.ts +1 -4
  7. package/dist/CertificationPathCard/index.js +9 -17
  8. package/dist/ContentGroupBaseCard/index.d.ts +3 -5
  9. package/dist/ContentGroupBaseCard/index.js +72 -129
  10. package/dist/ContentGroupBaseCard/shared.js +23 -29
  11. package/dist/CourseCard/index.d.ts +1 -4
  12. package/dist/CourseCard/index.js +11 -15
  13. package/dist/GlobalHeader/GlobalHeaderItems.js +1 -1
  14. package/dist/GlobalHeader/index.d.ts +1 -0
  15. package/dist/GlobalHeader/index.js +41 -37
  16. package/dist/GlobalHeader/types.d.ts +1 -0
  17. package/dist/Recurly/context/NoProvider.d.ts +8 -0
  18. package/dist/Recurly/context/NoProvider.js +7 -0
  19. package/dist/Recurly/context/elements/index.d.ts +26 -0
  20. package/dist/Recurly/context/elements/index.js +46 -0
  21. package/dist/Recurly/context/elements/index.test.js +88 -0
  22. package/dist/Recurly/context/index.d.ts +2 -0
  23. package/dist/Recurly/context/index.js +2 -0
  24. package/dist/Recurly/context/recurly/index.d.ts +30 -0
  25. package/dist/Recurly/context/recurly/index.js +50 -0
  26. package/dist/Recurly/context/recurly/index.test.js +63 -0
  27. package/dist/Recurly/context/recurly/loadRecurly.d.ts +6 -0
  28. package/dist/Recurly/context/recurly/loadRecurly.js +22 -0
  29. package/dist/Recurly/context/recurly/loadRecurly.test.js +57 -0
  30. package/dist/Recurly/context/recurly/w.d.ts +14 -0
  31. package/dist/Recurly/context/recurly/w.js +4 -0
  32. package/dist/Recurly/fields/RecurlyField.d.ts +9 -0
  33. package/dist/Recurly/fields/RecurlyField.js +57 -0
  34. package/dist/Recurly/fields/elements.d.ts +17 -0
  35. package/dist/Recurly/fields/elements.js +106 -0
  36. package/dist/Recurly/fields/elements.test.js +79 -0
  37. package/dist/Recurly/fields/index.d.ts +2 -0
  38. package/dist/Recurly/fields/index.js +2 -0
  39. package/dist/Recurly/index.d.ts +2 -0
  40. package/dist/Recurly/index.js +2 -0
  41. package/dist/SkillPathCard/index.d.ts +1 -4
  42. package/dist/SkillPathCard/index.js +7 -15
  43. package/dist/index.d.ts +1 -0
  44. package/dist/index.js +1 -0
  45. package/dist/stories/Molecules/ContentGroupBaseCard.stories.js +1 -3
  46. package/dist/stories/Molecules/CurriculumCards/CareerPathCard.stories.js +1 -3
  47. package/dist/stories/Molecules/CurriculumCards/CertificationPathCard.stories.js +1 -3
  48. package/dist/stories/Molecules/CurriculumCards/CourseCard.stories.js +1 -3
  49. package/dist/stories/Molecules/CurriculumCards/SkillPathCard.stories.js +1 -3
  50. package/dist/stories/Molecules/Recurly.stories.d.ts +5 -0
  51. package/dist/stories/Molecules/Recurly.stories.js +56 -0
  52. package/package.json +1 -1
@@ -0,0 +1,79 @@
1
+ import { setupRtl } from '@codecademy/gamut-tests';
2
+ import { render } from '@testing-library/react';
3
+ import { CardNumber } from './elements';
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ class MockElement {
6
+ attach = jest.fn();
7
+ handlers = {};
8
+ on = jest.fn((evt, handler) => {
9
+ this.handlers[evt] = handler;
10
+ });
11
+ configure = jest.fn();
12
+ destroy = jest.fn();
13
+ focus = jest.fn();
14
+ }
15
+ const mockElements = {};
16
+ jest.mock('../context', () => ({
17
+ useElements: jest.fn(() => mockElements)
18
+ }));
19
+ describe('CardNumber', () => {
20
+ it('creates the Recurly element and attaches it to the DOM', () => {
21
+ const mockElement = new MockElement();
22
+ mockElements.CardNumberElement = jest.fn(() => mockElement);
23
+ const renderView = setupRtl(CardNumber);
24
+ renderView();
25
+ expect(mockElements.CardNumberElement).toHaveBeenCalled();
26
+ expect(mockElement.attach).toHaveBeenCalled();
27
+ });
28
+ it('sets and updates event handlers', () => {
29
+ const mockElement = new MockElement();
30
+ mockElements.CardNumberElement = () => mockElement;
31
+ const renderView = setupRtl(CardNumber);
32
+ const createHandlers = () => ({
33
+ onReady: jest.fn(),
34
+ onChange: jest.fn(),
35
+ onBlur: jest.fn(),
36
+ onFocus: jest.fn(),
37
+ onSubmit: jest.fn()
38
+ });
39
+ const handlersA = createHandlers();
40
+ const {
41
+ update
42
+ } = renderView(handlersA);
43
+ for (const handler of Object.values(mockElement.handlers)) {
44
+ handler('test-1');
45
+ }
46
+ const handlersB = createHandlers();
47
+ update(handlersB);
48
+ for (const handler of Object.values(mockElement.handlers)) {
49
+ handler('test-2');
50
+ }
51
+ for (const handler of Object.values(handlersA)) {
52
+ expect(handler).toHaveBeenCalledTimes(1);
53
+ expect(handler).toHaveBeenCalledWith('test-1');
54
+ }
55
+ for (const handler of Object.values(handlersB)) {
56
+ expect(handler).toHaveBeenCalledTimes(1);
57
+ expect(handler).toHaveBeenCalledWith('test-2');
58
+ }
59
+ });
60
+ it('allows focus from the outside via ref', () => {
61
+ const mockElement = new MockElement();
62
+ mockElements.CardNumberElement = jest.fn(() => mockElement);
63
+ const ref = {};
64
+ render(/*#__PURE__*/_jsx(CardNumber, {
65
+ ref: ref
66
+ }));
67
+ ref.current?.focus();
68
+ expect(mockElement.focus).toHaveBeenCalled();
69
+ });
70
+ it('destroys the Recurly element when the component unmounts', () => {
71
+ const mockElement = new MockElement();
72
+ mockElements.CardNumberElement = jest.fn(() => mockElement);
73
+ const {
74
+ unmount
75
+ } = render(/*#__PURE__*/_jsx(CardNumber, {}));
76
+ unmount();
77
+ expect(mockElement.destroy).toHaveBeenCalled();
78
+ });
79
+ });
@@ -0,0 +1,2 @@
1
+ export * from './elements';
2
+ export * from './RecurlyField';
@@ -0,0 +1,2 @@
1
+ export * from './elements';
2
+ export * from './RecurlyField';
@@ -0,0 +1,2 @@
1
+ export * from './fields';
2
+ export { Elements, RecurlyProvider, useRecurly } from './context';
@@ -0,0 +1,2 @@
1
+ export * from './fields';
2
+ export { Elements, RecurlyProvider, useRecurly } from './context';
@@ -13,8 +13,5 @@ export interface SkillPathCardProps {
13
13
  timeToComplete?: number | null;
14
14
  header?: React.ReactNode;
15
15
  footer?: React.ReactNode;
16
- openInNewTab?: boolean;
17
- href: string;
18
- onClick: () => void;
19
16
  }
20
- export declare const SkillPathCard: import("react").ForwardRefExoticComponent<SkillPathCardProps & import("react").RefAttributes<HTMLAnchorElement>>;
17
+ export declare const SkillPathCard: React.FC<SkillPathCardProps>;
@@ -1,9 +1,8 @@
1
- import { forwardRef } from 'react';
2
1
  import { ContentGroupBaseCard } from '../ContentGroupBaseCard';
3
2
  import { getPathImageUrl } from '../ContentGroupBaseCard/helpers';
4
- import { CertificateComponent, CourseCountComponent } from '../ContentGroupBaseCard/shared';
3
+ import { CertificateComponent, CourseCountComponent, Divider } from '../ContentGroupBaseCard/shared';
5
4
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
- export const SkillPathCard = /*#__PURE__*/forwardRef(({
5
+ export const SkillPathCard = ({
7
6
  title,
8
7
  shortDescription,
9
8
  difficulty,
@@ -15,11 +14,8 @@ export const SkillPathCard = /*#__PURE__*/forwardRef(({
15
14
  isFullSize = false,
16
15
  timeToComplete,
17
16
  header,
18
- footer,
19
- openInNewTab = false,
20
- href,
21
- onClick
22
- }, ref) => {
17
+ footer
18
+ }) => {
23
19
  return /*#__PURE__*/_jsxs(ContentGroupBaseCard, {
24
20
  headerBackgroundColor: "blue-100",
25
21
  headerText: "Skill path",
@@ -35,12 +31,8 @@ export const SkillPathCard = /*#__PURE__*/forwardRef(({
35
31
  timeToComplete: timeToComplete,
36
32
  header: header,
37
33
  footer: footer,
38
- openInNewTab: openInNewTab,
39
- href: href,
40
- onClick: onClick,
41
- ref: ref,
42
- children: [/*#__PURE__*/_jsx(CourseCountComponent, {
34
+ children: [/*#__PURE__*/_jsx(Divider, {}), /*#__PURE__*/_jsx(CourseCountComponent, {
43
35
  count: courseCount
44
- }), /*#__PURE__*/_jsx(CertificateComponent, {})]
36
+ }), /*#__PURE__*/_jsx(Divider, {}), /*#__PURE__*/_jsx(CertificateComponent, {})]
45
37
  });
46
- });
38
+ };
package/dist/index.d.ts CHANGED
@@ -71,6 +71,7 @@ export * from './PricingSection';
71
71
  export * from './ProductFeatureShowcase';
72
72
  export * from './ProLogoAlt';
73
73
  export * from './RatingsBar';
74
+ export * from './Recurly';
74
75
  export * from './ResourceCard';
75
76
  export * from './ScoreSummary';
76
77
  export * from './ScoreSummary/SubScores';
package/dist/index.js CHANGED
@@ -71,6 +71,7 @@ export * from './PricingSection';
71
71
  export * from './ProductFeatureShowcase';
72
72
  export * from './ProLogoAlt';
73
73
  export * from './RatingsBar';
74
+ export * from './Recurly';
74
75
  export * from './ResourceCard';
75
76
  export * from './ScoreSummary';
76
77
  export * from './ScoreSummary/SubScores';
@@ -8,9 +8,7 @@ const meta = {
8
8
  headerBackgroundColor: 'pink',
9
9
  headerText: 'Course',
10
10
  title: 'Python 101',
11
- numLessons: 20,
12
- href: '/learn/python-101',
13
- onClick: () => {}
11
+ numLessons: 20
14
12
  }
15
13
  };
16
14
  export default meta;
@@ -9,9 +9,7 @@ const meta = {
9
9
  difficulty: CourseDifficulty.Beginner,
10
10
  title: 'Python 101',
11
11
  imageUrl: 'https://static-assets.codecademy.com/components/curriculum/path/front-end-engineer-career-path/curriculum-card.svg',
12
- timeToComplete: 15,
13
- href: '/learn/paths/python-101',
14
- onClick: () => {}
12
+ timeToComplete: 15
15
13
  }
16
14
  };
17
15
  export default meta;
@@ -7,9 +7,7 @@ const meta = {
7
7
  title: 'CLF-C02: AWS Certified Cloud Practitioner',
8
8
  courseCount: 16,
9
9
  shortDescription: 'Master AWS Cloud fundamentals, security, and migration strategies to prepare for the AWS Certified Cloud Practitioner exam (CLF-C02) and enhance your cloud skills.',
10
- difficulty: CourseDifficulty.Beginner,
11
- href: '/learn/ext-paths/certification-prep-clf-c02',
12
- onClick: () => {}
10
+ difficulty: CourseDifficulty.Beginner
13
11
  }
14
12
  };
15
13
  export default meta;
@@ -9,9 +9,7 @@ const meta = {
9
9
  pro: false,
10
10
  shortDescription: 'Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.',
11
11
  difficulty: CourseDifficulty.Beginner,
12
- timeToComplete: 3,
13
- href: '/learn/javascript',
14
- onClick: () => {}
12
+ timeToComplete: 3
15
13
  }
16
14
  };
17
15
  export default meta;
@@ -9,9 +9,7 @@ const meta = {
9
9
  shortDescription: 'Web applications are constantly under threat. Authentication and authorization, protected data, and secure code will protect your web app.',
10
10
  difficulty: CourseDifficulty.Intermediate,
11
11
  imageUrl: 'https://static-assets.codecademy.com/components/curriculum/path/securing-express-applications/curriculum-card.svg',
12
- timeToComplete: 10,
13
- href: '/learn/paths/securing-express-applications',
14
- onClick: () => {}
12
+ timeToComplete: 10
15
13
  }
16
14
  };
17
15
  export default meta;
@@ -0,0 +1,5 @@
1
+ import type { StoryObj } from '@storybook/react';
2
+ declare const _default: {};
3
+ export default _default;
4
+ export declare const Default: StoryObj;
5
+ export declare const RecurlyFieldStory: StoryObj;
@@ -0,0 +1,56 @@
1
+ import { GridBox, Text } from '@codecademy/gamut';
2
+ import { CardNumber, CVV, Elements, ExpMonth, ExpYear, RecurlyField, RecurlyProvider } from '../../index';
3
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
4
+ export default {};
5
+ export const Default = {
6
+ render: () => /*#__PURE__*/_jsx(RecurlyProvider, {
7
+ publicKey: "test-key",
8
+ required: [],
9
+ children: /*#__PURE__*/_jsx(Elements, {
10
+ children: /*#__PURE__*/_jsxs(GridBox, {
11
+ gridTemplateColumns: "2fr 1fr 1fr",
12
+ gap: 16,
13
+ children: [/*#__PURE__*/_jsx(RecurlyField, {
14
+ label: "Card number*",
15
+ children: /*#__PURE__*/_jsx(CardNumber, {})
16
+ }), /*#__PURE__*/_jsxs(RecurlyField, {
17
+ label: "Expiration date*",
18
+ children: [/*#__PURE__*/_jsx(ExpMonth, {}), /*#__PURE__*/_jsx(ExpYear, {})]
19
+ }), /*#__PURE__*/_jsx(RecurlyField, {
20
+ label: "CVV*",
21
+ children: /*#__PURE__*/_jsx(CVV, {})
22
+ })]
23
+ })
24
+ })
25
+ })
26
+ };
27
+ export const RecurlyFieldStory = {
28
+ render: () => /*#__PURE__*/_jsx(RecurlyProvider, {
29
+ publicKey: "test-key",
30
+ required: [],
31
+ children: /*#__PURE__*/_jsx(Elements, {
32
+ children: /*#__PURE__*/_jsxs(GridBox, {
33
+ gridTemplateColumns: "4rem 1fr",
34
+ gap: 16,
35
+ children: [/*#__PURE__*/_jsx(Text, {
36
+ variant: "title-xs",
37
+ alignSelf: "center",
38
+ children: "Error"
39
+ }), /*#__PURE__*/_jsx(RecurlyField, {
40
+ label: "Card number*",
41
+ error: true,
42
+ children: /*#__PURE__*/_jsx(CardNumber, {})
43
+ }), /*#__PURE__*/_jsx(Text, {
44
+ variant: "title-xs",
45
+ alignSelf: "center",
46
+ children: "Valid"
47
+ }), /*#__PURE__*/_jsx(RecurlyField, {
48
+ label: "Card number*",
49
+ valid: true,
50
+ children: /*#__PURE__*/_jsx(CardNumber, {})
51
+ })]
52
+ })
53
+ })
54
+ }),
55
+ name: 'Validation'
56
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@codecademy/brand",
3
3
  "description": "Brand component library for Codecademy",
4
- "version": "2.3.0-alpha.e4b81367fe.0",
4
+ "version": "2.4.0",
5
5
  "author": "Codecademy Engineering <dev@codecademy.com>",
6
6
  "dependencies": {
7
7
  "@emotion/is-prop-valid": "^1.2.1",