Skip to content

CC-Widgets Packages setup #237

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 27 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
383aafc
fix: convert npm to yarn
mkesavan13 Oct 21, 2024
520fac9
Merge remote-tracking branch 'upstream/master' into convert_to_yarn
mkesavan13 Oct 21, 2024
a9d5669
fix: yarn lock
mkesavan13 Oct 21, 2024
c9fe972
fix: rename folder to match package name
mkesavan13 Oct 22, 2024
6d24f89
fix: move to yarn 4.5.1
mkesavan13 Oct 22, 2024
09adcc5
fix: nitpick self review comments
mkesavan13 Oct 24, 2024
debdaaa
feat(cc-widgets): inital-packages-setup
ShreyasSharma28 Oct 24, 2024
f775ae2
fix(cc-widgets): move-widgets-inside-webex-folder
ShreyasSharma28 Oct 24, 2024
11a111b
fix(cc-widgets): remove-yarn-changes
ShreyasSharma28 Oct 24, 2024
840074c
fix(cc-widgets): added-babel-webpack-configs
ShreyasSharma28 Oct 24, 2024
72173d2
feat(setup): update-setup
ShreyasSharma28 Nov 4, 2024
f195b14
fix(cc-widgets): add-react-w2x-and-mobx
ShreyasSharma28 Nov 5, 2024
d8309fe
feat(cc-widgets): add-tests-for-widgets
ShreyasSharma28 Nov 5, 2024
5ce6996
feat(react-samples): add-widgets-samples-with-react
ShreyasSharma28 Nov 5, 2024
6505954
feat(cc-widgets): samples-app-for-widgets-as-web-component
ShreyasSharma28 Nov 5, 2024
e1ca859
fix(cc-widgets): review-comments
ShreyasSharma28 Nov 5, 2024
842e311
Merge remote-tracking branch 'upstream/feat/cc-widgets' into packages…
ShreyasSharma28 Nov 5, 2024
0aa1ad6
fix(cc-widgets): create-common-webpack-config
ShreyasSharma28 Nov 6, 2024
dd165c9
fix(cc-widgets): add-ts-doc-fix-babelrc
ShreyasSharma28 Nov 6, 2024
e3d4569
fix(cc-widgets): minor-fixes
ShreyasSharma28 Nov 6, 2024
e0646ad
fix(webpack): remove-react-react-dom-as-external
ShreyasSharma28 Nov 11, 2024
b6a0f69
feat(cc-widgets): review-comments
ShreyasSharma28 Nov 11, 2024
1cfd42a
feat(cc-widgets): add-home-page-for-samples
ShreyasSharma28 Nov 11, 2024
d40fc0e
fix(cc-widgets): move-packages-out-of-webex-review-comments
ShreyasSharma28 Nov 12, 2024
3b548ff
fix(samples): adjust-tsconfig
ShreyasSharma28 Nov 12, 2024
fbbb430
fix(cc-widgets): revert-config-changes
ShreyasSharma28 Nov 13, 2024
fca23fa
feat(cc-widgets): change-folder-structure
ShreyasSharma28 Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created common babelrc which will be imported in each workspace. babelrc is required in each workspace to run jest tests

presets: [
['@babel/preset-env', {targets: {node: 'current'}}],
['@babel/preset-react', {runtime: 'automatic'}],
'@babel/preset-typescript',
],
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ reports/
!.env.default
!package.json
!package-lock.json
!tsconfig.json
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tsconfig was getting ignore, was causing issues.

node_modules/
.yarn/*
!.yarn/releases
70 changes: 70 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<title>Webex Widgets</title>
<meta name="description" content="Widgets for webex" />

<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
crossorigin="anonymous"
/>

<style>
footer {
margin: 20px 0px;
}

footer .copyright {
text-align: center;
margin: 0 auto;
}
</style>

</head>

<body>
<header class="navbar navbar-default navbar-static-top" role="banner">
<div class="container">
<div class="navbar-header">
<div class="navbar-left">
<a class="navbar-brand" href="./index.html">Webex Widgets</a>
</div>
</div>
</ul>
</div>
</header>
<main>
<div class="container">
<div class="row">
<div class="col-md-4">
<h2 class="page-header">Samples</h2>
<p>
Get started quickly with the Cisco Webex Widgets with the following samples:
</p>
<div class="list-group">
<a href="./web-component-samples/index.html" class="list-group-item">Contact Center widgets as web-component</a>
<a href="http://localhost:3000/" class="list-group-item">Contact Center widgets in a react app</a>
</div>
</div>
</div>
</div>
</main>
<footer>
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-12">
<div class="copyright">
&copy; 2015-2024 Cisco and/or its affiliates. All Rights Reserved.
</div>
</div>
</div>
</div>
</footer>
</body>
</html>
32 changes: 32 additions & 0 deletions docs/react-samples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sample app is also a workspace. This will allow us to easily link updated widgets locally.

Copy link
Author

@Shreyas281299 Shreyas281299 Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the files in this are demo, these will be updated when we add the actual implementation of these widgets.
We can still run and see the basic providers and widgets working and sharing states. Demo added in the desciption

"name": "@webex/react-samples-app",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"build": "tsc --project tsconfig.json",
"build:src": "webpack && yarn run build",
"build:watch": "webpack --watch",
"serve": "webpack serve"
},
"dependencies": {
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.4",
"@babel/preset-react": "^7.24.7",
"@babel/preset-typescript": "^7.25.9",
"@r2wc/react-to-web-component": "^2.0.3",
"@webex/cc-station-login": "workspace:*",
"@webex/cc-user-state": "workspace:*",
"babel-loader": "^9.2.1",
"file-loader": "^6.2.0",
"html-webpack-plugin": "^5.6.3",
"mobx-react": "^9.1.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"ts-loader": "^9.5.1",
"typescript": "^5.6.3",
"webpack": "^5.94.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0",
"webpack-merge": "6.0.1"
}
}
11 changes: 11 additions & 0 deletions docs/react-samples/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CC Widgets in React</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
15 changes: 15 additions & 0 deletions docs/react-samples/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dummy code for a simple demo.

import {StationLogin} from '@webex/cc-station-login';
import {UserState} from '@webex/cc-user-state';

function App() {
return (
<>
<h1>Contact Center widgets in a react app</h1>
<StationLogin />
<UserState />
</>
);
}

export default App;
6 changes: 6 additions & 0 deletions docs/react-samples/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from 'react';
import {createRoot} from 'react-dom/client';
import App from './App';

const root = createRoot(document.getElementById('root'));
root.render(<App />);
11 changes: 11 additions & 0 deletions docs/react-samples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"declaration": true,
"declarationDir": "./dist/types"
},
"include": [
"./src"
]
}
38 changes: 38 additions & 0 deletions docs/react-samples/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const {merge} = require('webpack-merge');

const baseConfig = require('../../webpack.config');
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using base webpack config here also


module.exports = merge(baseConfig, {
entry: './src/index.tsx', // Entry file for bundling
output: {
path: path.resolve(__dirname, 'dist'), // Output directory
filename: 'bundle.js', // Output bundle file name
clean: true, // Clean dist folder before each build
},
module: {
rules: [
{
test: /\.(js|jsx)$/, // Match JS and JSX files
exclude: /node_modules/,
use: {
loader: 'babel-loader', // Use Babel to transpile JavaScript and JSX
},
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: './public/index.html', // Template HTML file
filename: 'index.html',
}),
],
devServer: {
static: path.join(__dirname, 'public'), // Serve files from public folder
compress: true, // Enable gzip compression
port: 3000, // Port for the dev server
hot: true, // Enable hot module replacement
open: false, // Open the app in browser on start
},
});
14 changes: 14 additions & 0 deletions docs/web-component-samples/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a sample using web-components and NO react. Again dummy code to just show that widgets can be used as web-components

<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CC Widgets as web-component</title>
</head>
<body>
<h1>Contact Center widgets as web-component</h1>
<script src="dist/bundle.js"></script>
<widget-cc-station-login></widget-cc-station-login>
<widget-cc-user-state></widget-cc-user-state>
</body>
</html>
19 changes: 19 additions & 0 deletions docs/web-component-samples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "@webex/web-component-samples-app",
"version": "1.0.0",
"main": "dist/index.js",
"dependencies": {
"@webex/cc-station-login": "workspace:*",
"@webex/cc-user-state": "workspace:*",
"html-webpack-plugin": "^5.6.3",
"ts-loader": "^9.5.1",
"typescript": "^5.6.3",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
"webpack-merge": "6.0.1"
},
"scripts": {
"serve": "open index.html",
"build:src": "webpack"
}
}
2 changes: 2 additions & 0 deletions docs/web-component-samples/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import '@webex/cc-station-login';
import '@webex/cc-user-state';
11 changes: 11 additions & 0 deletions docs/web-component-samples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"declaration": false,
"declarationDir": null
},
"include": [
"./src"
]
}
22 changes: 22 additions & 0 deletions docs/web-component-samples/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const path = require('path');
const {merge} = require('webpack-merge');

const baseConfig = require('../../webpack.config');

module.exports = merge(baseConfig, {
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
},

resolve: {
extensions: ['.js', '.jsx', '.tsx', '.ts'],
},
devServer: {
static: {
directory: path.join(__dirname, 'public'),
},
open: true,
port: 3000,
},
});
20 changes: 18 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,26 @@
"license": "MIT",
"private": true,
"workspaces": [
"packages/**/*"
"packages/**/*",
"packages/contact-center/*",
"docs/**/*"
],
"packageManager": "yarn@4.5.1",
"devDependencies": {
"node-gyp": "^10.2.0"
"html-webpack-plugin": "^5.6.3",
"node-gyp": "^10.2.0",
"typescript": "^5.6.3",
"webpack": "^5.96.1",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0"
},
"scripts": {
"build": "yarn run build:store && yarn run build:widgets",
"build:store": "yarn workspace @webex/cc-store build:src",
"build:widgets": "yarn workspace @webex/cc-station-login build:src && yarn workspace @webex/cc-user-state build:src",
"samples:build": "yarn workspace @webex/react-samples-app build:src && yarn workspace @webex/web-component-samples-app build:src",
"samples:serve": "open docs/index.html && yarn workspace @webex/react-samples-app serve",
"samples:serve-react": "yarn workspace @webex/react-samples-app serve",
"samples:serve-wc": "yarn workspace @webex/web-component-samples-app serve"
}
}
3 changes: 3 additions & 0 deletions packages/contact-center/station-login/.babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const baseConfig = require('../../../.babelrc');

module.exports = baseConfig;
47 changes: 47 additions & 0 deletions packages/contact-center/station-login/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@webex/cc-station-login",
"description": "Webex Contact Center Widgets: Station Login",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"build": "yarn run -T tsc",
"build:src": "webpack && yarn run build",
"build:watch": "webpack --watch",
"test:unit": "jest"
},
"dependencies": {
"@r2wc/react-to-web-component": "2.0.3",
"@webex/cc-store": "workspace:*",
"mobx-react": "9.1.1",
"react": "18.3.1",
"react-dom": "18.3.1",
"typescript": "5.6.3"
},
"devDependencies": {
"@babel/core": "7.25.2",
"@babel/preset-env": "7.25.4",
"@babel/preset-react": "7.24.7",
"@babel/preset-typescript": "7.25.9",
"@testing-library/dom": "10.4.0",
"@testing-library/jest-dom": "6.6.2",
"@testing-library/react": "16.0.1",
"@types/jest": "29.5.14",
"@types/react-test-renderer": "18",
"babel-jest": "29.7.0",
"babel-loader": "9.2.1",
"file-loader": "6.2.0",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"ts-loader": "9.5.1",
"webpack": "5.94.0",
"webpack-cli": "5.1.4",
"webpack-merge": "6.0.1"
},
"jest": {
"testEnvironment": "jsdom",
"testMatch": [
"**/tests/**/*.ts",
"**/tests/**/*.tsx"
]
}
}
3 changes: 3 additions & 0 deletions packages/contact-center/station-login/src/helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const useStationLogin = () => {
return {name: 'StationLogin'};
};
3 changes: 3 additions & 0 deletions packages/contact-center/station-login/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {StationLogin, WebStationLogin} from './station-login';

export {StationLogin, WebStationLogin};
Loading