Skip to content

Commit 15a0008

Browse files
Info cards plugin (#43)
Co-authored-by: Cafer Elgin <[email protected]>
1 parent 3a46524 commit 15a0008

39 files changed

+3301
-3
lines changed

plugins/info-cards/.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

plugins/info-cards/.eslintrc.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module.exports = {
2+
env: {
3+
browser: true,
4+
es2021: true,
5+
},
6+
extends: [
7+
"plugin:react/jsx-runtime",
8+
"plugin:react-hooks/recommended",
9+
"standard-with-typescript",
10+
"prettier",
11+
],
12+
overrides: [],
13+
parserOptions: {
14+
ecmaVersion: "latest",
15+
project: "tsconfig.json",
16+
sourceType: "module",
17+
tsconfigRootDir: __dirname,
18+
},
19+
plugins: ["react"],
20+
rules: {
21+
// conflicts with no-extra-boolean-cast
22+
"@typescript-eslint/strict-boolean-expressions": "off",
23+
"no-console": ["error", { allow: ["warn", "error"] }],
24+
},
25+
settings: {
26+
react: {
27+
version: "detect",
28+
},
29+
},
30+
};

plugins/info-cards/.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# OSX
2+
*.DS_Store
3+
4+
# IDEs
5+
.idea
6+
*.iml
7+
.vscode
8+
9+
# This project
10+
node_modules/
11+
dist/
12+
yarn-error.log

plugins/info-cards/.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

plugins/info-cards/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Example
2+
3+
Info Cards Plugin is a [Cortex](https://www.cortex.io/) plugin. To see how to run the plugin inside of Cortex, see [our docs](https://docs.cortex.io/docs/plugins).
4+
5+
### Prerequisites
6+
7+
Developing and building this plugin requires either [yarn](https://classic.yarnpkg.com/lang/en/docs/install/) or [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).
8+
9+
## Getting started
10+
11+
1. Run `yarn` or `npm install` to download all dependencies
12+
2. Run `yarn build` or `npm run build` to compile the plugin code into `./dist/ui.html`
13+
3. Upload `ui.html` into Cortex on a create or edit plugin page
14+
4. Add or update the code and repeat steps 2-3 as necessary
15+
16+
### Notable scripts
17+
18+
The following commands come pre-configured in this repository. You can see all available commands in the `scripts` section of [package.json](./package.json). They can be run with npm via `npm run {script_name}` or with yarn via `yarn {script_name}`, depending on your package manager preference. For instance, the `build` command can be run with `npm run build` or `yarn build`.
19+
20+
- `build` - compiles the plugin. The compiled code root is `./src/index.tsx` (or as defined by [webpack.config.js](webpack.config.js)) and the output is generated into `dist/ui.html`.
21+
- `test` - runs all tests defined in the repository using [jest](https://jestjs.io/)
22+
- `lint` - runs lint and format checking on the repository using [prettier](https://prettier.io/) and [eslint](https://eslint.org/)
23+
- `lintfix` - runs eslint in fix mode to fix any linting errors that can be fixed automatically
24+
- `formatfix` - runs Prettier in fix mode to fix any formatting errors that can be fixed automatically
25+
26+
### Available React components
27+
28+
See available UI components via our [Storybook](https://cortexapps.github.io/plugin-core/).
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "test-file-stub";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = {};

plugins/info-cards/babel.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
plugins: ["@babel/plugin-syntax-jsx"],
3+
presets: [
4+
["@babel/preset-env", { targets: { node: "current" } }],
5+
"@babel/preset-typescript",
6+
["@babel/preset-react", { runtime: "automatic" }],
7+
],
8+
};

plugins/info-cards/jest.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
moduleNameMapper: {
3+
// map static asset imports to a stub file under the assumption they are not important to our tests
4+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
5+
"<rootDir>/__mocks__/fileMock.js",
6+
// map style asset imports to a stub file under the assumption they are not important to our tests
7+
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js",
8+
"@cortexapps/plugin-core/components":
9+
"<rootDir>/../../node_modules/@cortexapps/plugin-core/dist/components.cjs.js",
10+
"@cortexapps/plugin-core":
11+
"<rootDir>/../../node_modules/@cortexapps/plugin-core/dist/index.cjs.js",
12+
},
13+
setupFilesAfterEnv: ["<rootDir>/setupTests.ts"],
14+
testEnvironment: "jsdom",
15+
transform: {
16+
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest",
17+
},
18+
transformIgnorePatterns: [
19+
"/node_modules/(?!yaml)", // yaml is commonjs evidently
20+
],
21+
};

plugins/info-cards/package.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"name": "info-cards",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"dependencies": {
6+
"@codemirror/lang-html": "^6.4.9",
7+
"@cortexapps/plugin-core": "^2.1.0",
8+
"@dnd-kit/core": "^6.3.1",
9+
"@dnd-kit/modifiers": "^9.0.0",
10+
"@dnd-kit/sortable": "^10.0.0",
11+
"@emotion/react": "^11.14.0",
12+
"@emotion/styled": "^11.14.0",
13+
"@nikolovlazar/chakra-ui-prose": "^1.2.1",
14+
"@uiw/react-codemirror": "^4.23.7",
15+
"dompurify": "^3.2.3",
16+
"framer-motion": "^11.13.5",
17+
"react": "^18.2.0",
18+
"react-dom": "^18.2.0",
19+
"yaml": "^2.6.1"
20+
},
21+
"devDependencies": {
22+
"@babel/core": "^7.21.3",
23+
"@babel/plugin-syntax-jsx": "^7.18.6",
24+
"@babel/preset-env": "^7.26.0",
25+
"@babel/preset-react": "^7.26.3",
26+
"@babel/preset-typescript": "^7.26.0",
27+
"@popperjs/core": "^2.11.8",
28+
"@testing-library/jest-dom": "^5.16.5",
29+
"@testing-library/react": "^14.0.0",
30+
"@types/jest": "^29.5.3",
31+
"@types/react": "^18.0.28",
32+
"@types/react-dom": "^18.0.11",
33+
"@typescript-eslint/eslint-plugin": "^5.0.0",
34+
"@typescript-eslint/parser": "^5.55.0",
35+
"babel-jest": "^29.7.0",
36+
"css-loader": "^6.7.3",
37+
"eslint": "^8.0.1",
38+
"eslint-config-prettier": "^8.7.0",
39+
"eslint-config-standard-with-typescript": "^34.0.0",
40+
"eslint-plugin-import": "^2.25.2",
41+
"eslint-plugin-n": "^15.6.1",
42+
"eslint-plugin-promise": "^6.0.0",
43+
"eslint-plugin-react": "^7.32.2",
44+
"eslint-plugin-react-hooks": "^4.6.0",
45+
"html-webpack-plugin": "^5.5.0",
46+
"jest": "^29.6.1",
47+
"jest-environment-jsdom": "^29.5.0",
48+
"npm-run-all": "^4.1.5",
49+
"prettier": "^2.8.4",
50+
"prop-types": "^15.8.1",
51+
"react-dev-utils": "^12.0.1",
52+
"style-loader": "^3.3.1",
53+
"terser-webpack-plugin": "^5.3.7",
54+
"ts-loader": "^9.4.2",
55+
"typescript": "^4.9.5",
56+
"url-loader": "^4.1.1",
57+
"webpack": "^5.76.1",
58+
"webpack-cli": "^5.0.1",
59+
"webpack-dev-server": "^4.15.0"
60+
},
61+
"scripts": {
62+
"build": "webpack --mode=production",
63+
"clean": "rm -r ./dist",
64+
"dev": "webpack serve --mode=development",
65+
"fix": "run-p formatfix lintfix",
66+
"formatfix": "yarn prettier . --write",
67+
"formatcheck": "yarn prettier . --check",
68+
"lint": "run-p formatcheck lintcheck",
69+
"lintcheck": "yarn eslint src",
70+
"lintfix": "yarn lintcheck --fix",
71+
"test": "jest"
72+
}
73+
}

0 commit comments

Comments
 (0)