🛎🎧 -> React.ts initialisation for #3

This commit is contained in:
Gizmotronn 2022-02-15 20:16:04 +08:00
parent e7eef3f844
commit 1123e0bc25
15 changed files with 27767 additions and 0 deletions

View File

@ -1,5 +1,8 @@
# Signal-K Digital Garden
## CLI branch
We'll be creating a CLI for writing documentation and integrating it with your code editor and visual/GUI tools (e.g. Unity), on THIS branch.
🔗 Log onto our [notion](https://www.notion.so/skinetics/Signal-Kinetics-4c3a0eaa11914a5f84a59c01de860c57) or the [portal](https://docs.skinetics.tech) to view documentation & tasks
<script src="https://giscus.app/client.js"

1
fetchjson/README.md Normal file
View File

@ -0,0 +1 @@
Documentation related to typescript components of the Quartz repo, as well as examples for integration with LedgerStream-CLI (signal-k/cli) repo on Github.com

View File

@ -0,0 +1,3 @@
const add = (a: number, b: number): number => {
return a + b;
};

View File

@ -0,0 +1,12 @@
const today = new Date();
today.getMonth();
const person = {
age: 20
};
person.age += 1;
class Colour {
}
const red = new Colour();

View File

@ -0,0 +1,58 @@
let apples: number = 5;
let speed: string = 'fast';
let hasName: boolean = true;
let applesInference = 5;
let applesAnnotation: number = 5;
let nothing: null = null;
let nothingu: undefined = undefined;
// Built in objects
let now: Date = new Date();
// Array that only contains strings
let colours: string[] = ['red', 'green', 'blue'];
let myNumbers: number[] = [1, 2, 3];
let statements: boolean[] = [true, false, true];
// Classes with type annoations
class Car {
}
let car: Car = new Car();
// Object literal with type annoations
let point: { x: number; y: number; } = {
x: 10,
y: 20
}
// Function with type annoations
const logNumber: (i: number) => void = (i: number) => {
console.log(i);
}
// Json annotations
const json = '{"x": 10, "y": 20}';
const coordinates: { x: number; y: number } = JSON.parse(json);
console.log(coordinates);
// Anotation for declaring and later initializing variables
let words = ['red', 'green', 'blue'];
let foundWord: boolean;
for (let i = 0; i < words.length; i++) {
if (words[i] === 'green') {
foundWord = true;
}
}
// Non-inferrable variable
let numbers = [-10, -1, 12];
let numberAboveZero: boolean | number = false;
for (let i = 0; i < numbers.length; i++) {
if (numbers[i] > 0) {
numberAboveZero = numbers[i];
}
}

23
quartz-cli/.gitignore vendored Normal file
View File

@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*

46
quartz-cli/README.md Normal file
View File

@ -0,0 +1,46 @@
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.\
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you cant go back!**
If you arent satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point youre on your own.
You dont have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldnt feel obligated to use this feature. However we understand that this tool wouldnt be useful if you couldnt customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).

27494
quartz-cli/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

43
quartz-cli/package.json Normal file
View File

@ -0,0 +1,43 @@
{
"name": "quartz-cli",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.4.0",
"@types/node": "^16.11.25",
"@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"typescript": "^4.5.5",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

12
quartz-cli/src/index.tsx Normal file
View File

@ -0,0 +1,12 @@
import ReactDOM from 'react-dom';
import List from './state/List';
const App = () => {
return (
<div>
<List />
</div>
);
};
ReactDOM.render(<App />, document.getElementById('root'));

View File

@ -0,0 +1,20 @@
interface ChildProps {
colour: string;
onClick: () => void;
}
export const Child = ({ colour, onClick }: ChildProps) => {
return <div>
{colour}
<button onClick={onClick}>Click me</button>
</div>
};
export const ChildAsReactFC: React.FC<ChildProps> = ({ colour, onClick, children }) => {
return <div>
{colour}
<button onClick={onClick}>Click me</button>
</div>
};
//ChildAsReactFC.displayName = 'ChildAsReactFC';

View File

@ -0,0 +1,9 @@
import { ChildAsReactFC } from './Child';
const Parent = () => {
return <ChildAsReactFC colour="red" onClick={() => console.log('Clicked')}>;
Nothing
</ChildAsReactFC>
};
export default Parent;

1
quartz-cli/src/react-app-env.d.ts vendored Normal file
View File

@ -0,0 +1 @@
/// <reference types="react-scripts" />

View File

@ -0,0 +1,16 @@
import { useState } from 'react';
const List: React.FC = () => {
const [name, setName] = useState('');
return (
<div>
<h3>List</h3>
<input value={name} onChange={(e) => setName(e.target.value)} />
<button>Add item</button>
</div>
);
};
export default List;

26
quartz-cli/tsconfig.json Normal file
View File

@ -0,0 +1,26 @@
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}