-
Notifications
You must be signed in to change notification settings - Fork 33
Feature: added custom app example using React 19 #33
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
909a310
WIP: Initial example setup for a custom React application.
MartinaeyNL 582b41d
Replaced RSBuild project with RSPack. Using a different setup now; go…
MartinaeyNL c497aa5
Updated README.md for custom apps
MartinaeyNL ce5c4fb
Updated RSPack config with correct path and port. Updated README.
MartinaeyNL f10b31e
Added example for listening to events
MartinaeyNL 41b5e76
Added OpenRemote authentication and dependencies. Now prompting login…
MartinaeyNL 5511d95
Merge branch 'main' into feature/example-app-react
MartinaeyNL f2d492e
Upgraded dependencies: React 19, RSPack 1.5.8, etc
MartinaeyNL 5be0abb
Cleanup and rename to custom-react
MartinaeyNL b68d9de
Updated OR to 1.11.0
MartinaeyNL dc4011b
Updated to 1.11.0 edit 2
MartinaeyNL 39e007e
Bump RSPack version
MartinaeyNL 52ea1d1
Minor RSPack version adjustment
MartinaeyNL fc8d22c
Update ui/app/README.md
MartinaeyNL d5f14a5
Update ui/app/README.md
MartinaeyNL 67412de
Minor README adjustment
MartinaeyNL 5820696
Fixes for importing assets, such as favicons or images.
MartinaeyNL 06b7d72
Changed tabs to spaces in rspack.config.ts
MartinaeyNL 8c34e18
Update ui/app/custom-react/rspack.config.ts
MartinaeyNL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -7,6 +7,6 @@ | |
| "ui/demo/*" | ||
| ], | ||
| "devDependencies": { | ||
| "@openremote/util": "~1.10.0" | ||
| "@openremote/util": "~1.11.0" | ||
| } | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1,22 @@ | ||
| Custom UI apps can be added here use the manager UI app as a template. | ||
| # Custom UI apps | ||
|
|
||
| In this folder, you can add custom (web) applications that will be shipped along with OpenRemote. | ||
| For example, special mobile apps for end users, or apps for less-technical consumers are widespread. | ||
|
|
||
| Developing these custom apps is pretty straightforward, thanks to the built-in packages we provide. | ||
| These make communicating with OpenRemote easier, and allows developers to quickly set up a user interface. | ||
|
|
||
| ## Example apps | ||
|
|
||
| We provided several example apps to get familiar with the architecture. | ||
| All apps can be run using `npm run serve`, and visited at `http://localhost:9000/<your folder name>/`. | ||
| Here's a list of the apps, and what they do; | ||
|
|
||
| ### /custom | ||
| This is an example web application built with [Lit Web Components](https://lit.dev) and [Webpack](https://webpack.js.org). | ||
| Apps in our main OpenRemote [repository](https://github.com/openremote/openremote) are built with these technologies as well. | ||
| It can be used as a template to add your own pages on top of it. | ||
|
|
||
| ### /custom-react | ||
| This is an example web application built with [React 19](https://react.dev) and [RSPack](https://rspack.rs). | ||
| *(more information soon)* |
This file contains hidden or 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,13 @@ | ||
| # Local | ||
| .DS_Store | ||
| *.local | ||
| *.log* | ||
|
|
||
| # Dist | ||
| node_modules | ||
| dist/ | ||
|
|
||
| # IDE | ||
| .vscode/* | ||
| !.vscode/extensions.json | ||
| .idea |
Binary file not shown.
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 hidden or 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,12 @@ | ||
| buildDir = "dist" | ||
|
|
||
| tasks.register('clean') { | ||
| dependsOn npmClean | ||
| } | ||
|
|
||
| tasks.register('installDist', Copy) { | ||
| dependsOn npmBuild | ||
| mustRunAfter(resolveTask(":manager:installDist")) | ||
| from project.buildDir | ||
| into "${project(':deployment').buildDir}/image/manager/app/${projectDir.name}" | ||
| } |
This file contains hidden or 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,12 @@ | ||
| <!doctype html> | ||
| <html> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <link rel="icon" href="assets/favicon.ico"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Custom app example using React</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| </body> | ||
| </html> |
This file contains hidden or 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,30 @@ | ||
| { | ||
| "name": "@openremote/custom-react", | ||
| "version": "1.0.0", | ||
| "description": "OpenRemote Custom App using React", | ||
| "author": "OpenRemote", | ||
| "license": "AGPL-3.0-or-later", | ||
| "private": true, | ||
| "scripts": { | ||
| "clean": "npx tsc -b --clean && npx shx rm -rf dist", | ||
| "build": "npx cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 rspack build", | ||
| "serve": "npx cross-env NODE_ENV=development NODE_OPTIONS=--max_old_space_size=4096 rspack serve" | ||
| }, | ||
| "dependencies": { | ||
| "@openremote/core": "~1.11.0", | ||
| "@openremote/model": "~1.11.0", | ||
| "@openremote/or-mwc-components": "~1.11.0", | ||
| "react": "^19.2.0", | ||
| "react-dom": "^19.2.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@rspack/cli": "~1.6.0", | ||
| "@rspack/core": "~1.6.0", | ||
| "@types/react": "^19.2.2", | ||
| "@types/react-dom": "^19.2.2", | ||
| "cross-env": "^10.1.0", | ||
| "react-refresh": "^0.18.0", | ||
| "ts-node": "^10.9.2", | ||
| "typescript": "^5.9.3" | ||
| } | ||
| } |
This file contains hidden or 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,85 @@ | ||
| import {defineConfig} from "@rspack/cli"; | ||
| import {rspack} from "@rspack/core"; | ||
|
|
||
| const isDev = process.env.NODE_ENV === "development"; | ||
|
|
||
| // Target browsers, see: https://github.com/browserslist/browserslist | ||
| const targets = ["chrome >= 87", "edge >= 88", "firefox >= 78", "safari >= 14"]; | ||
|
|
||
| export default defineConfig({ | ||
| context: __dirname, | ||
| devServer: { | ||
| host: "0.0.0.0", | ||
| port: 9000, | ||
| open: false | ||
| }, | ||
| entry: { | ||
| main: "./src/main.tsx" | ||
| }, | ||
| resolve: { | ||
| extensions: ["...", ".ts", ".tsx", ".jsx"] | ||
| }, | ||
| module: { | ||
| parser: { | ||
| "css/auto": { | ||
| namedExports: false, | ||
| }, | ||
| }, | ||
| rules: [ | ||
| { | ||
| test: /\.svg$/, | ||
| type: "asset" | ||
| }, | ||
| { | ||
| test: /(maplibre|mapbox|@material|gridstack|@mdi).*\.css$/, //output css as strings | ||
| type: "asset/source" | ||
| }, | ||
| { | ||
| test: /\.tsx$/, | ||
| type: "javascript/auto", | ||
| use: [ | ||
| { | ||
| loader: "builtin:swc-loader", | ||
| options: { | ||
| jsc: { | ||
| parser: { | ||
| syntax: "typescript", | ||
| tsx: true | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| }, | ||
| plugins: [ | ||
| new rspack.HtmlRspackPlugin({ | ||
| template: "./index.html" | ||
| }), | ||
| // Define MANAGER_URL as a global variable | ||
| new rspack.DefinePlugin({ | ||
| MANAGER_URL: JSON.stringify(process.env.MANAGER_URL ?? (isDev ? "http://localhost:8080" : undefined)) | ||
| }), | ||
| // Import assets | ||
| new rspack.CopyRspackPlugin({ | ||
| patterns: [ | ||
| {from: "./assets", to: "assets"} | ||
| ] | ||
| }) | ||
| ], | ||
| optimization: { | ||
| minimizer: [ | ||
| new rspack.SwcJsMinimizerRspackPlugin(), | ||
| new rspack.LightningCssMinimizerRspackPlugin({ | ||
| minimizerOptions: {targets} | ||
| }) | ||
| ] | ||
| }, | ||
| output: { | ||
| publicPath: isDev ? "/custom-react/" : "/", | ||
| }, | ||
| experiments: { | ||
| css: true | ||
| } | ||
| }); | ||
This file contains hidden or 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,10 @@ | ||
| #root { | ||
| max-width: 1280px; | ||
| margin: 0 auto; | ||
| padding: 2rem; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .logo { | ||
| height: 12em; | ||
| } |
This file contains hidden or 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,23 @@ | ||
| import React from "react"; | ||
| import openremoteLogo from "../assets/openremote.svg"; | ||
| import {InputType} from "@openremote/or-mwc-components/or-mwc-input"; | ||
| import type {} from "@openremote/or-mwc-components/jsx"; | ||
| import "./App.css"; | ||
|
|
||
| function App() { | ||
| return ( | ||
| <div className="App"> | ||
| <div id="logo"> | ||
| <img src={openremoteLogo} className="logo openremote" alt="OpenRemote logo"/> | ||
| </div> | ||
| <h2>"A React template for your custom app."</h2> | ||
MartinaeyNL marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <div id="content"> | ||
| <a href="https://docs.openremote.io" target="_blank" rel="noreferrer"> | ||
| <or-mwc-input type={InputType.BUTTON} outlined label="View the documentation"></or-mwc-input> | ||
| </a> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default App; | ||
This file contains hidden or 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,31 @@ | ||
| :root { | ||
| font-family: Inter, Avenir, Helvetica, Arial, sans-serif; | ||
| font-size: 16px; | ||
| line-height: 24px; | ||
| font-weight: 400; | ||
|
|
||
| color-scheme: light dark; | ||
| color: rgba(255, 255, 255, 0.87); | ||
| background-color: #242424; | ||
|
|
||
| font-synthesis: none; | ||
| text-rendering: optimizeLegibility; | ||
| -webkit-font-smoothing: antialiased; | ||
| -moz-osx-font-smoothing: grayscale; | ||
| -webkit-text-size-adjust: 100%; | ||
| } | ||
|
|
||
| body { | ||
| margin: 0; | ||
| display: flex; | ||
| place-items: center; | ||
| min-width: 320px; | ||
| min-height: 100vh; | ||
| } | ||
|
|
||
| @media (prefers-color-scheme: light) { | ||
| :root { | ||
| color: #213547; | ||
| background-color: #ffffff; | ||
| } | ||
| } |
This file contains hidden or 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,35 @@ | ||
| import React from "react"; | ||
| import ReactDOM from "react-dom/client"; | ||
| import App from "./App.tsx"; | ||
| import {manager} from "@openremote/core"; | ||
| import {ManagerConfig} from "@openremote/model"; | ||
| import "./index.css"; | ||
|
|
||
| declare const MANAGER_URL: string | undefined; | ||
|
|
||
| /** | ||
| * Define the Manager configuration to talk with OpenRemote. | ||
| * For example, defining the realm and URL to communicate with. (these will be consumed with HTTP API calls for example) | ||
| * We also enable autoLogin to prompt a Keycloak login before the app appears. | ||
| */ | ||
| const managerConfig: ManagerConfig = { | ||
| realm: "master", | ||
| managerUrl: MANAGER_URL ?? "", | ||
| autoLogin: true | ||
| }; | ||
|
|
||
| /** | ||
| * Initialize the Manager connection. | ||
| * Afterward, we can start rendering the React DOM UI. | ||
| */ | ||
| manager.init(managerConfig).then(() => { | ||
|
|
||
| /** | ||
| * Render your React application to the DOM. | ||
| */ | ||
| ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( | ||
| <React.StrictMode> | ||
| <App /> | ||
| </React.StrictMode> | ||
| ); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.