-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:MetaCell/geppetto-meta into feat…
…ure/GEP-166
- Loading branch information
Showing
36 changed files
with
3,473 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# 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* | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# Getting Started with Create React App | ||
|
||
This project was bootstrapped with [Vite](https://vitejs.dev/guide/) using React template. | ||
|
||
To start develop, you need to setup yalc to link geppetto libraries to the current project. | ||
|
||
To do so, run | ||
|
||
``` | ||
bash setup.bash | ||
``` | ||
|
||
or you can also run manually | ||
|
||
``` | ||
yarn install && yarn link:yalc | ||
``` | ||
|
||
# Project Description | ||
|
||
The Multiple Layout Manager Playground enables the creation of one or more workspaces, providing a flexible environment for managing various layouts. | ||
|
||
## Available Scripts | ||
|
||
You can run the project in dev or preview mode using `yarn dev` and `yarn preview`. | ||
To build the project, use `yarn build`. | ||
|
||
Here is a description of what each command is doing. | ||
|
||
### `yarn dev` | ||
|
||
Runs the app in the development mode. | ||
Open [http://localhost:5143](http://localhost:5143) to view it in the browser (the port might be different on your machine, check the logs displayed by vite to be sure you are targeting the right address). | ||
|
||
The page will reload if you make edits. | ||
You will also see any lint errors in the console. | ||
|
||
If you are developping at the same time on any of the geppetto.js lib (core, ui, client), you can run: | ||
|
||
``` | ||
bash watch-geppettojs-updates.sh | ||
``` | ||
|
||
This command will launch a `watch` on all the geppetto.js libraries and hot-reload the application if any of the source code of those dependencies changes. | ||
|
||
|
||
### `yarn preview` | ||
|
||
Runs the app in preview mode. | ||
This means that a local webserver is launched to serve the app, but hot-reloading is not avaiable and the application is served from the `dist` directory where the application have been compiled/built. | ||
|
||
|
||
### `yarn build` | ||
|
||
Builds the app for production to the `dist` folder. | ||
It correctly bundles React in production mode and optimizes the build for the best performance. | ||
|
||
Your app is ready to be deployed! |
71 changes: 71 additions & 0 deletions
71
examples/multiple-layout-manager-playground/eslint.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import js from '@eslint/js' | ||
import globals from 'globals' | ||
import reactHooks from 'eslint-plugin-react-hooks' | ||
import reactRefresh from 'eslint-plugin-react-refresh' | ||
import tseslint from 'typescript-eslint' | ||
import json from 'eslint-plugin-json' | ||
|
||
|
||
export default tseslint.config( | ||
{ ignores: [ | ||
'dist', | ||
'node_modules', | ||
'.yalc', | ||
'src/rest/*' // do not lint generated code | ||
] }, | ||
{ | ||
extends: [js.configs.recommended, ...tseslint.configs.recommended], | ||
files: ['**/*.{ts,tsx,js,jsx}'], | ||
languageOptions: { | ||
ecmaVersion: "latest", | ||
globals: globals.browser, | ||
sourceType: "module" | ||
}, | ||
plugins: { | ||
'react-hooks': reactHooks, | ||
'react-refresh': reactRefresh, | ||
}, | ||
rules: { | ||
...reactHooks.configs.recommended.rules, | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
indent: ["error", 2, { | ||
SwitchCase: 1, | ||
}], | ||
curly: "error", // enforce braces for one-line blocks | ||
"no-tabs": "error", // enforce no tabs | ||
"no-console": ["warn", { | ||
allow: ["warn", "error", "debug"], | ||
}], | ||
"consistent-return": "warn", // https://eslint.org/docs/latest/rules/consistent-return | ||
"prefer-arrow-callback": ["warn"], | ||
"object-curly-spacing": ["warn", "always"], // enforce consistent spacing inside braces | ||
"func-style": "off", // function expressions or arrow functions are equally valid | ||
"no-unneeded-ternary": "warn", // disallow unnecessary ternary expressions | ||
// React rules: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules | ||
"react/prop-types": "off", // PropTypes are not forced | ||
"react/forbid-prop-types": "off", // all PropTypes are allowed | ||
"react-hooks/rules-of-hooks": "error", // https://react.dev/reference/rules/rules-of-hooks | ||
"react-hooks/exhaustive-deps": "warn", // Hooks dependency array, sometimes it's better to ignore | ||
}, | ||
}, | ||
{ // Linting for tsconfig.json files allows comments | ||
files: ["tsconfig*.json"], | ||
plugins: { json }, | ||
processor: "json/json", | ||
rules: { | ||
...json.configs["recommended-with-comments"].rules, | ||
} | ||
}, | ||
{ // Linting for *.json files do now allow comments | ||
files: ["**/*.json"], | ||
ignores: ["tsconfig*.json"], | ||
plugins: { json }, | ||
processor: "json/json", | ||
rules: { | ||
...json.configs.recommended.rules, | ||
} | ||
} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<link rel="manifest" href="/manifest.json" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<title>Geppetto Multiple Layout Manager Playground</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/index.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"name": "multiple-layout-manager-playground", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"prepare": "yarn link:yalc", | ||
"link:yalc": "yalc link @metacell/geppetto-meta-core && yalc link @metacell/geppetto-meta-ui && yalc link @metacell/geppetto-meta-client", | ||
"dev": "vite", | ||
"build": "tsc -b && vite build", | ||
"lint": "eslint .", | ||
"lint-fix": "eslint . --fix", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"@emotion/react": "^11.11.1", | ||
"@emotion/styled": "^11.11.0", | ||
"@fortawesome/fontawesome-free": "^6.4.0", | ||
"@material-ui/core": "^4.11.4", | ||
"@metacell/geppetto-meta-client": "^2.0.0", | ||
"@metacell/geppetto-meta-core": "^2.0.0", | ||
"@metacell/geppetto-meta-ui": "^2.0.0", | ||
"@mui/icons-material": "^5.14.0", | ||
"@mui/material": "^5.14.0", | ||
"@reduxjs/toolkit": "^2.2.7", | ||
"@types/jest": "^27.5.2", | ||
"@types/node": "^16.18.38", | ||
"file-saver": "^2.0.5", | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1", | ||
"react-redux": "^7.2.0", | ||
"web-vitals": "^2.1.4" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "^9.9.0", | ||
"@types/react": "^18.3.3", | ||
"@types/react-dom": "^18.3.0", | ||
"@vitejs/plugin-react": "^4.3.1", | ||
"eslint": "^9.9.0", | ||
"eslint-plugin-json": "^4.0.1", | ||
"eslint-plugin-react-hooks": "^5.1.0-rc.0", | ||
"eslint-plugin-react-refresh": "^0.4.9", | ||
"globals": "^15.9.0", | ||
"sass": "^1.32.12", | ||
"typescript": "^5.5.4", | ||
"typescript-eslint": "^8.4.0", | ||
"vite": "^5.4.3", | ||
"yalc": "^1.0.0-pre.53" | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
examples/multiple-layout-manager-playground/public/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"short_name": "Layout Manager Playground", | ||
"name": "Simple App Playground for Layout Manager", | ||
"icons": [], | ||
"start_url": ".", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff" | ||
} |
3 changes: 3 additions & 0 deletions
3
examples/multiple-layout-manager-playground/public/robots.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# https://www.robotstxt.org/robotstxt.html | ||
User-agent: * | ||
Disallow: |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Trick to have folder relative to the script, not CWD | ||
PARENT_PATH=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) | ||
cd "${PARENT_PATH}" | ||
|
||
# Install the libraries (if not already installed) | ||
GEPPETTO_JS="../../geppetto.js" | ||
(bash "${GEPPETTO_JS}/dev-install.sh") | ||
|
||
yarn install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { ThemeProvider, createTheme } from '@mui/material/styles'; | ||
import CssBaseline from '@mui/material/CssBaseline'; | ||
import { Provider } from 'react-redux'; | ||
import HomePage from "./pages/HomePage"; | ||
import { useState } from 'react'; | ||
import { Workspace } from './workspace'; | ||
import { Box } from '@mui/material'; | ||
|
||
const darkTheme = createTheme({ | ||
palette: { | ||
mode: 'dark', | ||
}, | ||
}); | ||
|
||
function App() { | ||
const [workspaces, setWorkspaces] = useState<Record<string, Workspace>>({}); | ||
const [selectedWorkspacesIds, setSelectedWorkspacesIds] = useState<Set<string>>(new Set<string>()); | ||
|
||
const updateWorkspace = (workspace: Workspace) => { | ||
setWorkspaces((prev) => ({ | ||
...prev, | ||
[workspace.id]: workspace, | ||
})); | ||
}; | ||
|
||
const createWorkspace = (id: string, name: string) => { | ||
const newWorkspace = new Workspace(id, name, updateWorkspace); | ||
setWorkspaces((prev) => ({ ...prev, [id]: newWorkspace })); | ||
}; | ||
|
||
const handleCreateClick = () => { | ||
const workspaceId = `workspace-${Date.now()}`; | ||
const workspaceName = `Workspace ${Object.keys(workspaces).length + 1}`; | ||
|
||
createWorkspace(workspaceId, workspaceName); | ||
setSelectedWorkspacesIds(prevSelectedIds => { | ||
const updatedSet = new Set(prevSelectedIds); | ||
updatedSet.add(workspaceId); // Add the new workspace ID | ||
return updatedSet; | ||
}); | ||
}; | ||
|
||
const renderCompareMode = (workspaceIds: string[]) => ( | ||
<Box sx={{ display: "grid", gridTemplateColumns: "auto auto" }}> | ||
{workspaceIds.map((id) => ( | ||
<Provider key={id} store={workspaces[id].store}> | ||
<HomePage /> | ||
</Provider> | ||
))} | ||
</Box> | ||
); | ||
|
||
const renderWorkspaces = () => { | ||
return renderCompareMode(Array.from(selectedWorkspacesIds)); | ||
}; | ||
|
||
return ( | ||
<ThemeProvider theme={darkTheme}> | ||
<CssBaseline /> | ||
<div className="App"> | ||
<header className="App-header"> | ||
<button onClick={handleCreateClick} style={{ margin: "10px" }}>Create workspace</button> | ||
{renderWorkspaces()} | ||
</header> | ||
</div> | ||
</ThemeProvider> | ||
); | ||
} | ||
|
||
export default App; |
1 change: 1 addition & 0 deletions
1
examples/multiple-layout-manager-playground/src/assets/react.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions
14
examples/multiple-layout-manager-playground/src/components/MyComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { FC } from 'react'; | ||
|
||
// Define the props type for MyComponent | ||
type MyComponentProps = { | ||
name: string; | ||
color: string; | ||
}; | ||
|
||
// Define MyComponent as a functional component | ||
const MyComponent: FC<MyComponentProps> = ({ name, color }) => { | ||
return <h1 style={{ width: "100%", backgroundColor: color }}>{name}</h1>; | ||
}; | ||
|
||
export default MyComponent; |
Oops, something went wrong.