@codecademy/codebytes 0.4.1-alpha.ea7234.0 → 0.4.1-alpha.f8fe5c.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/CHANGELOG.md +1 -1
- package/package.json +3 -2
- package/src/__tests__/codebyte-test.tsx +13 -0
- package/src/index.tsx +15 -13
- package/src/types.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
### [0.4.1-alpha.
|
|
6
|
+
### [0.4.1-alpha.f8fe5c.0](https://github.com/Codecademy/client-modules/compare/@codecademy/codebytes@0.4.0...@codecademy/codebytes@0.4.1-alpha.f8fe5c.0) (2022-01-25)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @codecademy/codebytes
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/codebytes",
|
|
3
3
|
"description": "Codebytes Code Editor",
|
|
4
|
-
"version": "0.4.1-alpha.
|
|
4
|
+
"version": "0.4.1-alpha.f8fe5c.0",
|
|
5
5
|
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
6
|
"sideEffects": [
|
|
7
7
|
"**/*.css",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"@codecademy/gamut": "*",
|
|
24
24
|
"@codecademy/gamut-icons": "*",
|
|
25
25
|
"@codecademy/gamut-styles": "*",
|
|
26
|
+
"@codecademy/tracking": "0.18.0",
|
|
26
27
|
"@codecademy/variance": "*",
|
|
27
28
|
"@emotion/react": "^11.4.0",
|
|
28
29
|
"@emotion/styled": "^11.3.0",
|
|
@@ -55,5 +56,5 @@
|
|
|
55
56
|
"publishConfig": {
|
|
56
57
|
"access": "public"
|
|
57
58
|
},
|
|
58
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "3756c6e51177c3cffe5e7c2f962cf195d86edbbd"
|
|
59
60
|
}
|
|
@@ -171,6 +171,7 @@ describe('CodeBytes', () => {
|
|
|
171
171
|
renderWrapperWith({
|
|
172
172
|
text: 'some-value',
|
|
173
173
|
language: 'javascript',
|
|
174
|
+
isForums: true,
|
|
174
175
|
});
|
|
175
176
|
|
|
176
177
|
expect(trackUserImpression).toHaveBeenCalledWith({
|
|
@@ -185,6 +186,7 @@ describe('CodeBytes', () => {
|
|
|
185
186
|
text: 'some-value',
|
|
186
187
|
language: 'javascript',
|
|
187
188
|
mode: 'compose',
|
|
189
|
+
isForums: true,
|
|
188
190
|
});
|
|
189
191
|
|
|
190
192
|
expect(trackUserImpression).toHaveBeenCalledWith({
|
|
@@ -193,5 +195,16 @@ describe('CodeBytes', () => {
|
|
|
193
195
|
target: 'codebyte',
|
|
194
196
|
});
|
|
195
197
|
});
|
|
198
|
+
|
|
199
|
+
it('does not trigger a trackUserImpression when not isForum is false', () => {
|
|
200
|
+
renderWrapperWith({
|
|
201
|
+
text: 'some-value',
|
|
202
|
+
language: 'javascript',
|
|
203
|
+
mode: 'compose',
|
|
204
|
+
isForums: false,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
expect(trackUserImpression).not.toHaveBeenCalled();
|
|
208
|
+
});
|
|
196
209
|
});
|
|
197
210
|
});
|
package/src/index.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import { trackUserImpression } from './libs/eventTracking';
|
|
|
13
13
|
import { CodeByteEditorProps } from './types';
|
|
14
14
|
|
|
15
15
|
const editorStates = states({
|
|
16
|
-
|
|
16
|
+
isForums: { height: '100vh' },
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
const editorBaseStyles = system.css({
|
|
@@ -38,7 +38,7 @@ export const CodeByteEditor: React.FC<CodeByteEditorProps> = ({
|
|
|
38
38
|
text: initialText,
|
|
39
39
|
language: initialLanguage,
|
|
40
40
|
hideCopyButton = false,
|
|
41
|
-
|
|
41
|
+
isForums = false,
|
|
42
42
|
snippetsBaseUrl = process.env.CONTAINER_API_BASE,
|
|
43
43
|
onEdit,
|
|
44
44
|
onLanguageChange,
|
|
@@ -51,17 +51,19 @@ export const CodeByteEditor: React.FC<CodeByteEditorProps> = ({
|
|
|
51
51
|
const [hasBeenEdited, setHasBeenEdited] = useState(false);
|
|
52
52
|
|
|
53
53
|
useEffect(() => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
if (isForums) {
|
|
55
|
+
const options = getOptions();
|
|
56
|
+
const page_name = options.renderMode
|
|
57
|
+
? `${options.clientName}_${options.renderMode}`
|
|
58
|
+
: options.clientName;
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
trackUserImpression({
|
|
61
|
+
page_name,
|
|
62
|
+
context: options.parentPage,
|
|
63
|
+
target: 'codebyte',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}, [isForums]);
|
|
65
67
|
|
|
66
68
|
useEffect(() => {
|
|
67
69
|
if (language) {
|
|
@@ -70,7 +72,7 @@ export const CodeByteEditor: React.FC<CodeByteEditorProps> = ({
|
|
|
70
72
|
}, [language, initialText]);
|
|
71
73
|
|
|
72
74
|
return (
|
|
73
|
-
<EditorContainer bg="black" as="main"
|
|
75
|
+
<EditorContainer bg="black" as="main" isForums={isForums}>
|
|
74
76
|
<Box borderBottom={1} borderColor="gray-900" py={4} pl={8}>
|
|
75
77
|
<IconButton
|
|
76
78
|
icon={FaviconIcon}
|
package/src/types.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface CodeByteEditorProps {
|
|
|
9
9
|
language?: LanguageOption;
|
|
10
10
|
hideCopyButton?: boolean;
|
|
11
11
|
onCopy?: CodebytesChangeHandler;
|
|
12
|
-
|
|
12
|
+
isForums?: boolean;
|
|
13
13
|
snippetsBaseUrl?: string;
|
|
14
14
|
onEdit?: CodebytesChangeHandler;
|
|
15
15
|
onLanguageChange?: CodebytesChangeHandler;
|