Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite project to TS #19

Merged
merged 14 commits into from
Jan 23, 2023
2 changes: 1 addition & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ env:
extends:
- 'plugin:react/recommended'
- airbnb
parser: '@babel/eslint-parser'
parser: "@typescript-eslint/parser"
parserOptions:
ecmaFeatures:
jsx: true
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ https://github.com/FredrikOseberg/react-chatbot-kit

First of all you need to make your own question`s roadmap dependencies.

Create a `config.js` file.
Create a `config.ts` file.

See example of `config.js` in the `examples` directory.
See example of `config.ts` in the `examples` directory.

`config.js` file has four fields:
`config.ts` file has four fields:

1) `initMessages`, an array of messages that users will see when launching a chatbot.
2) `initQuestions`. Here are stored initial roadmap questions for users. The array consists of question names.
Expand All @@ -40,7 +40,7 @@ Create your custom widget component. See examples in the `examples/widgets` dire

Create object `widgets`, import and add all your widgets.

Create a `getWidget` function that has a `name` param and returns a component from `widgets` object, consider an example from the `examples/widgets/index.js`.
Create a `getWidget` function that has a `name` param and returns a component from `widgets` object, consider an example from the `examples/widgets/index.ts`.

### Now check if it`s working

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 0 additions & 9 deletions __fixtures__/widgets/index.js

This file was deleted.

9 changes: 9 additions & 0 deletions __fixtures__/widgets/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import ABS from './ABS';
import ESP from './ESP';

const widgets: any = {
ABS,
ESP,
};

export default (name: string) => widgets[name];
6 changes: 3 additions & 3 deletions __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import createFlowBot from '../src/init.jsx';
import baseConfig from '../__fixtures__/baseConfig.js';
import getWidget from '../__fixtures__/widgets/index.js';
import createFlowBot from '../src/init.tsx';
import baseConfig from '../__fixtures__/baseConfig.ts';
import getWidget from '../__fixtures__/widgets/index.ts';

const initialHtml = '<div id="root"></div>';

Expand Down
3 changes: 2 additions & 1 deletion babel.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
"@babel/preset-react",
"@babel/preset-typescript"
],
"plugins": [
[ "@babel/plugin-transform-runtime", { "regenerator": true } ]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 0 additions & 9 deletions examples/widgets/index.js

This file was deleted.

9 changes: 9 additions & 0 deletions examples/widgets/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import ABS from './ABS';
import ESP from './ESP';

const widgets: any = {
ABS,
ESP,
};

export default (name: string) => widgets[name];
Loading