-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #229 from abhinavkrin/new/html-embedd
New/html embed
- Loading branch information
Showing
36 changed files
with
2,676 additions
and
4,756 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": ["@babel/preset-react"] | ||
} |
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,2 @@ | ||
node_modules | ||
dist |
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,22 @@ | ||
{ | ||
"name": "@embeddedchat/htmlembed", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"type": "module", | ||
"scripts": { | ||
"build": "vite build && node postbuild.cjs", | ||
"preview": "npm run build && vite preview --port=4001" | ||
}, | ||
"dependencies": { | ||
"@embeddedchat/react": "./packages/react", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0" | ||
}, | ||
"devDependencies": { | ||
"@vitejs/plugin-react": "^3.1.0", | ||
"live-server": "^1.2.2", | ||
"vite": "^4.2.0", | ||
"vite-plugin-css-injected-by-js": "^3.1.0" | ||
} | ||
} |
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,20 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const files = fs.readdirSync(path.join(__dirname, 'public'), { recursive: true }); | ||
|
||
files.forEach((file) => { | ||
const inPath = path.join(__dirname, 'public', file); | ||
const outPath = path.join(__dirname, 'dist', file); | ||
console.log("Copy: ",inPath); | ||
if (fs.statSync(inPath).isDirectory()) { | ||
if (!fs.existsSync(outPath)) { | ||
fs.mkdirSync(outPath, {recursive: true}); | ||
} | ||
} else { | ||
fs.writeFileSync( | ||
outPath, | ||
fs.readFileSync(inPath) | ||
); | ||
} | ||
}); |
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,39 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + React</title> | ||
</head> | ||
<body> | ||
<div> | ||
<div id="embeddedchat"></div> | ||
<link rel="stylesheet" href="http://127.0.0.1:4001/rocketchat-icon.css"> | ||
<script src="http://127.0.0.1:4001/embeddedchat.js"></script> | ||
<script> | ||
// all props for the EmbeddedChat of @embeddedchat/react will go here | ||
// the config will be directly applied as props for the EmbeddedChat Component | ||
const config = { | ||
host: 'http://localhost:3000', | ||
roomId: 'GENERAL', | ||
GOOGLE_CLIENT_ID: '', | ||
isClosable: true, | ||
setClosableState: true, | ||
moreOpts: true, | ||
channelName: 'general', | ||
anonymousMode: true, | ||
headerColor: 'white', | ||
toastBarPosition: 'bottom-end', | ||
showRoles: true, | ||
showAvatar: false, | ||
enableThreads: true, | ||
auth: { | ||
flow: 'MANAGED', | ||
}, | ||
} | ||
EmbeddedChat.renderInElementWithId(config, 'embeddedchat') | ||
</script> | ||
</div> | ||
</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,13 @@ | ||
@font-face { | ||
font-family: 'RocketChat'; | ||
font-weight: 400; | ||
font-style: normal; | ||
font-display: auto; | ||
|
||
src: url('./rocketchat.eot'); | ||
src: url('./rocketchat.eot?#iefix') format('embedded-opentype'), | ||
url('./rocketchat.woff2') format('woff2'), | ||
url('./rocketchat.woff') format('woff'), | ||
url('./rocketchat.ttf') format('truetype'), | ||
url('./rocketchat.svg#RocketChat') format('svg'); | ||
} |
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,22 @@ | ||
import babel from '@rollup/plugin-babel'; | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
|
||
export default { | ||
input: 'src/index.js', | ||
output: { | ||
file: 'dist/embeddedchat.js', | ||
format: 'umd', | ||
name: 'EmbeddedChat', | ||
}, | ||
plugins: [ | ||
resolve(), | ||
commonjs(), | ||
babel({ | ||
babelHelpers: 'bundled', | ||
presets: ['@babel/preset-react'], | ||
}), | ||
terser(), | ||
], | ||
}; |
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,37 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom/client' | ||
import { EmbeddedChat as EmbeddedChatComponent } from '@embeddedchat/react'; | ||
|
||
const EmbeddedChat = { | ||
renderInElementWithId(config, id) { | ||
if (!id) { | ||
throw new Error("Please provide a valid id of the element to render embeddedchat"); | ||
} | ||
ReactDOM.createRoot(document.getElementById(id)).render( | ||
<React.StrictMode> | ||
<EmbeddedChatComponent {...config} /> | ||
</React.StrictMode> | ||
) | ||
}, | ||
renderInElementWithSelector(config, selector) { | ||
if(!selector) { | ||
throw new Error("Please provide a valid selector to render embeddedchat"); | ||
} | ||
ReactDOM.createRoot(document.querySelector(selector)).render( | ||
<React.StrictMode> | ||
<EmbeddedChatComponent {...config} /> | ||
</React.StrictMode> | ||
) | ||
}, | ||
renderInElement(config, element) { | ||
if (!element) { | ||
throw new Error("Please provide a valid element to render embeddedchat"); | ||
} | ||
ReactDOM.createRoot(element).render( | ||
<React.StrictMode> | ||
<EmbeddedChatComponent {...config} /> | ||
</React.StrictMode> | ||
) | ||
} | ||
} | ||
export default EmbeddedChat; |
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 @@ | ||
import EmbeddedChat from "./EmbeddedChat"; | ||
|
||
export default EmbeddedChat; |
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,19 @@ | ||
import { defineConfig } from 'vite' | ||
import react from '@vitejs/plugin-react' | ||
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js' | ||
import path from 'path'; | ||
|
||
export default defineConfig({ | ||
plugins: [react(), cssInjectedByJsPlugin()], | ||
build: { | ||
minify: true, | ||
cssCodeSplit: false, | ||
lib: { | ||
entry: path.resolve(__dirname, 'src/index.js'), | ||
name: 'EmbeddedChat', | ||
formats: ['umd'], | ||
fileName: () => 'embeddedchat.js', | ||
} | ||
}, | ||
define: { 'process.env.NODE_ENV': '"production"', 'process.env': '{}' } | ||
}) |
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
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
41 changes: 0 additions & 41 deletions
41
packages/react/src/components/ChatBody/ChatBody.module.css
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.