Skip to content

Commit 43ab9ae

Browse files
authored
chore(docs): upgrade react-live to latest version (#6184)
1 parent 10b017a commit 43ab9ae

File tree

4 files changed

+78
-138
lines changed

4 files changed

+78
-138
lines changed

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"react-copy-to-clipboard": "^5.0.4",
4242
"react-dom": "18.2.0",
4343
"react-icons": "^4.3.1",
44-
"react-live": "^2.4.1",
44+
"react-live": "^4.1.8",
4545
"rehype": "^11.0.0",
4646
"rehype-autolink-headings": "^5.1.0",
4747
"rehype-slug": "^4.0.1",

docs/src/components/home/HomeEditor.tsx

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import * as React from 'react';
2-
import {
3-
LiveProvider,
4-
LiveEditor,
5-
LivePreview,
6-
LiveContext,
7-
ContextProps,
8-
} from 'react-live';
2+
import { LiveProvider, LiveEditor, LivePreview, LiveContext } from 'react-live';
93
// only import the primitives to prevent importing sideEffects
104
import { primitives as AUI } from '@aws-amplify/ui-react';
115
import { trackClick } from '@/utils/track';
@@ -47,7 +41,7 @@ const code = `<Card variation="elevated">
4741
</Card>`;
4842

4943
const Error = () => {
50-
const context: ContextProps = React.useContext(LiveContext);
44+
const context = React.useContext(LiveContext);
5145
const { error } = context;
5246
if (error) {
5347
return <Alert variation="error">{error}</Alert>;
@@ -58,6 +52,7 @@ const Error = () => {
5852

5953
const HomeEditor = () => {
6054
const [edited, setEdited] = React.useState(false);
55+
6156
return (
6257
<LiveProvider
6358
scope={{ ...AUI }}
@@ -73,22 +68,14 @@ const HomeEditor = () => {
7368
<View
7469
flex="1"
7570
className="docs-home-editor__code-panel with-lines scrollable"
71+
onKeyUp={() => {
72+
if (!edited) {
73+
trackClick('HomeCodeEdit');
74+
setEdited(true);
75+
}
76+
}}
7677
>
77-
<LiveEditor
78-
onKeyDown={(e) => {
79-
// This makes sure the editor is not a focus trap, allowing customers to 'tab' out of the editor
80-
if (e.keyCode === 9) {
81-
// tab key
82-
e.preventDefault();
83-
e.currentTarget.blur();
84-
return;
85-
}
86-
if (!edited) {
87-
trackClick('HomeCodeEdit');
88-
setEdited(true);
89-
}
90-
}}
91-
/>
78+
<LiveEditor tabMode="focus" />
9279
</View>
9380
<View
9481
aria-label="Live preview results"

docs/src/styles/docs/code.scss

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@
33
* Based on Atom's One Light theme: https://github.com/atom/atom/tree/master/packages/one-light-syntax
44
*/
55

6-
.docs-home code.prism-code {
7-
font-size: inherit;
6+
.docs-home {
7+
code.prism-code {
8+
font-size: inherit;
9+
}
10+
11+
pre.prism-code {
12+
display: flex;
13+
flex-direction: column;
14+
}
815
}
916

1017
code[class*='language-'],

0 commit comments

Comments
 (0)