@codecademy/brand 3.26.0-alpha.fa0b72ae29.0 → 3.26.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/AppHeaderCatalogDropdown/index.js +6 -28
- package/dist/AppHeader/AppHeaderElements/AppHeaderDropdown/index.d.ts +0 -1
- package/dist/AppHeader/AppHeaderElements/AppHeaderDropdown/index.js +10 -67
- package/dist/AppHeader/AppHeaderElements/{AppHeaderDropdownLinks/elements/StyledAppHeaderLink.d.ts → AppHeaderLinkSections/elements.d.ts} +6 -6
- package/dist/AppHeader/AppHeaderElements/AppHeaderLinkSections/elements.js +36 -0
- package/dist/AppHeader/AppHeaderElements/AppHeaderLinkSections/index.d.ts +1 -8
- package/dist/AppHeader/AppHeaderElements/AppHeaderLinkSections/index.js +32 -25
- package/dist/AppHeader/AppHeaderElements/AppHeaderNavButton/index.d.ts +5 -2
- package/dist/AppHeader/AppHeaderElements/AppHeaderNavButton/index.js +91 -24
- package/dist/AppHeader/AppHeaderElements/AppHeaderResourcesDropdown/index.js +5 -27
- package/dist/AppHeader/AppHeaderElements/AppHeaderSection/NavSection.d.ts +2 -2
- package/dist/AppHeader/AppHeaderElements/AppHeaderSection/NavSection.js +38 -20
- package/dist/AppHeader/AppHeaderElements/AppHeaderSection/elements.js +8 -8
- package/dist/AppHeader/AppHeaderElements/AppHeaderSection/index.js +5 -13
- package/dist/AppHeader/Search/SearchPane.js +49 -24
- package/dist/AppHeader/shared/elements.d.ts +9 -3
- package/dist/AppHeader/shared/elements.js +126 -26
- package/dist/AppHeader/shared/types.d.ts +1 -1
- package/dist/AppHeader/shared/utils.d.ts +1 -2
- package/dist/AppHeader/shared/utils.js +0 -2
- package/dist/AppHeaderMobile/index.js +96 -100
- package/dist/PlanCard/PricingAmount.js +6 -6
- package/dist/PlanCard/types.d.ts +1 -0
- package/dist/PlanCard/types.js +13 -1
- package/package.json +6 -1
- package/dist/AppHeader/AppHeaderElements/AppHeaderDropdownLinks/elements/AppHeaderDropdownLink.d.ts +0 -3
- package/dist/AppHeader/AppHeaderElements/AppHeaderDropdownLinks/elements/AppHeaderDropdownLink.js +0 -25
- package/dist/AppHeader/AppHeaderElements/AppHeaderDropdownLinks/elements/AppHeaderMenuItem.d.ts +0 -3
- package/dist/AppHeader/AppHeaderElements/AppHeaderDropdownLinks/elements/AppHeaderMenuItem.js +0 -26
- package/dist/AppHeader/AppHeaderElements/AppHeaderDropdownLinks/elements/StyledAppHeaderLink.js +0 -36
- package/dist/AppHeader/AppHeaderElements/AppHeaderDropdownLinks/elements/types.d.ts +0 -4
- package/dist/AppHeader/AppHeaderElements/AppHeaderDropdownLinks/elements/types.js +0 -1
- package/dist/AppHeader/AppHeaderElements/AppHeaderDropdownLinks/index.d.ts +0 -2
- package/dist/AppHeader/AppHeaderElements/AppHeaderDropdownLinks/index.js +0 -2
- package/dist/AppHeader/AppHeaderElements/AppHeaderNavButton/AppHeaderDropdownNavButton.d.ts +0 -18
- package/dist/AppHeader/AppHeaderElements/AppHeaderNavButton/AppHeaderDropdownNavButton.js +0 -50
- package/dist/AppHeader/AppHeaderElements/AppHeaderNavButton/AppHeaderMenuNavButton.d.ts +0 -9
- package/dist/AppHeader/AppHeaderElements/AppHeaderNavButton/AppHeaderMenuNavButton.js +0 -38
- package/dist/AppHeader/Search/hooks/useSearchTracking.d.ts +0 -5
- package/dist/AppHeader/Search/hooks/useSearchTracking.js +0 -46
- package/dist/AppHeader/utils/string-similarity.d.ts +0 -17
- package/dist/AppHeader/utils/string-similarity.js +0 -30
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { IconButton } from '@codecademy/gamut';
|
|
2
|
-
import { DropdownAnchor, DropdownIcon, StyledText } from '../../shared';
|
|
3
|
-
import { useAppHeaderDropdownContext } from '../AppHeaderDropdownProvider';
|
|
4
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
export const AppHeaderDropdownNavButton = ({
|
|
6
|
-
buttonRef,
|
|
7
|
-
handleOnClick,
|
|
8
|
-
icon,
|
|
9
|
-
isOpen,
|
|
10
|
-
title,
|
|
11
|
-
isIconOnly
|
|
12
|
-
}) => {
|
|
13
|
-
const {
|
|
14
|
-
firstItemRef
|
|
15
|
-
} = useAppHeaderDropdownContext();
|
|
16
|
-
const dropdownNavOnClick = e => {
|
|
17
|
-
handleOnClick(e);
|
|
18
|
-
if (!isOpen) {
|
|
19
|
-
firstItemRef?.focus();
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
const sharedProps = {
|
|
23
|
-
'aria-expanded': isOpen,
|
|
24
|
-
onClick: dropdownNavOnClick,
|
|
25
|
-
ref: buttonRef
|
|
26
|
-
};
|
|
27
|
-
if (icon && isIconOnly) return /*#__PURE__*/_jsx(IconButton, {
|
|
28
|
-
icon: icon,
|
|
29
|
-
tip: title ?? 'Dropdown',
|
|
30
|
-
tipProps: {
|
|
31
|
-
alignment: 'bottom-center',
|
|
32
|
-
placement: 'floating'
|
|
33
|
-
},
|
|
34
|
-
...sharedProps
|
|
35
|
-
});
|
|
36
|
-
return /*#__PURE__*/_jsxs(DropdownAnchor, {
|
|
37
|
-
...sharedProps,
|
|
38
|
-
title: title,
|
|
39
|
-
variant: "interface",
|
|
40
|
-
children: [/*#__PURE__*/_jsx(StyledText, {
|
|
41
|
-
fontWeight: isOpen ? 'bold' : 'normal',
|
|
42
|
-
textAlign: "center",
|
|
43
|
-
title: title,
|
|
44
|
-
children: title
|
|
45
|
-
}), /*#__PURE__*/_jsx(DropdownIcon, {
|
|
46
|
-
open: isOpen,
|
|
47
|
-
size: 12
|
|
48
|
-
})]
|
|
49
|
-
});
|
|
50
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AppHeaderProfileDropdownItem } from '../../shared';
|
|
2
|
-
interface AppHeaderMenuNavButtonProps {
|
|
3
|
-
buttonRef: React.RefObject<HTMLButtonElement>;
|
|
4
|
-
handleOnClick: (event: React.MouseEvent) => void;
|
|
5
|
-
isOpen: boolean;
|
|
6
|
-
item: AppHeaderProfileDropdownItem;
|
|
7
|
-
}
|
|
8
|
-
export declare const AppHeaderMenuNavButton: React.FC<AppHeaderMenuNavButtonProps>;
|
|
9
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { TextButton } from '@codecademy/gamut';
|
|
2
|
-
import { Avatar } from '../../../Avatar';
|
|
3
|
-
import { useAppHeaderMenuContext } from '../AppHeaderMenuProvider';
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
export const AppHeaderMenuNavButton = ({
|
|
6
|
-
buttonRef,
|
|
7
|
-
handleOnClick,
|
|
8
|
-
isOpen,
|
|
9
|
-
item
|
|
10
|
-
}) => {
|
|
11
|
-
const {
|
|
12
|
-
menuItems,
|
|
13
|
-
resetIndex
|
|
14
|
-
} = useAppHeaderMenuContext();
|
|
15
|
-
const profileOnClick = e => {
|
|
16
|
-
const menuItemsArray = menuItems.values();
|
|
17
|
-
const firstMenuItem = menuItemsArray.next().value;
|
|
18
|
-
handleOnClick(e);
|
|
19
|
-
firstMenuItem?.focus();
|
|
20
|
-
};
|
|
21
|
-
return /*#__PURE__*/_jsx(TextButton, {
|
|
22
|
-
"aria-expanded": isOpen,
|
|
23
|
-
"aria-haspopup": true,
|
|
24
|
-
"data-testid": "avatar-dropdown-button",
|
|
25
|
-
onClick: profileOnClick
|
|
26
|
-
// this resets our programatic menu index to 0 in case someone clicks out of the dropdown
|
|
27
|
-
,
|
|
28
|
-
onFocus: resetIndex,
|
|
29
|
-
ref: buttonRef,
|
|
30
|
-
variant: "interface",
|
|
31
|
-
children: /*#__PURE__*/_jsx(Avatar, {
|
|
32
|
-
alt: "User profile avatar",
|
|
33
|
-
disableDropshadow: true,
|
|
34
|
-
size: 40,
|
|
35
|
-
src: item.avatar
|
|
36
|
-
})
|
|
37
|
-
});
|
|
38
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
import { usePrevious } from 'react-use';
|
|
3
|
-
import { isSimilarSetOfStrings } from '../../utils/string-similarity';
|
|
4
|
-
import { useSearchTrackingContext } from '../SearchTrackingProvider';
|
|
5
|
-
export const useSearchTracking = ({
|
|
6
|
-
onSearchAsYouType
|
|
7
|
-
}) => {
|
|
8
|
-
const {
|
|
9
|
-
onSearchAsYouTypeParams
|
|
10
|
-
} = useSearchTrackingContext();
|
|
11
|
-
|
|
12
|
-
// store the previous search event params
|
|
13
|
-
const prevSearchEventParams = usePrevious(onSearchAsYouTypeParams);
|
|
14
|
-
const lastTrackedQueryRef = useRef('');
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
// skip search tracking entirely if tracking function is not provided
|
|
17
|
-
if (!onSearchAsYouType) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// skip empty queries
|
|
22
|
-
if (onSearchAsYouTypeParams?.query.length === 0) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
let searchEventDelay;
|
|
26
|
-
|
|
27
|
-
// scenario 1: track when user's search has no results
|
|
28
|
-
if (onSearchAsYouTypeParams?.resultsCount === 0) {
|
|
29
|
-
searchEventDelay = setTimeout(() => {
|
|
30
|
-
onSearchAsYouType(onSearchAsYouTypeParams.query, onSearchAsYouTypeParams.searchId, 0, onSearchAsYouTypeParams.queryLoadTime);
|
|
31
|
-
lastTrackedQueryRef.current = onSearchAsYouTypeParams.query;
|
|
32
|
-
}, 1500);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// scenario 2: track when user's search has meaningful edits
|
|
36
|
-
if (prevSearchEventParams && onSearchAsYouTypeParams?.query !== prevSearchEventParams.query && prevSearchEventParams.query !== '' && prevSearchEventParams.resultsCount > 0 && prevSearchEventParams.query !== lastTrackedQueryRef.current && !isSimilarSetOfStrings(onSearchAsYouTypeParams?.query ?? '', prevSearchEventParams.query)) {
|
|
37
|
-
searchEventDelay = setTimeout(() => {
|
|
38
|
-
onSearchAsYouType(prevSearchEventParams.query, prevSearchEventParams.searchId, prevSearchEventParams.resultsCount, prevSearchEventParams.queryLoadTime);
|
|
39
|
-
lastTrackedQueryRef.current = prevSearchEventParams.query;
|
|
40
|
-
}, 1500);
|
|
41
|
-
}
|
|
42
|
-
return () => {
|
|
43
|
-
clearTimeout(searchEventDelay);
|
|
44
|
-
};
|
|
45
|
-
}, [onSearchAsYouType, onSearchAsYouTypeParams, prevSearchEventParams]);
|
|
46
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Determines whether two sets of words are similar based on the Jaccard index and
|
|
3
|
-
* a specified similarity threshold.
|
|
4
|
-
*
|
|
5
|
-
* @param a - A set of strings to compare against the second set of strings.
|
|
6
|
-
* @param b - A set of strings to compare against the first set of strings.
|
|
7
|
-
* @param threshold - A float between 0 and 1, where 1 means the strings are
|
|
8
|
-
* identical and 0 means the strings are completely different.
|
|
9
|
-
*
|
|
10
|
-
* The threshold is used to determine if the strings are similar.
|
|
11
|
-
* By default, if the threshold is 0.8, then the strings are considered similar
|
|
12
|
-
* if at least 80% of the words in the first set of strings are also in the
|
|
13
|
-
* second set of strings.
|
|
14
|
-
*
|
|
15
|
-
* @returns - It returns true if the strings are similar, false otherwise.
|
|
16
|
-
*/
|
|
17
|
-
export declare const isSimilarSetOfStrings: (a: string, b: string, threshold?: number) => boolean;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const transformSanitizedStringToArray = s => s.trim().toLowerCase().split(/\s+/);
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Determines whether two sets of words are similar based on the Jaccard index and
|
|
5
|
-
* a specified similarity threshold.
|
|
6
|
-
*
|
|
7
|
-
* @param a - A set of strings to compare against the second set of strings.
|
|
8
|
-
* @param b - A set of strings to compare against the first set of strings.
|
|
9
|
-
* @param threshold - A float between 0 and 1, where 1 means the strings are
|
|
10
|
-
* identical and 0 means the strings are completely different.
|
|
11
|
-
*
|
|
12
|
-
* The threshold is used to determine if the strings are similar.
|
|
13
|
-
* By default, if the threshold is 0.8, then the strings are considered similar
|
|
14
|
-
* if at least 80% of the words in the first set of strings are also in the
|
|
15
|
-
* second set of strings.
|
|
16
|
-
*
|
|
17
|
-
* @returns - It returns true if the strings are similar, false otherwise.
|
|
18
|
-
*/
|
|
19
|
-
export const isSimilarSetOfStrings = (a, b, threshold = 0.8) => {
|
|
20
|
-
const setA = Array.from(new Set(transformSanitizedStringToArray(a)));
|
|
21
|
-
const setB = Array.from(new Set(transformSanitizedStringToArray(b)));
|
|
22
|
-
|
|
23
|
-
// manually calculating intersection and union to support older browsers that may not have
|
|
24
|
-
// the Set.intersection and Set.union methods
|
|
25
|
-
const intersection = new Set([...setA].filter(s => setB.includes(s)));
|
|
26
|
-
const union = new Set([...setA, ...setB]);
|
|
27
|
-
|
|
28
|
-
// the Jaccard similarity is the ratio between the intersection and union of the two sets of words
|
|
29
|
-
return threshold <= intersection.size / union.size;
|
|
30
|
-
};
|