diff --git a/examples/adaptive-cards/.gitignore b/examples/adaptive-cards/.gitignore new file mode 100644 index 000000000..db4c6d9b6 --- /dev/null +++ b/examples/adaptive-cards/.gitignore @@ -0,0 +1,2 @@ +dist +node_modules \ No newline at end of file diff --git a/examples/adaptive-cards/README.md b/examples/adaptive-cards/README.md new file mode 100644 index 000000000..3093a29ca --- /dev/null +++ b/examples/adaptive-cards/README.md @@ -0,0 +1,13 @@ + + +# 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 +``` \ No newline at end of file diff --git a/examples/adaptive-cards/app.js b/examples/adaptive-cards/app.js new file mode 100644 index 000000000..46e40f167 --- /dev/null +++ b/examples/adaptive-cards/app.js @@ -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); \ No newline at end of file diff --git a/examples/adaptive-cards/index.html b/examples/adaptive-cards/index.html new file mode 100644 index 000000000..6ae19e9f8 --- /dev/null +++ b/examples/adaptive-cards/index.html @@ -0,0 +1,12 @@ + + + +