@codecademy/brand 2.9.0-alpha.f019d85d25.0 → 2.9.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,13 +1,18 @@
1
1
  import { ContentContainer, FillButton, Text, TextButton } from '@codecademy/gamut';
2
- import { useState } from 'react';
2
+ import { useContext, useState } from 'react';
3
3
  import * as React from 'react';
4
4
  import { AppHeaderLink } from '../../AppHeader/AppHeaderElements/AppHeaderLink';
5
5
  import { AppHeaderLinkSections } from '../../AppHeader/AppHeaderElements/AppHeaderLinkSections';
6
- import { login, signUp } from '../../GlobalHeader/GlobalHeaderItems';
6
+ import { BlpHeroExperimentContext } from '../../GlobalHeader';
7
+ import { login, requestTeamsDemo, signUp, signUpTextButton } from '../../GlobalHeader/GlobalHeaderItems';
7
8
  import { AppHeaderSubNavMobile } from '../AppHeaderSubMenuMobile';
8
9
  import { MobileUlWrapper } from '../AppHeaderSubMenuMobile/elements';
9
10
  import { AppHeaderSubMenuRow } from '../AppHeaderSubMenuTarget';
10
11
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
12
+ const isBusinessPageExperiment = isBlpHeroExperimentVariant => {
13
+ if (typeof window === 'undefined') return false;
14
+ return window.location.pathname === '/business' && isBlpHeroExperimentVariant;
15
+ };
11
16
  export const AppHeaderMainMenuMobile = ({
12
17
  action,
13
18
  items,
@@ -16,6 +21,7 @@ export const AppHeaderMainMenuMobile = ({
16
21
  handleCloseMainMenu
17
22
  }) => {
18
23
  const [subMenuItem, setSubMenuItem] = useState();
24
+ const isBlpHeroExperimentVariant = useContext(BlpHeroExperimentContext);
19
25
  const openSubMenu = (event, item) => {
20
26
  action(event, item);
21
27
  setSubMenuItem(item);
@@ -86,7 +92,7 @@ export const AppHeaderMainMenuMobile = ({
86
92
  tabIndex: -1,
87
93
  children: /*#__PURE__*/_jsxs(MobileUlWrapper, {
88
94
  as: "ul",
89
- children: [items.map(item => mapItemToElement(item, action)), isAnon && /*#__PURE__*/_jsxs("div", {
95
+ children: [items.map(item => mapItemToElement(item, action)), isAnon && /*#__PURE__*/_jsx("div", {
90
96
  style: {
91
97
  display: 'flex',
92
98
  alignItems: 'baseline',
@@ -94,17 +100,31 @@ export const AppHeaderMainMenuMobile = ({
94
100
  paddingTop: '16px',
95
101
  borderTop: '1px solid var(--border-tertiary)'
96
102
  },
97
- children: [/*#__PURE__*/_jsx(FillButton, {
98
- "data-testid": signUp.dataTestId,
99
- href: signUp.href,
100
- onClick: event => action(event, signUp),
101
- children: signUp.text
102
- }, signUp.id), /*#__PURE__*/_jsx(TextButton, {
103
- "data-testid": login.dataTestId,
104
- href: login.href,
105
- onClick: event => action(event, login),
106
- children: login.text
107
- }, login.id)]
103
+ children: isBusinessPageExperiment(isBlpHeroExperimentVariant) ? /*#__PURE__*/_jsxs(_Fragment, {
104
+ children: [/*#__PURE__*/_jsx(TextButton, {
105
+ "data-testid": signUpTextButton.dataTestId,
106
+ href: signUpTextButton.href,
107
+ onClick: event => action(event, signUpTextButton),
108
+ children: signUpTextButton.text
109
+ }, signUpTextButton.id), /*#__PURE__*/_jsx(FillButton, {
110
+ "data-testid": requestTeamsDemo.dataTestId,
111
+ href: requestTeamsDemo.href,
112
+ onClick: event => action(event, requestTeamsDemo),
113
+ children: requestTeamsDemo.text
114
+ }, requestTeamsDemo.id)]
115
+ }) : /*#__PURE__*/_jsxs(_Fragment, {
116
+ children: [/*#__PURE__*/_jsx(FillButton, {
117
+ "data-testid": signUp.dataTestId,
118
+ href: signUp.href,
119
+ onClick: event => action(event, signUp),
120
+ children: signUp.text
121
+ }, signUp.id), /*#__PURE__*/_jsx(TextButton, {
122
+ "data-testid": login.dataTestId,
123
+ href: login.href,
124
+ onClick: event => action(event, login),
125
+ children: login.text
126
+ }, login.id)]
127
+ })
108
128
  })]
109
129
  })
110
130
  });
@@ -22,4 +22,6 @@ export declare const upgradeToPro: (checkoutUrl?: string) => AppHeaderFillButton
22
22
  export declare const unpausePro: AppHeaderFillButtonItem;
23
23
  export declare const login: AppHeaderTextButtonItem;
24
24
  export declare const signUp: AppHeaderFillButtonItem;
25
+ export declare const signUpTextButton: AppHeaderTextButtonItem;
25
26
  export declare const bootcampCta: (bootcampSlug: string) => AppHeaderFillButtonItem;
27
+ export declare const requestTeamsDemo: AppHeaderFillButtonItem;
@@ -392,6 +392,15 @@ export const signUp = {
392
392
  type: 'fill-button',
393
393
  redirect: true
394
394
  };
395
+ export const signUpTextButton = {
396
+ dataTestId: 'header-sign-up-variant',
397
+ id: 'signup',
398
+ text: 'Sign Up',
399
+ href: '/register',
400
+ trackingTarget: 'topnav_signup',
401
+ type: 'text-button',
402
+ redirect: true
403
+ };
395
404
  export const bootcampCta = bootcampSlug => ({
396
405
  dataTestId: 'bootcamp-header-cta',
397
406
  id: 'bootcamp-header-cta',
@@ -402,4 +411,12 @@ export const bootcampCta = bootcampSlug => ({
402
411
  variant: 'secondary',
403
412
  icon: MiniArrowRightIcon,
404
413
  iconPosition: 'right'
405
- });
414
+ });
415
+ export const requestTeamsDemo = {
416
+ dataTestId: 'request-teams-demo',
417
+ id: 'request-teams-demo',
418
+ text: 'Request a demo',
419
+ href: '/business/teams-quote',
420
+ trackingTarget: 'topnav_request_teams_demo',
421
+ type: 'fill-button'
422
+ };
@@ -1,8 +1,8 @@
1
1
  import { AppHeaderItem, FormattedAppHeaderItems, FormattedMobileAppHeaderItems } from '../AppHeader/shared';
2
2
  import { GlobalHeaderProps } from '.';
3
3
  import { User } from './types';
4
- export declare const anonDefaultHeaderItems: (hidePricing?: boolean, user?: User) => FormattedAppHeaderItems;
5
- export declare const anonDefaultMobileHeaderItems: (hidePricing?: boolean, user?: User) => FormattedMobileAppHeaderItems;
4
+ export declare const anonDefaultHeaderItems: (hidePricing?: boolean, user?: User, isBlpHeroExperimentVariant?: boolean) => FormattedAppHeaderItems;
5
+ export declare const anonDefaultMobileHeaderItems: (hidePricing?: boolean, user?: User, isBlpHeroExperimentVariant?: boolean) => FormattedMobileAppHeaderItems;
6
6
  export declare const anonLandingHeaderItems: (hidePricing?: boolean, user?: User) => FormattedAppHeaderItems;
7
7
  export declare const anonLandingMobileHeaderItems: (hidePricing?: boolean, user?: User) => FormattedMobileAppHeaderItems;
8
8
  export declare const anonLoginHeaderItems: (hidePricing?: boolean, user?: User) => FormattedAppHeaderItems;
@@ -1,4 +1,8 @@
1
- import { addPayment, bootcampCta, businessSolutions, catalogDropdown, communityDropdown, enterpriseLogo, freeProfile, liveLearningHub, loading, login, logo, myHome, myPercipioHome, pricingDropdown, proProfile, resourcesDropdown, signUp, simpleResourcesDropdown, tryProForFree, unpausePro, upgradePlan, upgradeToPro } from './GlobalHeaderItems';
1
+ import { addPayment, bootcampCta, businessSolutions, catalogDropdown, communityDropdown, enterpriseLogo, freeProfile, liveLearningHub, loading, login, logo, myHome, myPercipioHome, pricingDropdown, proProfile, requestTeamsDemo, resourcesDropdown, signUp, signUpTextButton, simpleResourcesDropdown, tryProForFree, unpausePro, upgradePlan, upgradeToPro } from './GlobalHeaderItems';
2
+ const isBusinessPage = isBlpHeroExperimentVariant => {
3
+ if (typeof window === 'undefined') return false;
4
+ return window.location.pathname === '/business' && Boolean(isBlpHeroExperimentVariant);
5
+ };
2
6
  const transformSimpleResourcesDropdownlabels = resourcesLabel => ({
3
7
  ...simpleResourcesDropdown,
4
8
  text: resourcesLabel?.title || simpleResourcesDropdown.text,
@@ -7,36 +11,54 @@ const transformSimpleResourcesDropdownlabels = resourcesLabel => ({
7
11
  text: resourcesLabel?.[item.id] || item.text
8
12
  }))
9
13
  });
10
- const anonHeaderItems = (renderLogin, renderSignUp, hidePricing, user) => {
14
+ const anonHeaderItems = (renderLogin, renderSignUp, hidePricing, user, isBlpHeroExperimentVariant) => {
11
15
  const specialLogo = {
12
16
  ...logo,
13
17
  checkMini: true
14
18
  };
15
19
  const leftItems = [specialLogo, catalogDropdown(user?.hideCareerPaths), resourcesDropdown(), communityDropdown(), ...(hidePricing ? [] : [pricingDropdown]), liveLearningHub, businessSolutions];
16
20
  const rightItems = [];
17
- if (renderLogin) {
18
- rightItems.push(login);
19
- }
20
- if (renderSignUp) {
21
- rightItems.push(signUp);
21
+ if (isBusinessPage(isBlpHeroExperimentVariant)) {
22
+ if (renderSignUp) {
23
+ rightItems.push(signUpTextButton);
24
+ }
25
+ if (renderLogin) {
26
+ rightItems.push(requestTeamsDemo);
27
+ }
28
+ } else {
29
+ if (renderLogin) {
30
+ rightItems.push(login);
31
+ }
32
+ if (renderSignUp) {
33
+ rightItems.push(signUp);
34
+ }
22
35
  }
23
36
  return {
24
37
  left: leftItems,
25
38
  right: rightItems
26
39
  };
27
40
  };
28
- const anonMobileHeaderItems = (renderLogin, renderSignUp, hidePricing, user) => {
41
+ const anonMobileHeaderItems = (renderLogin, renderSignUp, hidePricing, user, isBlpHeroExperimentVariant) => {
29
42
  const specialLogo = {
30
43
  ...logo,
31
44
  checkMini: true
32
45
  };
33
46
  const leftItems = [specialLogo];
34
47
  const rightItems = [];
35
- if (renderLogin) {
36
- rightItems.push(login);
37
- }
38
- if (renderSignUp) {
39
- rightItems.push(signUp);
48
+ if (isBusinessPage(isBlpHeroExperimentVariant)) {
49
+ if (renderSignUp) {
50
+ rightItems.push(signUpTextButton);
51
+ }
52
+ if (renderLogin) {
53
+ rightItems.push(requestTeamsDemo);
54
+ }
55
+ } else {
56
+ if (renderLogin) {
57
+ rightItems.push(login);
58
+ }
59
+ if (renderSignUp) {
60
+ rightItems.push(signUp);
61
+ }
40
62
  }
41
63
  const mainMenuItems = [catalogDropdown(user?.hideCareerPaths), resourcesDropdown(), communityDropdown(), ...(hidePricing ? [] : [pricingDropdown]), liveLearningHub, businessSolutions];
42
64
  return {
@@ -45,11 +67,11 @@ const anonMobileHeaderItems = (renderLogin, renderSignUp, hidePricing, user) =>
45
67
  mainMenu: mainMenuItems
46
68
  };
47
69
  };
48
- export const anonDefaultHeaderItems = (hidePricing, user) => {
49
- return anonHeaderItems(true, true, hidePricing, user);
70
+ export const anonDefaultHeaderItems = (hidePricing, user, isBlpHeroExperimentVariant) => {
71
+ return anonHeaderItems(true, true, hidePricing, user, isBlpHeroExperimentVariant);
50
72
  };
51
- export const anonDefaultMobileHeaderItems = (hidePricing, user) => {
52
- return anonMobileHeaderItems(true, true, hidePricing, user);
73
+ export const anonDefaultMobileHeaderItems = (hidePricing, user, isBlpHeroExperimentVariant) => {
74
+ return anonMobileHeaderItems(true, true, hidePricing, user, isBlpHeroExperimentVariant);
53
75
  };
54
76
  export const anonLandingHeaderItems = (hidePricing, user) => {
55
77
  return anonHeaderItems(true, false, hidePricing, user);
@@ -7,5 +7,6 @@ export declare const HeaderQuizContext: React.Context<{
7
7
  showSortingQuiz?: boolean;
8
8
  }>;
9
9
  export declare const GlobalNavRedesignContext: React.Context<boolean>;
10
+ export declare const BlpHeroExperimentContext: React.Context<boolean>;
10
11
  export type GlobalHeaderProps = AnonHeader | FreeHeader | ProHeader | EnterpriseHeader | TeamsHeader | LoadingHeader | SimpleHeader | SimpleBootcampHeader;
11
12
  export declare const GlobalHeader: React.FC<GlobalHeaderProps>;
@@ -13,6 +13,7 @@ export const HeaderQuizContext = /*#__PURE__*/React.createContext({
13
13
  showSortingQuiz: false
14
14
  });
15
15
  export const GlobalNavRedesignContext = /*#__PURE__*/React.createContext(false);
16
+ export const BlpHeroExperimentContext = /*#__PURE__*/React.createContext(false);
16
17
 
17
18
  // Overloading getAppHeaderItems function to return different types based on mobile parameter
18
19
 
@@ -30,7 +31,7 @@ function getAppHeaderItems(props, mobile) {
30
31
  case 'signup':
31
32
  return mobile ? anonSignupMobileHeaderItems(hidePricing, props.user) : anonSignupHeaderItems(hidePricing, props.user);
32
33
  default:
33
- return mobile ? anonDefaultMobileHeaderItems(hidePricing, props.user) : anonDefaultHeaderItems(hidePricing, props.user);
34
+ return mobile ? anonDefaultMobileHeaderItems(hidePricing, props.user, props.isBlpHeroExperimentVariant) : anonDefaultHeaderItems(hidePricing, props.user, props.isBlpHeroExperimentVariant);
34
35
  }
35
36
  case 'enterprise':
36
37
  return mobile ? enterpriseMobileHeaderItems(props.user, props) : enterpriseHeaderItems(props.user, props);
@@ -68,47 +69,50 @@ export const GlobalHeader = props => {
68
69
  },
69
70
  children: /*#__PURE__*/_jsx(GlobalNavRedesignContext.Provider, {
70
71
  value: !!props.displayGlobalNavRedesign,
71
- children: /*#__PURE__*/_jsx(GlobalHeaderItemClickContext.Provider, {
72
- value: {
73
- globalHeaderItemClick: combinedAction
74
- },
75
- children: /*#__PURE__*/_jsxs(Box, {
76
- as: "header",
77
- position: "sticky",
78
- top: 0,
79
- zIndex: theme.elements.headerZ,
80
- overflow: {
81
- _: 'hidden',
82
- sm: 'visible'
83
- } // Prevent tooltip overflow on mobile
84
- ,
85
- children: [/*#__PURE__*/_jsx(AppHeader, {
86
- action: combinedAction,
87
- items: getAppHeaderItems(props, false),
88
- search: props.search,
89
- ...(props.type === 'anon' ? {
90
- redirectParam: props.redirectParam
91
- } : hideNotification ? {} : {
92
- notifications: props.notifications
93
- }),
94
- hideRightButtonDefaults: hideNotification,
95
- isAnon: props.type === 'anon',
96
- isTeams: props.type === 'teams',
97
- type: hideNotification ? 'enterprise' : 'standard'
98
- }), /*#__PURE__*/_jsx(AppHeaderMobile, {
99
- action: combinedAction,
100
- items: getAppHeaderItems(props, true),
101
- ...(props.type === 'anon' || hideNotification ? {} : {
102
- notifications: props.notifications
103
- }),
104
- search: props.search,
105
- redirectParam: props.type === 'anon' ? props.redirectParam : undefined,
106
- isEnterprise: props.type === 'enterprise',
107
- isAnon: props.type === 'anon',
108
- isSimple: props.type === 'simple',
109
- hideRightMenuButton: props.type === 'simple' || props.type === 'loading',
110
- navigationMenuFormattedLabel: props?.localizedLabels?.navigationMenuFormattedLabel
111
- }), props.children]
72
+ children: /*#__PURE__*/_jsx(BlpHeroExperimentContext.Provider, {
73
+ value: !!props.isBlpHeroExperimentVariant,
74
+ children: /*#__PURE__*/_jsx(GlobalHeaderItemClickContext.Provider, {
75
+ value: {
76
+ globalHeaderItemClick: combinedAction
77
+ },
78
+ children: /*#__PURE__*/_jsxs(Box, {
79
+ as: "header",
80
+ position: "sticky",
81
+ top: 0,
82
+ zIndex: theme.elements.headerZ,
83
+ overflow: {
84
+ _: 'hidden',
85
+ sm: 'visible'
86
+ } // Prevent tooltip overflow on mobile
87
+ ,
88
+ children: [/*#__PURE__*/_jsx(AppHeader, {
89
+ action: combinedAction,
90
+ items: getAppHeaderItems(props, false),
91
+ search: props.search,
92
+ ...(props.type === 'anon' ? {
93
+ redirectParam: props.redirectParam
94
+ } : hideNotification ? {} : {
95
+ notifications: props.notifications
96
+ }),
97
+ hideRightButtonDefaults: hideNotification,
98
+ isAnon: props.type === 'anon',
99
+ isTeams: props.type === 'teams',
100
+ type: hideNotification ? 'enterprise' : 'standard'
101
+ }), /*#__PURE__*/_jsx(AppHeaderMobile, {
102
+ action: combinedAction,
103
+ items: getAppHeaderItems(props, true),
104
+ ...(props.type === 'anon' || hideNotification ? {} : {
105
+ notifications: props.notifications
106
+ }),
107
+ search: props.search,
108
+ redirectParam: props.type === 'anon' ? props.redirectParam : undefined,
109
+ isEnterprise: props.type === 'enterprise',
110
+ isAnon: props.type === 'anon',
111
+ isSimple: props.type === 'simple',
112
+ hideRightMenuButton: props.type === 'simple' || props.type === 'loading',
113
+ navigationMenuFormattedLabel: props?.localizedLabels?.navigationMenuFormattedLabel
114
+ }), props.children]
115
+ })
112
116
  })
113
117
  })
114
118
  })
@@ -31,6 +31,7 @@ interface BaseHeader extends WithChildrenProp, AppHeaderAction {
31
31
  localizedLabels?: localizedLabels;
32
32
  search: AppHeaderSearch;
33
33
  displayGlobalNavRedesign?: boolean;
34
+ isBlpHeroExperimentVariant?: boolean;
34
35
  }
35
36
  export type User = {
36
37
  avatar: string;
package/dist/index.d.ts CHANGED
@@ -27,7 +27,6 @@ export * from './ContentGroupBaseCard';
27
27
  export * from './ContentGroupBaseCard/types';
28
28
  export * from './ContentGroupBaseCard/helpers';
29
29
  export * from './CourseCard';
30
- export * from './CourseRecommendationsLink';
31
30
  export * from './CurriculumCard';
32
31
  export * from './CurriculumCard/Difficulty';
33
32
  export * from './CurriculumCard/Difficulty/types';
package/dist/index.js CHANGED
@@ -27,7 +27,6 @@ export * from './ContentGroupBaseCard';
27
27
  export * from './ContentGroupBaseCard/types';
28
28
  export * from './ContentGroupBaseCard/helpers';
29
29
  export * from './CourseCard';
30
- export * from './CourseRecommendationsLink';
31
30
  export * from './CurriculumCard';
32
31
  export * from './CurriculumCard/Difficulty';
33
32
  export * from './CurriculumCard/Difficulty/types';
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.9.0-alpha.f019d85d25.0",
4
+ "version": "2.9.0",
5
5
  "author": "Codecademy Engineering <dev@codecademy.com>",
6
6
  "dependencies": {
7
7
  "@emotion/is-prop-valid": "^1.2.1",
@@ -1,3 +0,0 @@
1
- export declare const CourseRecommendationsLink: React.FC<{
2
- onClick?: () => void;
3
- }>;
@@ -1,27 +0,0 @@
1
- import { FillButton, FlexBox, Text } from '@codecademy/gamut';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- export const CourseRecommendationsLink = ({
4
- onClick
5
- }) => /*#__PURE__*/_jsxs(FlexBox, {
6
- column: true,
7
- p: 16,
8
- bg: "navy-100",
9
- border: 1,
10
- borderColor: "border-tertiary",
11
- borderRadius: "lg",
12
- children: [/*#__PURE__*/_jsx(Text, {
13
- variant: "p-large",
14
- fontWeight: "bold",
15
- children: "Get personalized course recommendations"
16
- }), /*#__PURE__*/_jsx(Text, {
17
- variant: "p-base",
18
- mt: 8,
19
- children: "Answer a few quick questions about your interests and skill level. We\u2019ll create a custom list of courses just for you."
20
- }), /*#__PURE__*/_jsx(FillButton, {
21
- size: "small",
22
- mt: 16,
23
- href: "/welcome/find-a-course",
24
- onClick: onClick,
25
- children: "Take the quiz"
26
- })]
27
- });