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

feat: render adaptive cards #2746

Open
wants to merge 40 commits into
base: next/mgt-chat
Choose a base branch
from
Open

feat: render adaptive cards #2746

wants to merge 40 commits into from

Conversation

musale
Copy link
Contributor

@musale musale commented Oct 3, 2023

Closes #2185

PR Type

  • Feature

Description of the changes

  • Render adaptive cards with Action.OpenUrl option

PR checklist

  • Project builds (yarn build) and changes have been tested in at least two supported browsers (Edge + non-Chromium based browser)
  • All public APIs (classes, methods, etc) have been documented following the jsdoc syntax
  • Stories have been added and existing stories have been tested
  • Added appropriate documentation. Docs PR:
  • License header has been added to all new source files (yarn setLicense)
  • Contains NO breaking changes

Other information

@musale musale mentioned this pull request Oct 3, 2023
6 tasks
@musale musale changed the title Add adaptive cards and markdownit to render md feat: render adaptive cards Oct 5, 2023
This was unlinked from issues Oct 5, 2023
@musale musale linked an issue Oct 5, 2023 that may be closed by this pull request
@musale musale added this to the Chat - Public Preview milestone Oct 5, 2023
@github-actions
Copy link

📖 The updated storybook is available here

1 similar comment
@github-actions
Copy link

📖 The updated storybook is available here

@github-actions
Copy link

🚀 New react-contoso sample application deployed here

1 similar comment
@github-actions
Copy link

🚀 New react-contoso sample application deployed here

@musale musale marked this pull request as ready for review October 23, 2023 10:14
@musale musale requested a review from a team as a code owner October 23, 2023 10:14
@github-actions
Copy link

📖 The updated storybook is available here

@github-actions
Copy link

🚀 New react-contoso sample application deployed here

package.json Outdated Show resolved Hide resolved
packages/mgt-chat/src/utils/onRenderMessage.tsx Outdated Show resolved Hide resolved
packages/mgt-chat/src/utils/onRenderMessage.tsx Outdated Show resolved Hide resolved
packages/mgt-chat/src/utils/onRenderMessage.tsx Outdated Show resolved Hide resolved
packages/mgt-chat/src/utils/onRenderMessage.tsx Outdated Show resolved Hide resolved
packages/mgt-chat/src/utils/onRenderMessage.tsx Outdated Show resolved Hide resolved
packages/mgt-chat/src/utils/onRenderMessage.tsx Outdated Show resolved Hide resolved
packages/mgt-chat/src/utils/onRenderMessage.tsx Outdated Show resolved Hide resolved
@musale
Copy link
Contributor Author

musale commented Nov 1, 2023

@sebastienlevert thank you for this Adaptive card designer resource. I used the teams light css in the styling.

Signed-off-by: Martin Musale <[email protected]>
@sebastienlevert
Copy link
Contributor

sebastienlevert commented Nov 2, 2023

There is a conflict with this PR @musale and can't test / validate. @gavinbarron this happens on a lot of PRs lately with .yarn/install-state.gz and I'm wondering if we should add this file to .gitignore?

.yarn/install-state.gz is an optimization file that you shouldn't ever have to commit. It simply stores the exact state of your project so that the next commands can boot without having to resolve your workspaces all over again.

https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored

Copy link

github-actions bot commented Nov 7, 2023

📖 The updated storybook is available here

Copy link

github-actions bot commented Nov 7, 2023

🚀 New react-contoso sample application deployed here

Signed-off-by: Martin Musale <[email protected]>
Copy link

github-actions bot commented Nov 7, 2023

📖 The updated storybook is available here

Copy link

github-actions bot commented Nov 7, 2023

🚀 New react-contoso sample application deployed here

@sebastienlevert
Copy link
Contributor

sebastienlevert commented Nov 7, 2023

This starts to look really great! Couple comments:

  • The color scheme for the AC styles should be closer to Web Light. Can you assign fluent tokens?
  • The fonct used in the ACs should be the same (style, size, family) than the rest of the messages)
  • Width of AC should be limited. When looking at Teams, the max-width of any message is calc(100% - 212px). Not exactly the same for us (we have a larger surface) but something like calc(100% - 400px) seems pretty good and represents a very similar rendering than in Teams.
  • Some button sections are doubled?
    image
    Card is the following payload:
{
    "type": "AdaptiveCard",
    "body": [
        {
            "columns": [
                {
                    "width": "auto",
                    "items": [
                        {
                            "size": "medium",
                            "style": "person",
                            "url": "https://focusworksaistrg.blob.core.windows.net/images/color.png",
                            "height": "auto",
                            "type": "Image"
                        }
                    ],
                    "type": "Column"
                },
                {
                    "width": "stretch",
                    "items": [
                        {
                            "size": "large",
                            "text": "Create images by describing them in your own language!",
                            "weight": "bolder",
                            "wrap": true,
                            "type": "TextBlock"
                        }
                    ],
                    "type": "Column"
                }
            ],
            "type": "ColumnSet"
        },
        {
            "size": "medium",
            "text": "🌟 Want a snazzy image for making the next presentation pop?\\💎 If you are on our paid plan, you can just tell me to create an image by providing a brief description.",
            "wrap": true,
            "type": "TextBlock"
        },
        {
            "text": "_\\"Create an image of a daring astronaut, space suit and helmet, standing in front of futuristic spaceship, adventurous, detailed, high detail, portrait\\"_",
            "wrap": true,
            "type": "TextBlock"
        },
        {
            "actions": [
                {
                    "url": "https://teams.microsoft.com/l/entity/ac68a41d-6b5a-432c-aba9-e1a0ca1e2a3e/47fa9af7-a1ea-46d9-9607-34dbffc5b7e7",
                    "title": "Subscribe from the Dashboard",
                    "type": "Action.OpenUrl"
                }
            ],
            "type": "ActionSet"
        },
        {
            "horizontalAlignment": "center",
            "url": "https://focusworksaistrg.blob.core.windows.net/images/aiimg1.png",
            "height": "auto",
            "type": "Image"
        },
        {
            "size": "medium",
            "text": "So go ahead and start creating images right now! ",
            "wrap": true,
            "type": "TextBlock"
        },
        {
            "actions": [
                {
                    "url": "https://forms.microsoft.com/e/Tdy8KgRuuc",
                    "title": "Want a customized version of Focusworks AI for your organization? Contact us.",
                    "type": "Action.OpenUrl"
                }
            ],
            "type": "ActionSet"
        }
    ],
    "version": "1.5",
    "msTeams": {
        "width": "full"
    }
}

and in Teams it look like this:

image

  • Carousel are not supported right now (multiple ACs on the same message, with a carousel experience). I'm ok with leaving them behind, for now, but we'll have to identify a way to support them as some point. (It seems that caroussels can ONLY be a list of attachments, without no other markup, vs. a message with multiple adaptive cards that wraps them in a

    ).

Copy link

📖 The updated storybook is available here

Copy link

🚀 New react-contoso sample application deployed here

Copy link

📖 The updated storybook is available here

Copy link

🚀 New react-contoso sample application deployed here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress 🚧
Development

Successfully merging this pull request may close these issues.

[mgt-chat] Render Adaptive Cards
3 participants