Skip to content
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

POC/adaptive cards #814

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions examples/adaptive-cards/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
13 changes: 13 additions & 0 deletions examples/adaptive-cards/README.md
Sanjuice marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!--- Morgan Stanley makes this available to you under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
--->

# ComposeUI Default App

This is a simple webpage that loads adaptive-cards and showcases a button which launches an alert when clicked.

## During Development

```npm i

npx lerna run start --stream --scope=@morgan-stanley/composeui-example-adaptive-cards
```
43 changes: 43 additions & 0 deletions examples/adaptive-cards/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Morgan Stanley makes this available to you under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

import * as AdaptiveCards from "adaptivecards";

// Author a card
var card = {
"type": "AdaptiveCard",
"version": "1.6",
"body": [
{
"type": "TextBlock",
"text": "Clicking on the button below will cause an alert"
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "Click me"
}
]
};

// Create an AdaptiveCard instance
var adaptiveCard = new AdaptiveCards.AdaptiveCard();

// Set its hostConfig property unless you want to use the default Host Config
// Host Config defines the style and behavior of a card
adaptiveCard.hostConfig = new AdaptiveCards.HostConfig({
fontFamily: "Segoe UI, Helvetica Neue, sans-serif"
});

// Set the adaptive card's event handlers. onExecuteAction is invoked
// whenever an action is clicked in the card
adaptiveCard.onExecuteAction = function(action) { alert("Ow! "); }

// Parse the card payload
adaptiveCard.parse(card);

// Render the card to an HTML element:
var renderedCard = adaptiveCard.render();

// And finally insert it somewhere in your page:
document.body.appendChild(renderedCard);
12 changes: 12 additions & 0 deletions examples/adaptive-cards/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- Morgan Stanley makes this available to you under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -->

<html lang="en">
<title>ComposeUI Adapative cards POC App</title>
</head>

<body>
<div id="container"></div>
<script type="text/javascript" src="dist/bundle.js"></script>
</body>

</html>
22 changes: 22 additions & 0 deletions examples/adaptive-cards/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@morgan-stanley/composeui-example-adaptive-cards",
"version": "0.1.0-alpha.1",
"private": true,
"description": "ComposeUI Default App",
"main": "app.js",
"type": "module",
"scripts": {
"clean": "rimraf dist",
"bundle": "rollup -c",
"build": "npm run clean && npm run bundle",
"start": "http-server -p 6060"
},
"devDependencies": {
"http-server": "14.1.1",
"rimraf": "^6.0.1",
"rollup": "^4.24.0"
},
"dependencies": {
"adaptivecards": "^1.3.1"
}
}
18 changes: 18 additions & 0 deletions examples/adaptive-cards/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Morgan Stanley makes this available to you under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. See the NOTICE file distributed with this work for additional information regarding copyright ownership. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';



export default {
input: 'app.js',
output: {
file: 'dist/bundle.js',
format: 'iife',
name: 'app'
},
plugins: [
resolve(),
commonjs()
]
};
29 changes: 29 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "Lerna monorepo of the web dependencies in ComposeUI",
"private": true,
"workspaces": [
"examples/adaptive-cards",
"examples/js-chart-and-grid-messagerouter/js-*",
"examples/fdc3-chart-and-grid/js-*",
"examples/fdc3-pricing-and-chat/js-*",
Expand Down