Skip to content

Commit

Permalink
feat: add main template
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia committed May 28, 2021
1 parent eed0fa2 commit 75a198d
Show file tree
Hide file tree
Showing 65 changed files with 27,053 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
public
coverage
src/serviceWorker.js
cypress/integration/examples
75 changes: 75 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"extends": [
"airbnb",
"prettier",
"plugin:@typescript-eslint/eslint-recommended"
],
"plugins": ["import", "jsx-a11y", "react"],
"ignorePatterns": ["dist"],
"env": {
"browser": true,
"node": true,
"mocha": true,
"jest": true
},
"globals": {
"cy": true,
"Cypress": true
},
"parser": "babel-eslint",
"rules": {
"no-underscore-dangle": [
"error",
{
"allow": ["_id", "__REDUX_DEVTOOLS_EXTENSION__"]
}
],
"jsx-a11y/anchor-is-valid": [
"error",
{
"components": ["Link"],
"specialLink": ["to", "hrefLeft", "hrefRight"],
"aspects": ["noHref", "invalidHref", "preferButton"]
}
],
"react/jsx-filename-extension": [
1,
{
"extensions": [".js", ".jsx"]
}
],
"import/no-named-as-default": 0,
"react/static-property-placement": [
"error",
"property assignment",
{
"childContextTypes": "static public field",
"contextTypes": "static public field",
"contextType": "static public field",
"defaultProps": "static public field",
"displayName": "static public field",
"propTypes": "static public field"
}
],
"react/state-in-constructor": ["error", "never"],
"no-console": [2, { "allow": ["error"] }],
"no-restricted-syntax": "off",
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
]
},
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".jsx", ".ts", ".tsx"]
}
}
}
}
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
node_modules
/.pnp
.pnp.js

# production
/build
/dist

# misc
.DS_Store

npm-debug.log*
yarn-debug.log*
yarn-error.log*

# environment files but not encrypted ones
.env*
!.env.*.encrypted

# cache
.eslintcache

# testing and coverage
cypress/screenshots
cypress/videos
/.nyc_output
/coverage


# jetbrains
.idea
10 changes: 10 additions & 0 deletions .huskyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"post-checkout": "yarn install",
"pre-commit": "pretty-quick --staged && yarn lint",
"post-commit": "git status",
"post-merge": "yarn install",
"pre-push": "yarn lint && yarn build && yarn test:once"
}
}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
34 changes: 34 additions & 0 deletions .versionrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"types": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "test",
"section": "Tests"
},
{
"type": "build",
"section": "Build System"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "ci",
"section": "Continuous Integration"
},
{
"type": "chore",
"section": "Chores",
"hidden": true
}
]
}

5 changes: 5 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This example was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

It is linked to the @graasp/ui package in the parent directory for development purposes.

You can run `yarn install` and then `yarn start` to test your package.
47 changes: 47 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "graasp-query-client-example",
"homepage": ".",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"dependencies": {
"@graasp/query-client": "link:..",
"@material-ui/core": "4.11.0",
"@material-ui/icons": "4.9.1",
"@testing-library/jest-dom": "link:../node_modules/@testing-library/jest-dom",
"@testing-library/react": "link:../node_modules/@testing-library/react",
"@testing-library/user-event": "link:../node_modules/@testing-library/user-event",
"@types/jest": "link:../node_modules/@types/jest",
"@types/node": "link:../node_modules/@types/node",
"@types/react": "link:../node_modules/@types/react",
"@types/react-dom": "link:../node_modules/@types/react-dom",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-query": "3.16.0",
"react-scripts": "3.4.3",
"typescript": "link:../node_modules/typescript"
},
"devDependencies": {
"@babel/plugin-syntax-object-rest-spread": "^7.8.3"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added example/public/favicon.ico
Binary file not shown.
46 changes: 46 additions & 0 deletions example/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<meta name="theme-color" content="#000000" />

<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />

<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Graasp UI</title>
</head>

<body>
<noscript> You need to enable JavaScript to run this app. </noscript>

<div id="root"></div>

<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
15 changes: 15 additions & 0 deletions example/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"short_name": "graasp-ui",
"name": "graasp-ui",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
9 changes: 9 additions & 0 deletions example/src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
17 changes: 17 additions & 0 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { useEffect } from 'react';
import { hooks, useMutation } from './configureQueryClient';

const App = () => {
const { mutate: postItem }: any = useMutation('postItem');

useEffect(() => {
postItem({ id: 'wef', parentId: 'wefoik' });
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const { data: user }: any = hooks.useOwnItems();

return <div>hello: {user}</div>;
};

export default App;
13 changes: 13 additions & 0 deletions example/src/configureQueryClient.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { configureQueryClient } from '@graasp/query-client';
const queryConfig = {
API_HOST: 'http://localhost:3000',
};

const {
QueryClientProvider,
queryClient,
hooks,
useMutation,
} = configureQueryClient(queryConfig);

export { QueryClientProvider, queryClient, hooks, useMutation };
14 changes: 14 additions & 0 deletions example/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
14 changes: 14 additions & 0 deletions example/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import './index.css';

import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import { QueryClientProvider, queryClient } from './configureQueryClient';

const app = (
<QueryClientProvider client={queryClient}>
<App />
</QueryClientProvider>
);

ReactDOM.render(app, document.getElementById('root'));
1 change: 1 addition & 0 deletions example/src/react-app-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="react-scripts" />
5 changes: 5 additions & 0 deletions example/src/setupTests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom/extend-expect';
30 changes: 30 additions & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"compilerOptions": {
"outDir": "dist",
"module": "esnext",
"lib": ["dom", "esnext"],
"moduleResolution": "node",
"jsx": "react",
"sourceMap": true,
"declaration": true,
"esModuleInterop": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"allowSyntheticDefaultImports": true,
"target": "es5",
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true
},
"include": ["src"],
"exclude": ["node_modules", "build"]
}
Loading

0 comments on commit 75a198d

Please sign in to comment.