@codecademy/brand 3.14.0-alpha.0674fecdc1.0 → 3.14.0-alpha.21505a76bc.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.
@@ -3,18 +3,13 @@ import { useTheme } from '@emotion/react';
3
3
  import * as React from 'react';
4
4
  import { useCallback, useMemo } from 'react';
5
5
  import { AppHeader, AppHeaderMobile, isAppHeaderItemWithHref } from '..';
6
- import { GlobalHeaderDynamicDataContext, GlobalHeaderItemClickContext } from './context';
6
+ import { GlobalHeaderDynamicDataContext, GlobalHeaderItemClickContext, HeaderDisplayContext } from './context';
7
7
  import { anonDefaultHeaderItems, anonDefaultMobileHeaderItems, anonLandingHeaderItems, anonLandingMobileHeaderItems, anonLoginHeaderItems, anonLoginMobileHeaderItems, anonSignupHeaderItems, anonSignupMobileHeaderItems, enterpriseHeaderItems, enterpriseMobileHeaderItems, freeHeaderItems, freeMobileHeaderItems, loadingHeaderItems, loadingMobileHeaderItems, proHeaderItems, proMobileHeaderItems, simpleBootcampHeaderItems, simpleBootcampMobileHeaderItems, simpleHeaderItems, simpleMobileHeaderItems, teamsHeaderItems, teamsMobileHeaderItems } from './GlobalHeaderVariants';
8
8
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
9
9
  export * from './types';
10
10
  export const LiveLearningHubContext = /*#__PURE__*/React.createContext(false);
11
- export const HeaderQuizContext = /*#__PURE__*/React.createContext({
12
- showOnboardingQuiz: false,
13
- showSortingQuiz: false
14
- });
15
11
  export const GlobalNavRedesignContext = /*#__PURE__*/React.createContext(false);
16
12
  export const BlpHeroExperimentContext = /*#__PURE__*/React.createContext(false);
17
- export const RevampedBlpExperimentContext = /*#__PURE__*/React.createContext(false);
18
13
 
19
14
  // Overloading getAppHeaderItems function to return different types based on mobile parameter
20
15
 
@@ -29,18 +24,18 @@ function getAppHeaderItems(props, mobile, dynamicDataLoading) {
29
24
  case 'anon':
30
25
  switch (props.variant) {
31
26
  case 'landing':
32
- return mobile ? anonLandingMobileHeaderItems(hidePricing, props.user, props.isInRevampedBlpExperimentVariant) : anonLandingHeaderItems(hidePricing, props.user, props.isInRevampedBlpExperimentVariant);
27
+ return mobile ? anonLandingMobileHeaderItems(hidePricing, props.user) : anonLandingHeaderItems(hidePricing, props.user);
33
28
  case 'login':
34
- return mobile ? anonLoginMobileHeaderItems(hidePricing, props.user, props.isInRevampedBlpExperimentVariant) : anonLoginHeaderItems(hidePricing, props.user, props.isInRevampedBlpExperimentVariant);
29
+ return mobile ? anonLoginMobileHeaderItems(hidePricing, props.user) : anonLoginHeaderItems(hidePricing, props.user);
35
30
  case 'signup':
36
- return mobile ? anonSignupMobileHeaderItems(hidePricing, props.user, props.isInRevampedBlpExperimentVariant) : anonSignupHeaderItems(hidePricing, props.user, props.isInRevampedBlpExperimentVariant);
31
+ return mobile ? anonSignupMobileHeaderItems(hidePricing, props.user) : anonSignupHeaderItems(hidePricing, props.user);
37
32
  default:
38
- return mobile ? anonDefaultMobileHeaderItems(hidePricing, props.user, props.isBlpHeroExperimentVariant, props.isInRevampedBlpExperimentVariant) : anonDefaultHeaderItems(hidePricing, props.user, props.isBlpHeroExperimentVariant, props.isInRevampedBlpExperimentVariant);
33
+ return mobile ? anonDefaultMobileHeaderItems(hidePricing, props.user, props.isBlpHeroExperimentVariant) : anonDefaultHeaderItems(hidePricing, props.user, props.isBlpHeroExperimentVariant);
39
34
  }
40
35
  case 'enterprise':
41
36
  return mobile ? enterpriseMobileHeaderItems(props.user, props) : enterpriseHeaderItems(props.user, props);
42
37
  case 'free':
43
- return mobile ? freeMobileHeaderItems(props.user, hidePricing, props.isInRevampedBlpExperimentVariant) : freeHeaderItems(props.user, hidePricing, props.isInRevampedBlpExperimentVariant);
38
+ return mobile ? freeMobileHeaderItems(props.user, hidePricing) : freeHeaderItems(props.user, hidePricing);
44
39
  case 'pro':
45
40
  return mobile ? proMobileHeaderItems(props.user) : proHeaderItems(props.user);
46
41
  case 'teams':
@@ -68,63 +63,78 @@ export const GlobalHeader = props => {
68
63
  const hideNotification = props.type === 'loading' || props.type === 'enterprise' || props.type === 'simple' || props.type === 'bootcamp';
69
64
  const showOnboardingQuiz = props.type === 'anon' || (props.type === 'free' || props.type === 'pro') && !props.user.enrolledInTwoOrMoreContainers;
70
65
  const showSortingQuiz = (props.type === 'free' || props.type === 'pro') && props.user.enrolledInTwoOrMoreContainers;
71
- return /*#__PURE__*/_jsx(HeaderQuizContext.Provider, {
66
+
67
+ // other header types are not part of the experiment
68
+ const getNarrowResourceDropdownPosition = headerType => {
69
+ if (headerType === 'free') return -14.5;
70
+ if (headerType === 'anon') return -9.5;
71
+ if (headerType === 'pro' || headerType === 'teams') return -19.5;
72
+ return 0;
73
+ };
74
+ const getWideResourceDropdownPosition = headerType => {
75
+ if (headerType === 'free') return -19.5;
76
+ if (headerType === 'anon') return -14.5;
77
+ if (headerType === 'pro' || headerType === 'teams') return -19.5;
78
+ return 0;
79
+ };
80
+ const narrowResourceDropdownPosition = getNarrowResourceDropdownPosition(props.type);
81
+ const wideResourceDropdownPosition = getWideResourceDropdownPosition(props.type);
82
+ return /*#__PURE__*/_jsx(HeaderDisplayContext.Provider, {
72
83
  value: {
73
84
  showOnboardingQuiz,
74
- showSortingQuiz
85
+ showSortingQuiz,
86
+ narrowResourceDropdownPosition,
87
+ wideResourceDropdownPosition
75
88
  },
76
89
  children: /*#__PURE__*/_jsx(GlobalNavRedesignContext.Provider, {
77
90
  value: !!props.displayGlobalNavRedesign,
78
91
  children: /*#__PURE__*/_jsx(BlpHeroExperimentContext.Provider, {
79
92
  value: !!props.isBlpHeroExperimentVariant,
80
- children: /*#__PURE__*/_jsx(RevampedBlpExperimentContext.Provider, {
81
- value: !!props.isInRevampedBlpExperimentVariant,
82
- children: /*#__PURE__*/_jsx(GlobalHeaderItemClickContext.Provider, {
83
- value: {
84
- globalHeaderItemClick: combinedAction
85
- },
86
- children: /*#__PURE__*/_jsx(GlobalHeaderDynamicDataContext.Provider, {
87
- value: useMemo(() => ({
88
- globalHeaderDynamicData: dynamicData ?? null
89
- }), [dynamicData]),
90
- children: /*#__PURE__*/_jsxs(Box, {
91
- as: "header",
92
- position: "sticky",
93
- top: 0,
94
- zIndex: theme.elements.headerZ,
95
- overflow: {
96
- _: 'hidden',
97
- sm: 'visible'
98
- } // Prevent tooltip overflow on mobile
99
- ,
100
- children: [/*#__PURE__*/_jsx(AppHeader, {
101
- action: combinedAction,
102
- items: getAppHeaderItems(props, false, dynamicDataLoading ?? false),
103
- search: props.search,
104
- ...(props.type === 'anon' ? {
105
- redirectParam: props.redirectParam
106
- } : hideNotification ? {} : {
107
- notifications: props.notifications
108
- }),
109
- hideRightButtonDefaults: hideNotification,
110
- isAnon: props.type === 'anon',
111
- isTeams: props.type === 'teams',
112
- type: hideNotification ? 'enterprise' : 'standard'
113
- }), /*#__PURE__*/_jsx(AppHeaderMobile, {
114
- action: combinedAction,
115
- items: getAppHeaderItems(props, true, dynamicDataLoading ?? false),
116
- ...(props.type === 'anon' || hideNotification ? {} : {
117
- notifications: props.notifications
118
- }),
119
- search: props.search,
120
- redirectParam: props.type === 'anon' ? props.redirectParam : undefined,
121
- isEnterprise: props.type === 'enterprise',
122
- isAnon: props.type === 'anon',
123
- isSimple: props.type === 'simple',
124
- hideRightMenuButton: props.type === 'simple' || props.type === 'loading',
125
- navigationMenuFormattedLabel: props?.localizedLabels?.navigationMenuFormattedLabel
126
- }), props.children]
127
- })
93
+ children: /*#__PURE__*/_jsx(GlobalHeaderItemClickContext.Provider, {
94
+ value: {
95
+ globalHeaderItemClick: combinedAction
96
+ },
97
+ children: /*#__PURE__*/_jsx(GlobalHeaderDynamicDataContext.Provider, {
98
+ value: useMemo(() => ({
99
+ globalHeaderDynamicData: dynamicData ?? null
100
+ }), [dynamicData]),
101
+ children: /*#__PURE__*/_jsxs(Box, {
102
+ as: "header",
103
+ position: "sticky",
104
+ top: 0,
105
+ zIndex: theme.elements.headerZ,
106
+ overflow: {
107
+ _: 'hidden',
108
+ sm: 'visible'
109
+ } // Prevent tooltip overflow on mobile
110
+ ,
111
+ children: [/*#__PURE__*/_jsx(AppHeader, {
112
+ action: combinedAction,
113
+ items: getAppHeaderItems(props, false, dynamicDataLoading ?? false),
114
+ search: props.search,
115
+ ...(props.type === 'anon' ? {
116
+ redirectParam: props.redirectParam
117
+ } : hideNotification ? {} : {
118
+ notifications: props.notifications
119
+ }),
120
+ hideRightButtonDefaults: hideNotification,
121
+ isAnon: props.type === 'anon',
122
+ isTeams: props.type === 'teams',
123
+ type: hideNotification ? 'enterprise' : 'standard'
124
+ }), /*#__PURE__*/_jsx(AppHeaderMobile, {
125
+ action: combinedAction,
126
+ items: getAppHeaderItems(props, true, dynamicDataLoading ?? false),
127
+ ...(props.type === 'anon' || hideNotification ? {} : {
128
+ notifications: props.notifications
129
+ }),
130
+ search: props.search,
131
+ redirectParam: props.type === 'anon' ? props.redirectParam : undefined,
132
+ isEnterprise: props.type === 'enterprise',
133
+ isAnon: props.type === 'anon',
134
+ isSimple: props.type === 'simple',
135
+ hideRightMenuButton: props.type === 'simple' || props.type === 'loading',
136
+ navigationMenuFormattedLabel: props?.localizedLabels?.navigationMenuFormattedLabel
137
+ }), props.children]
128
138
  })
129
139
  })
130
140
  })
@@ -33,7 +33,6 @@ interface BaseHeader extends WithChildrenProp, AppHeaderAction {
33
33
  search: AppHeaderSearch;
34
34
  displayGlobalNavRedesign?: boolean;
35
35
  isBlpHeroExperimentVariant?: boolean;
36
- isInRevampedBlpExperimentVariant?: boolean;
37
36
  dynamicData?: GlobalHeaderDynamicData | null;
38
37
  dynamicDataLoading?: boolean;
39
38
  }
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": "3.14.0-alpha.0674fecdc1.0",
4
+ "version": "3.14.0-alpha.21505a76bc.0",
5
5
  "author": "Codecademy Engineering <dev@codecademy.com>",
6
6
  "dependencies": {
7
7
  "@emotion/is-prop-valid": "^1.2.1",