Skip to content

Commit 11550b5

Browse files
author
Di Wu
authored
Merge branch 'next-release/main' into 5d/update-pinpoint-config
2 parents 15397f7 + f909a98 commit 11550b5

File tree

242 files changed

+5238
-2826
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

242 files changed

+5238
-2826
lines changed

mdx-components.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Block, BlockSwitcher } from './src/components/BlockSwitcher';
99
import { Callout } from './src/components/Callout';
1010
import Fragments from './src/components/Fragments';
1111
import { MDXCode, MDXHeading, MDXLink } from './src/components/MDXComponents';
12-
import MigrationAlert from './src/components/MigrationAlert';
12+
import { MigrationAlert } from './src/components/MigrationAlert';
1313
import preToCodeBlock from './src/utils/pre-to-code-block';
1414
import { Overview } from './src/components/Overview';
1515
import ExternalLink from './src/components/ExternalLink';

src/components/GetStartedPopover/GetStartedPopover.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
} from '@/components/Icons';
1717
import { useClickOutside } from '@/utils/useClickOutside';
1818
import { DEFAULT_PLATFORM } from '@/data/platforms';
19+
import { useTabKeyDetection } from '@/utils/useTabKeyDetection';
1920

2021
const getStartedHref = '/[platform]/start/getting-started/introduction/';
2122

@@ -107,21 +108,32 @@ export const GetStartedPopover = () => {
107108
}
108109
});
109110

111+
const { isTabKeyPressed, setIsTabKeyPressed } =
112+
useTabKeyDetection(contentRef);
113+
110114
useEffect(() => {
111115
if (expanded) {
112116
contentRef?.current?.focus();
113117
}
114118
}, [expanded]);
115119

116-
const handleBlur = useCallback(
117-
(e) => {
118-
// Use relatedTarget to see if the target receiving focus is outside of the popover
119-
if (contentRef.current && !contentRef.current.contains(e.relatedTarget)) {
120+
const handleBlur = (e) => {
121+
// Use relatedTarget to see if the target receiving focus is outside of the popover
122+
if (
123+
contentRef.current &&
124+
!contentRef.current.contains(e.relatedTarget) &&
125+
isTabKeyPressed
126+
) {
127+
if (expanded) {
120128
setExpanded(false);
129+
130+
// Since the custom hook is only listening to the keydown and keyup
131+
// event on the ref we pass in, the keyup event doesn't get registered
132+
// when we lose focus and so the state isn't reset. Reset it here
133+
setIsTabKeyPressed(false);
121134
}
122-
},
123-
[contentRef]
124-
);
135+
}
136+
};
125137

126138
return (
127139
<Flex className="split-button">

src/components/GlobalNav/components/icons/AmplifyLogo.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ export function AmplifyLogo({ isGen2 }: AmplifyLogoProps) {
1111
width="20px"
1212
height="20px"
1313
viewBox={{ width: 24, height: 22 }}
14-
pathData="M20.6144 19L10.1205 1H13.5019L24 19H20.6144ZM7.80721 5.3588L15.4882 19H18.7952L9.45719 2.42859L7.80721 5.3588ZM4.89082 10.5419L0 19H13.8795L12.1271 15.9696H5.2705L8.70006 10.043L6.94038 7L4.89082 10.5419Z"
1514
color={isGen2 ? 'font.inverse' : 'brand.primary.60'}
15+
paths={[
16+
{
17+
d: 'M14.3128 20.0394C14.3651 20.1298 14.4618 20.1855 14.5664 20.1855H16.8444C17.0698 20.1855 17.2107 19.942 17.098 19.7472L8.82308 5.44278C8.71037 5.24795 8.4286 5.24795 8.31589 5.44278L7.09981 7.54494C7.09518 7.55294 7.09518 7.56281 7.09981 7.57081L7.10128 7.57334C7.1106 7.58946 7.09894 7.60961 7.08029 7.60961C7.07163 7.60961 7.06363 7.61422 7.0593 7.62171L0.0396396 19.7616C-0.0730193 19.9565 0.0678714 20.2 0.293265 20.2H10.9633C11.1887 20.2 11.3296 19.9564 11.2169 19.7616L10.1254 17.8749C10.0731 17.7845 9.97646 17.7288 9.87184 17.7288H4.4145C4.3018 17.7288 4.23135 17.607 4.28771 17.5096L8.4417 10.3288C8.49805 10.2314 8.63894 10.2314 8.6953 10.3288L14.3128 20.0394Z'
18+
},
19+
{
20+
d: 'M10.1282 2.30989C10.0759 2.40032 10.0759 2.51172 10.1282 2.60214L20.2155 20.0394C20.2678 20.1298 20.3645 20.1855 20.4691 20.1855H22.7412C22.9666 20.1855 23.1075 19.942 22.9948 19.7472L11.7715 0.346077C11.6588 0.151242 11.377 0.151243 11.2643 0.346077L10.1282 2.30989Z'
21+
}
22+
]}
1623
/>
1724
);
1825
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { useState } from 'react';
2+
import { Callout } from '../Callout';
3+
import Link from 'next/link';
4+
import { useCurrentPlatform } from '@/utils/useCurrentPlatform';
5+
import { Platform } from '@/data/platforms';
6+
7+
type MigrationAlert = {
8+
isLegacy: boolean;
9+
url: string;
10+
};
11+
12+
export function MigrationAlert({ isLegacy, url }: MigrationAlert) {
13+
const currentPlatform = useCurrentPlatform();
14+
15+
const alertText = isLegacy
16+
? 'You are currently viewing the legacy GraphQL Transformer documentation.'
17+
: 'You are currently viewing the new GraphQL transformer v2 docs';
18+
19+
const alertCTA = isLegacy
20+
? 'View latest documentation'
21+
: 'Looking for legacy docs?';
22+
23+
return (
24+
<Callout warning={true}>
25+
{alertText}{' '}
26+
<Link
27+
href={{
28+
pathname: url,
29+
query: { platform: currentPlatform }
30+
}}
31+
>
32+
{alertCTA}
33+
</Link>
34+
</Callout>
35+
);
36+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { MigrationAlert } from './MigrationAlert';

src/components/MigrationAlert/index.tsx

Lines changed: 0 additions & 164 deletions
This file was deleted.

src/components/PlatformNavigator/index.tsx

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import classNames from 'classnames';
77
import { useClickOutside } from '@/utils/useClickOutside';
88
import { VersionSwitcher } from '../VersionSwitcher';
99
import { PLATFORM_VERSIONS, PLATFORM_DISPLAY_NAMES } from '@/data/platforms';
10+
import { useTabKeyDetection } from '@/utils/useTabKeyDetection';
1011

1112
export function PlatformNavigator({ currentPlatform, isPrev }) {
1213
const [isOpen, setIsOpen] = useState<boolean>(false);
@@ -22,15 +23,26 @@ export function PlatformNavigator({ currentPlatform, isPrev }) {
2223
}
2324
});
2425

25-
const handleBlur = useCallback(
26-
(e) => {
27-
// Use relatedTarget to see if the target receiving focus is outside of the popover
28-
if (contentRef.current && !contentRef.current.contains(e.relatedTarget)) {
26+
const { isTabKeyPressed, setIsTabKeyPressed } =
27+
useTabKeyDetection(contentRef);
28+
29+
const handleBlur = (e) => {
30+
// Use relatedTarget to see if the target receiving focus is outside of the popover
31+
if (
32+
contentRef.current &&
33+
!contentRef.current.contains(e.relatedTarget) &&
34+
isTabKeyPressed
35+
) {
36+
if (isOpen) {
2937
setIsOpen(false);
38+
39+
// Since the custom hook is only listening to the keydown and keyup
40+
// event on the ref we pass in, the keyup event doesn't get registered
41+
// when we lose focus and so the state isn't reset. Reset it here
42+
setIsTabKeyPressed(false);
3043
}
31-
},
32-
[contentRef]
33-
);
44+
}
45+
};
3446

3547
useEffect(() => {
3648
if (isOpen) {
@@ -67,7 +79,13 @@ export function PlatformNavigator({ currentPlatform, isPrev }) {
6779
</Flex>
6880
<IconChevron className={isOpen ? '' : 'icon-rotate-90-reverse'} />
6981
</Button>
70-
{PLATFORM_VERSIONS[currentPlatform] && <VersionSwitcher platform={currentPlatform} isPrev={isPrev} flex="1 1 0" />}
82+
{PLATFORM_VERSIONS[currentPlatform] && (
83+
<VersionSwitcher
84+
platform={currentPlatform}
85+
isPrev={isPrev}
86+
flex="1 1 0"
87+
/>
88+
)}
7189
</Flex>
7290
<View
7391
className={classNames('popover', {

0 commit comments

Comments
 (0)