@codecademy/brand 3.2.0 → 3.3.0-alpha.991be2ca62.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.
- package/dist/AppHeader/AppHeaderElements/AppHeaderLinkSections/index.js +0 -0
- package/dist/AppHeader/Search/DefaultResults.js +2 -2
- package/dist/AppHeader/Search/SearchButton.d.ts +1 -1
- package/dist/AppHeader/Search/SearchButton.js +17 -1
- package/dist/AppHeader/Search/SearchPane.js +118 -39
- package/dist/AppHeader/Search/SearchTrackingProvider/index.d.ts +17 -0
- package/dist/AppHeader/Search/SearchTrackingProvider/index.js +25 -0
- package/dist/AppHeader/Search/types.d.ts +1 -0
- package/dist/AppHeader/Search/useHeaderSearch.js +2 -1
- package/dist/AppHeader/index.js +12 -9
- package/package.json +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
interface OnSearchAsYouTypeParamsType {
|
|
3
|
+
query: string;
|
|
4
|
+
searchId: string;
|
|
5
|
+
resultsCount: number;
|
|
6
|
+
queryLoadTime: number;
|
|
7
|
+
}
|
|
8
|
+
interface SearchTrackingContextType {
|
|
9
|
+
onSearchAsYouTypeParams: OnSearchAsYouTypeParamsType | null;
|
|
10
|
+
setOnSearchAsYouTypeParams: (params: OnSearchAsYouTypeParamsType | null) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const SearchTrackingContext: React.Context<SearchTrackingContextType>;
|
|
13
|
+
export declare const SearchTrackingProvider: React.FC<{
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const useSearchTrackingContext: () => SearchTrackingContextType;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import noop from 'lodash/noop';
|
|
2
|
+
import React, { createContext, useContext, useState } from 'react';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
export const SearchTrackingContext = /*#__PURE__*/createContext({
|
|
5
|
+
onSearchAsYouTypeParams: null,
|
|
6
|
+
setOnSearchAsYouTypeParams: noop
|
|
7
|
+
});
|
|
8
|
+
export const SearchTrackingProvider = ({
|
|
9
|
+
children
|
|
10
|
+
}) => {
|
|
11
|
+
const [onSearchAsYouTypeParams, setOnSearchAsYouTypeParams] = useState({
|
|
12
|
+
query: '',
|
|
13
|
+
searchId: '',
|
|
14
|
+
resultsCount: 0,
|
|
15
|
+
queryLoadTime: 0
|
|
16
|
+
});
|
|
17
|
+
return /*#__PURE__*/_jsx(SearchTrackingContext.Provider, {
|
|
18
|
+
value: {
|
|
19
|
+
onSearchAsYouTypeParams,
|
|
20
|
+
setOnSearchAsYouTypeParams
|
|
21
|
+
},
|
|
22
|
+
children: children
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export const useSearchTrackingContext = () => useContext(SearchTrackingContext);
|
|
@@ -17,6 +17,7 @@ export interface AppHeaderSearch extends OnSearch, onTrackingClick {
|
|
|
17
17
|
export interface SearchButtonProps extends ToggleSearch {
|
|
18
18
|
isSearchVisible: boolean;
|
|
19
19
|
setIsSearchVisible: Dispatch<SetStateAction<boolean>>;
|
|
20
|
+
onSearchAsYouType?: OnSearch['onSearchAsYouType'];
|
|
20
21
|
}
|
|
21
22
|
export interface SearchPaneProps extends OnSearch, ToggleSearch, onTrackingClick {
|
|
22
23
|
}
|
|
@@ -24,7 +24,8 @@ export const useHeaderSearch = ({
|
|
|
24
24
|
isSearchVisible: isSearchVisible,
|
|
25
25
|
setIsSearchVisible: setIsSearchVisible,
|
|
26
26
|
toggleSearch: toggleSearch,
|
|
27
|
-
searchButtonRef: searchButtonRef
|
|
27
|
+
searchButtonRef: searchButtonRef,
|
|
28
|
+
onSearchAsYouType: onSearchAsYouType
|
|
28
29
|
})
|
|
29
30
|
}, /*#__PURE__*/_jsx(AnimatedHeaderZone, {
|
|
30
31
|
visible: isSearchVisible,
|
package/dist/AppHeader/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { NotificationsDropdown } from '../Notifications/NotificationsDropdown';
|
|
|
5
5
|
import { useHeaderNotifications } from '../Notifications/useHeaderNotifications';
|
|
6
6
|
import { AppHeaderListItem } from './AppHeaderElements/AppHeaderListItem';
|
|
7
7
|
import { AppHeaderProvider } from './AppHeaderElements/AppHeaderProvider';
|
|
8
|
+
import { SearchTrackingProvider } from './Search/SearchTrackingProvider';
|
|
8
9
|
import { useHeaderSearch } from './Search/useHeaderSearch';
|
|
9
10
|
import { appHeaderMobileBreakpoint, appHeaderSpacing, StyledAppBar, StyledNavBar } from './shared';
|
|
10
11
|
import { mapAppHeaderItemToElement } from './shared/utils';
|
|
@@ -63,15 +64,17 @@ export const AppHeader = ({
|
|
|
63
64
|
_: 'none',
|
|
64
65
|
[appHeaderMobileBreakpoint]: 'block'
|
|
65
66
|
},
|
|
66
|
-
children: /*#__PURE__*/
|
|
67
|
-
children:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
children: /*#__PURE__*/_jsx(AppHeaderProvider, {
|
|
68
|
+
children: /*#__PURE__*/_jsxs(SearchTrackingProvider, {
|
|
69
|
+
children: [/*#__PURE__*/_jsx(StyledAppBar, {
|
|
70
|
+
"aria-label": "Main",
|
|
71
|
+
as: "nav",
|
|
72
|
+
children: /*#__PURE__*/_jsxs(StyledNavBar, {
|
|
73
|
+
ref: menuContainerRef,
|
|
74
|
+
children: [mapItemsToElement(items.left, 'left'), mapItemsToElement(right, 'right')]
|
|
75
|
+
})
|
|
76
|
+
}), notificationsView, searchPane]
|
|
77
|
+
})
|
|
75
78
|
})
|
|
76
79
|
});
|
|
77
80
|
};
|
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.
|
|
4
|
+
"version": "3.3.0-alpha.991be2ca62.0",
|
|
5
5
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@emotion/is-prop-valid": "^1.2.1",
|