Skip to content

Commit 20c9197

Browse files
authored
docs(samples): unify the widgets sample apps (#363)
1 parent dd40af9 commit 20c9197

26 files changed

+1453
-74
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
- checkout_from_workspace
6262
- run:
6363
name: Build
64-
command: yarn run build && yarn workspace @webex/widgets run build
64+
command: yarn run build && yarn workspace @webex/widgets run build:src
6565
- persist_to_workspace:
6666
root: .
6767
paths:

copy_to_docs.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# Copy the index.html file to the docs directory
4+
cp ./widgets-samples/index.html docs/
5+
6+
# Copy specific files and directories from samples-cc-wc-app to the docs directory
7+
mkdir -p docs/samples-cc-wc-app
8+
cp -r ./widgets-samples/cc/samples-cc-wc-app/dist docs/samples-cc-wc-app/
9+
cp ./widgets-samples/cc/samples-cc-wc-app/app.js docs/samples-cc-wc-app/
10+
cp ./widgets-samples/cc/samples-cc-wc-app/bundle.js docs/samples-cc-wc-app/
11+
cp ./widgets-samples/cc/samples-cc-wc-app/index.html docs/samples-cc-wc-app/
12+
13+
# Update the hrefs in the copied index.html file
14+
sed -i '' 's|http://localhost:4000/|./samples-cc-wc-app/index.html|g' docs/index.html
15+
sed -i '' 's|http://localhost:3000/|./samples-cc-react-app/index.html|g' docs/index.html
16+
sed -i '' 's|https://localhost:9000/|./samples-meeting-app/index.html|g' docs/index.html
17+
18+
echo "All dist folders, specific files from samples-cc-wc-app, and index.html from widgets-samples have been copied to the docs directory, and hrefs have been updated."

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"workspaces": [
88
"packages/**/*",
99
"packages/contact-center/*",
10-
"docs/**/*"
10+
"widgets-samples/**/**"
1111
],
1212
"packageManager": "yarn@4.5.1",
1313
"devDependencies": {
@@ -20,6 +20,7 @@
2020
"crypto-browserify": "^3.12.1",
2121
"css-loader": "^7.1.2",
2222
"html-webpack-plugin": "^5.6.3",
23+
"http-server": "^14.1.1",
2324
"jest": "29.7.0",
2425
"node-gyp": "^10.2.0",
2526
"os-browserify": "^0.3.0",
@@ -41,12 +42,12 @@
4142
"clean:dist": "yarn workspaces foreach --all --topological --parallel run clean:dist",
4243
"test:unit": "yarn run test:tooling && yarn run test:cc-widgets",
4344
"test:tooling": "jest --coverage",
44-
"test:cc-widgets": "yarn workspaces foreach --all --parallel --exclude webex-widgets --exclude @webex/web-component-samples-app --exclude @webex/react-samples-app run test:unit",
45-
"build": "yarn workspaces foreach --all --topological --parallel --exclude webex-widgets --exclude @webex/web-component-samples-app --exclude @webex/react-samples-app run build:src",
46-
"samples:build": "yarn workspace @webex/react-samples-app build:src && yarn workspace @webex/web-component-samples-app build:src",
47-
"samples:serve": "open docs/index.html && yarn workspace @webex/react-samples-app serve",
48-
"samples:serve-react": "yarn workspace @webex/react-samples-app serve",
49-
"samples:serve-wc": "yarn workspace @webex/web-component-samples-app serve",
45+
"test:cc-widgets": "yarn workspaces foreach --all --parallel --exclude webex-widgets --exclude samples-cc-wc-app --exclude samples-cc-react-app run test:unit",
46+
"build": "yarn workspaces foreach --all --topological --parallel --exclude samples-cc-react-app --exclude samples-cc-wc-app --exclude samples-meeting-app run build:src",
47+
"samples:build": "yarn workspaces foreach --all --parallel --include samples-cc-react-app --include samples-cc-wc-app --include samples-meeting-app run build:src && ./copy_to_docs.sh",
48+
"samples:serve": "http-server docs",
49+
"samples:serve-react": "yarn workspace samples-cc-react-app serve",
50+
"samples:serve-wc": "yarn workspace samples-cc-wc-app serve",
5051
"release:widgets": "semantic-release"
5152
},
5253
"jest": {

packages/@webex/widgets/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"main": "dist/webexWidgets.esm.js",
88
"module": "dist/webexWidgets.esm.js",
99
"scripts": {
10-
"build": "rollup -c",
10+
"clean": "rm -rf dist && rm -rf node_modules",
11+
"clean:dist": "rm -rf dist",
12+
"build:src": "yarn clean:dist && rollup -c",
1113
"demo:serve": "webpack serve ./demo/App.jsx --mode development",
1214
"demo:build": "webpack ./demo/App.jsx --mode production",
1315
"release": "semantic-release",

docs/react-samples/package.json renamed to widgets-samples/cc/samples-cc-react-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@webex/react-samples-app",
2+
"name": "samples-cc-react-app",
33
"version": "1.0.0",
44
"main": "dist/index.js",
55
"scripts": {

docs/react-samples/tsconfig.json renamed to widgets-samples/cc/samples-cc-react-app/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "./dist",
55
"declaration": true,

docs/react-samples/webpack.config.js renamed to widgets-samples/cc/samples-cc-react-app/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ const path = require('path');
22
const HtmlWebpackPlugin = require('html-webpack-plugin');
33
const {merge} = require('webpack-merge');
44

5-
const baseConfig = require('../../webpack.config');
5+
const baseConfig = require('../../../webpack.config');
66

77
module.exports = merge(baseConfig, {
88
entry: './src/index.tsx', // Entry file for bundling
99
output: {
10-
path: path.resolve(__dirname, 'dist'), // Output directory
10+
path: path.resolve(__dirname, '../../../docs/samples-cc-react-app'), // Output directory
1111
filename: 'bundle.js', // Output bundle file name
1212
clean: true, // Clean dist folder before each build
1313
},

docs/web-component-samples/package.json renamed to widgets-samples/cc/samples-cc-wc-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@webex/web-component-samples-app",
2+
"name": "samples-cc-wc-app",
33
"version": "1.0.0",
44
"main": "dist/index.js",
55
"dependencies": {
@@ -14,7 +14,7 @@
1414
"scripts": {
1515
"clean": "rm -rf dist && rm -rf node_modules",
1616
"clean:dist": "rm -rf dist",
17-
"serve": "open index.html",
17+
"serve": "webpack serve",
1818
"build:src": "webpack"
1919
}
2020
}

docs/web-component-samples/tsconfig.json renamed to widgets-samples/cc/samples-cc-wc-app/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "../../tsconfig.json",
2+
"extends": "../../../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "./dist",
55
"declaration": false,

docs/web-component-samples/webpack.config.js renamed to widgets-samples/cc/samples-cc-wc-app/webpack.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const path = require('path');
22
const {merge} = require('webpack-merge');
33

4-
const baseConfig = require('../../webpack.config');
4+
const baseConfig = require('../../../webpack.config');
55

66
module.exports = merge(baseConfig, {
77
output: {
@@ -14,9 +14,9 @@ module.exports = merge(baseConfig, {
1414
},
1515
devServer: {
1616
static: {
17-
directory: path.join(__dirname, 'public'),
17+
directory: path.join(__dirname),
1818
},
19-
open: true,
20-
port: 3000,
19+
open: false,
20+
port: 4000,
2121
},
2222
});

docs/index.html renamed to widgets-samples/index.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ <h2 class="page-header">Samples</h2>
4848
Get started quickly with the Cisco Webex Widgets with the following samples:
4949
</p>
5050
<div class="list-group">
51-
<a href="./web-component-samples/index.html" class="list-group-item">Contact Center widgets as web-component</a>
52-
<a href="http://localhost:3000/" class="list-group-item">Contact Center widgets in a react app</a>
51+
<a href="http://localhost:4000/" target="_blank" rel="noopener noreferrer" class="list-group-item">Contact Center widgets as web-component</a>
52+
<a href="http://localhost:3000/" target="_blank" rel="noopener noreferrer" class="list-group-item">Contact Center widgets in a react app</a>
53+
<a href="https://localhost:9000/" target="_blank" rel="noopener noreferrer" class="list-group-item">Meetings widgets in a react app</a>
5354
</div>
5455
</div>
5556
</div>
@@ -60,7 +61,7 @@ <h2 class="page-header">Samples</h2>
6061
<div class="row">
6162
<div class="col-xs-12 col-md-12">
6263
<div class="copyright">
63-
&copy; 2015-2024 Cisco and/or its affiliates. All Rights Reserved.
64+
&copy; 2015-2025 Cisco and/or its affiliates. All Rights Reserved.
6465
</div>
6566
</div>
6667
</div>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"name": "samples-meeting-app",
3+
"version": "1.0.0",
4+
"scripts": {
5+
"clean": "rm -rf dist && rm -rf node_modules",
6+
"clean:dist": "rm -rf dist",
7+
"build:src": "yarn clean:dist && webpack --mode production",
8+
"build:watch": "webpack --mode production --watch",
9+
"serve": "webpack serve --mode development"
10+
},
11+
"dependencies": {
12+
"@webex/widgets": "workspace:*",
13+
"prop-types": "^15.7.2",
14+
"react": "18.3.1",
15+
"react-dom": "18.3.1",
16+
"webex": "2.60.2"
17+
},
18+
"devDependencies": {
19+
"@babel/core": "^7.25.2",
20+
"@babel/plugin-proposal-export-default-from": "^7.25.9",
21+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
22+
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
23+
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
24+
"@babel/plugin-transform-regenerator": "^7.25.9",
25+
"@babel/plugin-transform-runtime": "^7.25.9",
26+
"@babel/preset-env": "^7.25.4",
27+
"@babel/preset-react": "^7.24.7",
28+
"@babel/preset-typescript": "^7.25.9",
29+
"@types/babel__plugin-transform-runtime": "^7",
30+
"@types/prop-types": "^15",
31+
"babel-loader": "^9.2.1",
32+
"buffer": "^6.0.3",
33+
"clean-webpack-plugin": "^4.0.0",
34+
"crypto-browserify": "^3.12.1",
35+
"css-loader": "^7.1.2",
36+
"html-loader": "^5.1.0",
37+
"html-webpack-plugin": "^5.6.3",
38+
"node-sass": "^9.0.0",
39+
"os-browserify": "^0.3.0",
40+
"querystring-es3": "^0.2.1",
41+
"sass-loader": "^16.0.4",
42+
"stream-browserify": "^3.0.0",
43+
"style-loader": "^4.0.0",
44+
"ts-loader": "^9.5.1",
45+
"typescript": "^5.6.3",
46+
"url": "^0.11.4",
47+
"util": "^0.12.5",
48+
"vm-browserify": "^1.1.2",
49+
"webpack": "^5.94.0",
50+
"webpack-cli": "^5.1.4",
51+
"webpack-dev-server": "^5.1.0",
52+
"webpack-merge": "6.0.1"
53+
},
54+
"babel": {
55+
"presets": [
56+
"@babel/preset-env",
57+
"@babel/preset-react"
58+
],
59+
"plugins": [
60+
"@babel/plugin-proposal-export-default-from",
61+
"@babel/plugin-proposal-nullish-coalescing-operator",
62+
"@babel/plugin-proposal-object-rest-spread",
63+
"@babel/plugin-proposal-optional-chaining",
64+
"@babel/plugin-transform-regenerator",
65+
"@babel/plugin-transform-runtime"
66+
]
67+
}
68+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import React, {useState} from 'react';
2+
import { createRoot } from 'react-dom/client';
3+
import {Button, Input, Checkbox} from '@momentum-ui/react';
4+
5+
import WebexMeetingsWidgetDemo from './WebexMeetingsWidgetDemo';
6+
7+
import '@webex/widgets/dist/css/webex-widgets.css';
8+
import '@momentum-ui/core/css/momentum-ui.min.css';
9+
import './App.scss';
10+
11+
export default function App() {
12+
const [tokenInput, setTokenInput] = useState('');
13+
const [token, setToken] = useState();
14+
const [fedramp, setFedramp] = useState(false);
15+
16+
const handleClearToken = (event) => {
17+
event.preventDefault();
18+
setTokenInput('');
19+
setToken();
20+
};
21+
22+
const handleUpdateInputToken = (event) => {
23+
setTokenInput(event.target.value);
24+
};
25+
26+
const handleSaveToken = (event) => {
27+
event.preventDefault();
28+
if(!tokenInput?.trim()) return;
29+
30+
setToken(tokenInput);
31+
};
32+
33+
function handleFedrampChange() {
34+
setFedramp(!fedramp);
35+
}
36+
37+
return (
38+
<>
39+
<div className="content flex-column">
40+
<section className="webex-section">
41+
<h3>Webex Widgets Access Token</h3>
42+
<h5>Webex Widgets require an access token to identify the current user.</h5>
43+
<h5>
44+
You can get an access token from{' '}
45+
<a href={`https://developer${fedramp ? '-usgov' : ''}.webex.com`} target="_blank">
46+
{`developer${fedramp ? '-usgov' : ''}.webex.com`}
47+
</a>
48+
</h5>
49+
<form className="webex-form">
50+
<Checkbox
51+
checked={fedramp}
52+
htmlId="fedrampCheckbox"
53+
label="FedRAMP"
54+
onChange={handleFedrampChange}
55+
value="FedRAMP"
56+
disabled={!!token}
57+
/>
58+
<Input
59+
htmlId="token"
60+
label="Access Token"
61+
name="token"
62+
onChange={handleUpdateInputToken}
63+
placeholder="Access Token"
64+
readOnly={!!token}
65+
type="password"
66+
value={tokenInput}
67+
/>
68+
<Button color="blue" type="submit" onClick={handleSaveToken} disabled={!!token} ariaLabel="Save Token">
69+
Save Token
70+
</Button>
71+
<Button type="button" onClick={handleClearToken} disabled={!token} ariaLabel="Clear Token">
72+
Clear Token
73+
</Button>
74+
</form>
75+
</section>
76+
<section className="webex-section fluid-height flex-column">
77+
<WebexMeetingsWidgetDemo token={token} fedramp={fedramp} />
78+
</section>
79+
</div>
80+
</>
81+
);
82+
}
83+
84+
const root = createRoot(document.getElementById('widgets-demo'));
85+
86+
root.render(<App />);
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#widgets-demo {
2+
display: flex;
3+
height: 100%;
4+
width: 100%;
5+
6+
.content {
7+
width: 100%;
8+
height: 100%;
9+
padding: 1rem;
10+
11+
overflow: auto;
12+
}
13+
14+
.webex-form {
15+
margin: 1rem;
16+
}
17+
18+
.webex-section {
19+
background-color: white;
20+
margin: 1rem 0;
21+
padding: .5rem 1rem;
22+
box-shadow: 0 0.0625rem 0.125rem 0 #C6C7CA;
23+
border-radius: .25rem;
24+
}
25+
26+
.flex-column {
27+
display: flex;
28+
flex-direction: column;
29+
}
30+
31+
.fluid-height {
32+
flex: 1;
33+
}
34+
}

0 commit comments

Comments
 (0)