@codecademy/codebytes 40.4.2-alpha.4923e8.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/.storybook/main.js +11 -0
- package/.storybook/preview.js +9 -0
- package/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/babel.config.js +15 -0
- package/dist/editor.d.ts +7 -0
- package/dist/editor.js +11 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +30 -0
- package/dist/stories/Codebytes.stories.d.ts +5 -0
- package/dist/stories/Codebytes.stories.js +15 -0
- package/package.json +59 -0
- package/src/editor.tsx +10 -0
- package/src/index.tsx +25 -0
- package/src/stories/Codebytes.stories.tsx +16 -0
- package/tsconfig.json +11 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
### 40.4.2-alpha.4923e8.0 (2021-12-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @codecademy/codebytes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 Ryzac, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/babel.config.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
presets: ['codecademy', '@babel/preset-typescript'],
|
|
3
|
+
plugins: [
|
|
4
|
+
[
|
|
5
|
+
'@emotion',
|
|
6
|
+
{
|
|
7
|
+
sourceMap: true,
|
|
8
|
+
autoLabel: 'always',
|
|
9
|
+
labelFormat: '[local]',
|
|
10
|
+
},
|
|
11
|
+
],
|
|
12
|
+
],
|
|
13
|
+
include: ['./src/**/*'],
|
|
14
|
+
ignore: ['__tests__', './**/*.d.ts'],
|
|
15
|
+
};
|
package/dist/editor.d.ts
ADDED
package/dist/editor.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export var Editor = function Editor(_ref) {
|
|
3
|
+
var text = _ref.text,
|
|
4
|
+
_onChange = _ref.onChange;
|
|
5
|
+
return /*#__PURE__*/React.createElement("textarea", {
|
|
6
|
+
value: text,
|
|
7
|
+
onChange: function onChange(e) {
|
|
8
|
+
return _onChange(e.target.value);
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
8
|
+
|
|
9
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
10
|
+
|
|
11
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
+
|
|
13
|
+
import React, { useState } from 'react';
|
|
14
|
+
import { Editor } from './editor';
|
|
15
|
+
export var CodeByteEditor = function CodeByteEditor(_ref) {
|
|
16
|
+
var initialText = _ref.text;
|
|
17
|
+
|
|
18
|
+
var _useState = useState(initialText),
|
|
19
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
20
|
+
text = _useState2[0],
|
|
21
|
+
setText = _useState2[1];
|
|
22
|
+
|
|
23
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Editor, {
|
|
24
|
+
text: text,
|
|
25
|
+
onChange: function onChange(newText) {
|
|
26
|
+
setText(newText);
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
};
|
|
30
|
+
export default CodeByteEditor;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare const _default: ComponentMeta<React.FC<import("../index").CodeByteEditorProps>>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Default: ComponentStory<React.FC<import("../index").CodeByteEditorProps>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CodeByteEditor } from '../index';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Example/Codebytes',
|
|
5
|
+
component: CodeByteEditor
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
var Template = function Template(args) {
|
|
9
|
+
return /*#__PURE__*/React.createElement(CodeByteEditor, args);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export var Default = Template.bind({});
|
|
13
|
+
Default.args = {
|
|
14
|
+
text: 'hi'
|
|
15
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@codecademy/codebytes",
|
|
3
|
+
"description": "",
|
|
4
|
+
"version": "40.4.2-alpha.4923e8.0",
|
|
5
|
+
"author": "Codecademy Engineering <dev@codecademy.com>",
|
|
6
|
+
"sideEffects": [
|
|
7
|
+
"**/*.css",
|
|
8
|
+
"**/*.scss",
|
|
9
|
+
"dist/**/[A-Z]**/[A-Z]*.js",
|
|
10
|
+
"dist/**/[A-Z]**/index.js"
|
|
11
|
+
],
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git@github.com:Codecademy/gamut.git"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@emotion/react": "^11.4.0",
|
|
20
|
+
"@emotion/styled": "^11.3.0",
|
|
21
|
+
"react": ">=16.8.1",
|
|
22
|
+
"react-dom": ">=16.8.1"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@codecademy/gamut": "^6.0.1",
|
|
26
|
+
"@codecademy/gamut-styles": "^12.1.0"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"verify": "tsc --noEmit",
|
|
30
|
+
"build:compile": "babel ./src --out-dir ./dist --copy-files --extensions \".ts,.tsx\"",
|
|
31
|
+
"build:clean": "rm -rf dist",
|
|
32
|
+
"build:types": "tsc --emitDeclarationOnly",
|
|
33
|
+
"build": "yarn build:clean && yarn build:compile && yarn build:types",
|
|
34
|
+
"build:watch": "yarn build && onchange ./src -- yarn build:compile && yarn build:types",
|
|
35
|
+
"lernaBuildTask": "yarn build",
|
|
36
|
+
"storybook": "start-storybook -p 6006",
|
|
37
|
+
"build-storybook": "build-storybook"
|
|
38
|
+
},
|
|
39
|
+
"license": "MIT",
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@babel/core": "^7.16.0",
|
|
42
|
+
"@codecademy/gamut-tests": "^3.0.1",
|
|
43
|
+
"@emotion/jest": "^11.3.0",
|
|
44
|
+
"@storybook/addon-actions": "^6.4.4",
|
|
45
|
+
"@storybook/addon-essentials": "^6.4.4",
|
|
46
|
+
"@storybook/addon-links": "^6.4.4",
|
|
47
|
+
"@storybook/react": "^6.4.4",
|
|
48
|
+
"@testing-library/dom": "^7.31.2",
|
|
49
|
+
"@testing-library/react": "^11.0.4",
|
|
50
|
+
"@types/enzyme": "3.10.7",
|
|
51
|
+
"babel-loader": "^8.2.3",
|
|
52
|
+
"enzyme": "3.11.0",
|
|
53
|
+
"onchange": "^7.0.2"
|
|
54
|
+
},
|
|
55
|
+
"publishConfig": {
|
|
56
|
+
"access": "public"
|
|
57
|
+
},
|
|
58
|
+
"gitHead": "426c73091883fba76cc1272ea420c6b0a66305bc"
|
|
59
|
+
}
|
package/src/editor.tsx
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
type EditorProps = {
|
|
4
|
+
text: string;
|
|
5
|
+
onChange: (text: string) => void;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const Editor: React.FC<EditorProps> = ({ text, onChange }) => {
|
|
9
|
+
return <textarea value={text} onChange={(e) => onChange(e.target.value)} />;
|
|
10
|
+
};
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Editor } from './editor';
|
|
4
|
+
|
|
5
|
+
export interface CodeByteEditorProps {
|
|
6
|
+
text: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const CodeByteEditor: React.FC<CodeByteEditorProps> = ({
|
|
10
|
+
text: initialText,
|
|
11
|
+
}) => {
|
|
12
|
+
const [text, setText] = useState<string>(initialText);
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
<Editor
|
|
16
|
+
text={text}
|
|
17
|
+
onChange={(newText: string) => {
|
|
18
|
+
setText(newText);
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
21
|
+
</>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default CodeByteEditor;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import { CodeByteEditor } from '../index';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Example/Codebytes',
|
|
8
|
+
component: CodeByteEditor,
|
|
9
|
+
} as ComponentMeta<typeof CodeByteEditor>;
|
|
10
|
+
|
|
11
|
+
const Template: ComponentStory<typeof CodeByteEditor> = (args) => (
|
|
12
|
+
<CodeByteEditor {...args} />
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const Default = Template.bind({});
|
|
16
|
+
Default.args = { text: 'hi' };
|