workplacebuddy/adaptive-card

Classes and enums to generate Adaptive Card elements

v1.0.3 2023-10-05 13:33 UTC

This package is auto-updated.

Last update: 2024-04-03 11:55:17 UTC


README

Classes and enums to generate Adaptive Card elements

Definitions are generated from the schema.

Usage

Most of the classes are available in the AdaptiveCard namespace:

  • AdaptiveCard/AdaptiveCard for the main card
  • AdaptiveCard/Colors to fiddle with some colors
  • Etc..

Some more specific elements are in their own namespaces, like the actions and the inputs:

  • AdaptiveCard\Action\OpenUrl to open an URL when clicked
  • AdapticeCard\Input\Text to ask for some text
  • Etc..

All elements can be found here: https://adaptivecards.io/explorer/, everything should be available -- the elements are generated directly from the manifest/schema.

All elements also have a static method to quickly create a single element: make.

For example

$card = new AdaptiveCard\AdapticeCard();

$card->body = [AdaptiveCard\TextBlock::make(text: 'Hello world!')];

$card->actions = [
    AdapticeCard\Action\OpenUrl::make(
        title: 'Website',
        url: 'https://www.workplacebuddy.com/',
    ),
];

How to generate

  • Clone this repo
  • Install the dependencies, both from Packagist and NPM
    • composer install
    • yarn
    • Prettier is used to format the end result
  • Optionally run composer run fetch-schema to fetch a fresh schema
  • Run composer run generate to generate a new version of classes/enums