adaptive-cards-io


Nameadaptive-cards-io JSON
Version 1.3.2 PyPI version JSON
download
home_pagehttps://github.com/melquibrito/adaptive-cards
SummaryA lightweight framework for building MS adaptive cards programmatically.
upload_time2024-08-11 23:56:19
maintainerMelqui Brito
docs_urlNone
authorMelqui Brito
requires_python>=3.7
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![](https://img.shields.io/badge/build-v1.3.2-green.svg) ![](https://img.shields.io/badge/python-3.7_|_3.8_|_3.9_|_3.10_|_3.11_|_3.12-yellow.svg)

# Adaptive Cards Framework
## Baseline
### What are Adaptive Cards? 
[Adaptive Cards](https://adaptivecards.io/) are platform-agnostic snippets of UI, authored in JSON, that apps and services can openly exchange. When delivered to a specific app, the JSON is transformed into native UI that automatically adapts to its surroundings. It helps design and integrate light-weight UI for all major platforms and frameworks.

### Why do I need a framework?
Building an application that effectively serves Adaptive Cards can be complex and time-consuming. Without a framework, you'd need to thoroughly navigate the entire Adaptive Cards documentation to ensure proper implementation, which can slow down development and hinder scalability. While tools like the [designer.io](https://adaptivecards.io/designer/) page can assist with prototyping and creating JSON components, relying solely on these can limit your application's growth potential. By leveraging a framework, you streamline the process, allowing you to focus on crafting your cards with confidence and efficiency, without the worry of underlying technical details.

## About
**adaptive-cards-io** is a Python package designed to simplify the creation, manipulation, and integration of Adaptive Cards in your applications. Adaptive Cards are a powerful way to build lightweight, responsive user interfaces that seamlessly adapt to different platforms and environments. With **adaptive-cards-io**, you can efficiently generate and manage these cards, ensuring they are optimized and correctly formatted for your specific needs.

This package offers a streamlined approach, allowing developers to focus on designing and deploying Adaptive Cards without getting bogged down by the intricacies of the underlying JSON structure. Whether you're building prototypes or scaling up to a production environment, **adaptive-cards-io** provides the tools and framework to enhance productivity and reduce development time.

## Installation
1. Make sure PIP is up-to-date:
```bash
python3 -m pip install --upgrade pip
```

2. Install the package:
```bash
python3 -m pip install adaptive-cards-io
```

## Usage
### Importing
```python
from adaptive_cards import *
```
By importing everything, all of the following will become available in your python module:

#### Enumerators
- MaterialType
- ActionType
- InputType
- MaterialColor
- MaterialHeight
- MaterialOrientation
- HorizontalAlignment
- VerticalAlignment
- MaterialSpacing
- ActionTheme
- ActionMode
- ActionRole
- BackgroundFillMode
- AssociatedInputs
- TargetFreezing
- ContainerTheme
- ColumnWidth
- TextTheme
- FontType
- TextSize
- FontWeight
- ImageSize
- ImageTheme
- MediaMimeType
- CaptionMimeType
- ChoiceSetMode
- InputTextMode

#### Building Blocks
- Material
- MaterialDynamic
- MaterialMapping
- MaterialLayout
- AdaptiveCardMaterial
- BackgroundImage
- AdaptiveCardAction

#### Units
- Weight
- Seconds
- Pixels

#### Base
- AdaptiveCardLayout
- AdaptiveCard

#### Actions
- ActionSubmit
- ActionOpenUrl
- ActionShowCard
- ActionToggleVisibility
- TargetElement
- ActionExecute
- ActionSetLayout
- ActionSet
- MSTeams
- ActionData

#### Containers
- ContainerStyle
- ContainerLayout
- Container
- ColumnLayout
- Column
- ColumnSetLayout
- ColumnSet
- FactSetLayout
- Fact
- FactSet
- ImageSetLayout
- ImageSet
- TableLayout
- TableCell
- TableRow
- GridStyle
- Table
- CarouselPage
- Carousel

#### Inputs
- InputValidation
- InputLayout
- AdaptiveCardInput
- InputChoice
- InputChoiceSet
- InputTextValidation
- InputText
- InputNumber
- InputDate
- InputTime
- InputToggle

#### General
- TextLayout
- TextStyle
- TextBlock
- ImageLayout
- ImageStyle
- Image
- MediaLayout
- MediaSource
- MediaCaptions
- Media

## Example
```python
from adaptive_cards import *
import json

official_example = AdaptiveCard(
    version=1.5,
    schema="http://adaptivecards.io/schemas/adaptive-card.json",
    body=[
        TextBlock("${title}", style=TextStyle(size=TextSize.MEDIUM, weight=FontWeight.BOLDER)),
        ColumnSet(
            columns=[
                Column(
                    layout=ColumnLayout(width=ColumnWidth.AUTO),
                    items=[
                        Image(
                            "${creator.profileImage}",
                            style=ImageStyle(theme=ImageTheme.PERSON),
                            layout=ImageLayout(size=ImageSize.SMALL),
                            alternate_text="${creator.name}"
                        )
                    ]
                ),
                Column(
                    items=[
                        TextBlock("${creator.name}", style=TextStyle(weight=FontWeight.BOLDER)),
                        TextBlock(
                            "Created {{DATE(${createdUtc},SHORT)}}", 
                            style=TextStyle(subtle=True),
                            layout=TextLayout(spacing=MaterialSpacing.NONE)
                        )
                    ]
                )
            ]
        ),
        TextBlock("${description}"),
        FactSet(
            facts=[
                Fact(title="${key}:", value="${value}").using("${properties}"),
            ]
        )
    ],
    actions=[
        ActionShowCard(
            title="Set due date",
            card=AdaptiveCard(
                schema="http://adaptivecards.io/schemas/adaptive-card.json",
                body=[
                    InputDate(id="dueDate"),
                    InputText(id="comment", placeholder="Add a comment", multiline=True)
                ],
                actions=[ActionSubmit(title="OK")]
            )
        ),
        ActionOpenUrl(title="View", url="${viewUrl}")
    ]
)

print(json.dumps(official_example.__dict__, indent=4))
```

### Output
```json
{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "TextBlock",
            "text": "${title}",
            "wrap": true,
            "size": "Medium",
            "weight": "Bolder"
        },
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "Image",
                            "url": "${creator.profileImage}",
                            "altText": "${creator.name}",
                            "size": "Small",
                            "style": "Person"
                        }
                    ],
                    "width": "auto"
                },
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "${creator.name}",
                            "wrap": true,
                            "weight": "Bolder"
                        },
                        {
                            "type": "TextBlock",
                            "text": "Created {{DATE(${createdUtc},SHORT)}}",
                            "wrap": true,
                            "spacing": "None",
                            "isSubtle": true
                        }
                    ]
                }
            ]
        },
        {
            "type": "TextBlock",
            "text": "${description}",
            "wrap": true
        },
        {
            "type": "FactSet",
            "facts": [
                {
                    "$data": "${properties}",
                    "title": "${key}:",
                    "value": "${value}"
                }
            ]
        }
    ],
    "actions": [
        {
            "type": "Action.ShowCard",
            "title": "Set due date",
            "card": {
                "type": "AdaptiveCard",
                "body": [
                    {
                        "type": "Input.Date",
                        "id": "dueDate"
                    },
                    {
                        "type": "Input.Text",
                        "id": "comment",
                        "placeholder": "Add a comment",
                        "isMultiline": true
                    }
                ],
                "version": "1.6",
                "actions": [
                    {
                        "type": "Action.Submit",
                        "title": "OK",
                        "associatedInputs": "auto"
                    }
                ],
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
            }
        },
        {
            "type": "Action.OpenUrl",
            "title": "View",
            "url": "${viewUrl}"
        }
    ],
    "version": "1.5",
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/melquibrito/adaptive-cards",
    "name": "adaptive-cards-io",
    "maintainer": "Melqui Brito",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "melquibrito07@gmail.com",
    "keywords": null,
    "author": "Melqui Brito",
    "author_email": "melquibrito07@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/45/50/f5ebba31fc1277c886902b01cb0615e861fad6b2abc6338e2209323d6f2c/adaptive-cards-io-1.3.2.tar.gz",
    "platform": null,
    "description": "![](https://img.shields.io/badge/build-v1.3.2-green.svg) ![](https://img.shields.io/badge/python-3.7_|_3.8_|_3.9_|_3.10_|_3.11_|_3.12-yellow.svg)\n\n# Adaptive Cards Framework\n## Baseline\n### What are Adaptive Cards? \n[Adaptive Cards](https://adaptivecards.io/) are platform-agnostic snippets of UI, authored in JSON, that apps and services can openly exchange. When delivered to a specific app, the JSON is transformed into native UI that automatically adapts to its surroundings. It helps design and integrate light-weight UI for all major platforms and frameworks.\n\n### Why do I need a framework?\nBuilding an application that effectively serves Adaptive Cards can be complex and time-consuming. Without a framework, you'd need to thoroughly navigate the entire Adaptive Cards documentation to ensure proper implementation, which can slow down development and hinder scalability. While tools like the [designer.io](https://adaptivecards.io/designer/) page can assist with prototyping and creating JSON components, relying solely on these can limit your application's growth potential. By leveraging a framework, you streamline the process, allowing you to focus on crafting your cards with confidence and efficiency, without the worry of underlying technical details.\n\n## About\n**adaptive-cards-io** is a Python package designed to simplify the creation, manipulation, and integration of Adaptive Cards in your applications. Adaptive Cards are a powerful way to build lightweight, responsive user interfaces that seamlessly adapt to different platforms and environments. With **adaptive-cards-io**, you can efficiently generate and manage these cards, ensuring they are optimized and correctly formatted for your specific needs.\n\nThis package offers a streamlined approach, allowing developers to focus on designing and deploying Adaptive Cards without getting bogged down by the intricacies of the underlying JSON structure. Whether you're building prototypes or scaling up to a production environment, **adaptive-cards-io** provides the tools and framework to enhance productivity and reduce development time.\n\n## Installation\n1. Make sure PIP is up-to-date:\n```bash\npython3 -m pip install --upgrade pip\n```\n\n2. Install the package:\n```bash\npython3 -m pip install adaptive-cards-io\n```\n\n## Usage\n### Importing\n```python\nfrom adaptive_cards import *\n```\nBy importing everything, all of the following will become available in your python module:\n\n#### Enumerators\n- MaterialType\n- ActionType\n- InputType\n- MaterialColor\n- MaterialHeight\n- MaterialOrientation\n- HorizontalAlignment\n- VerticalAlignment\n- MaterialSpacing\n- ActionTheme\n- ActionMode\n- ActionRole\n- BackgroundFillMode\n- AssociatedInputs\n- TargetFreezing\n- ContainerTheme\n- ColumnWidth\n- TextTheme\n- FontType\n- TextSize\n- FontWeight\n- ImageSize\n- ImageTheme\n- MediaMimeType\n- CaptionMimeType\n- ChoiceSetMode\n- InputTextMode\n\n#### Building Blocks\n- Material\n- MaterialDynamic\n- MaterialMapping\n- MaterialLayout\n- AdaptiveCardMaterial\n- BackgroundImage\n- AdaptiveCardAction\n\n#### Units\n- Weight\n- Seconds\n- Pixels\n\n#### Base\n- AdaptiveCardLayout\n- AdaptiveCard\n\n#### Actions\n- ActionSubmit\n- ActionOpenUrl\n- ActionShowCard\n- ActionToggleVisibility\n- TargetElement\n- ActionExecute\n- ActionSetLayout\n- ActionSet\n- MSTeams\n- ActionData\n\n#### Containers\n- ContainerStyle\n- ContainerLayout\n- Container\n- ColumnLayout\n- Column\n- ColumnSetLayout\n- ColumnSet\n- FactSetLayout\n- Fact\n- FactSet\n- ImageSetLayout\n- ImageSet\n- TableLayout\n- TableCell\n- TableRow\n- GridStyle\n- Table\n- CarouselPage\n- Carousel\n\n#### Inputs\n- InputValidation\n- InputLayout\n- AdaptiveCardInput\n- InputChoice\n- InputChoiceSet\n- InputTextValidation\n- InputText\n- InputNumber\n- InputDate\n- InputTime\n- InputToggle\n\n#### General\n- TextLayout\n- TextStyle\n- TextBlock\n- ImageLayout\n- ImageStyle\n- Image\n- MediaLayout\n- MediaSource\n- MediaCaptions\n- Media\n\n## Example\n```python\nfrom adaptive_cards import *\nimport json\n\nofficial_example = AdaptiveCard(\n    version=1.5,\n    schema=\"http://adaptivecards.io/schemas/adaptive-card.json\",\n    body=[\n        TextBlock(\"${title}\", style=TextStyle(size=TextSize.MEDIUM, weight=FontWeight.BOLDER)),\n        ColumnSet(\n            columns=[\n                Column(\n                    layout=ColumnLayout(width=ColumnWidth.AUTO),\n                    items=[\n                        Image(\n                            \"${creator.profileImage}\",\n                            style=ImageStyle(theme=ImageTheme.PERSON),\n                            layout=ImageLayout(size=ImageSize.SMALL),\n                            alternate_text=\"${creator.name}\"\n                        )\n                    ]\n                ),\n                Column(\n                    items=[\n                        TextBlock(\"${creator.name}\", style=TextStyle(weight=FontWeight.BOLDER)),\n                        TextBlock(\n                            \"Created {{DATE(${createdUtc},SHORT)}}\", \n                            style=TextStyle(subtle=True),\n                            layout=TextLayout(spacing=MaterialSpacing.NONE)\n                        )\n                    ]\n                )\n            ]\n        ),\n        TextBlock(\"${description}\"),\n        FactSet(\n            facts=[\n                Fact(title=\"${key}:\", value=\"${value}\").using(\"${properties}\"),\n            ]\n        )\n    ],\n    actions=[\n        ActionShowCard(\n            title=\"Set due date\",\n            card=AdaptiveCard(\n                schema=\"http://adaptivecards.io/schemas/adaptive-card.json\",\n                body=[\n                    InputDate(id=\"dueDate\"),\n                    InputText(id=\"comment\", placeholder=\"Add a comment\", multiline=True)\n                ],\n                actions=[ActionSubmit(title=\"OK\")]\n            )\n        ),\n        ActionOpenUrl(title=\"View\", url=\"${viewUrl}\")\n    ]\n)\n\nprint(json.dumps(official_example.__dict__, indent=4))\n```\n\n### Output\n```json\n{\n    \"type\": \"AdaptiveCard\",\n    \"body\": [\n        {\n            \"type\": \"TextBlock\",\n            \"text\": \"${title}\",\n            \"wrap\": true,\n            \"size\": \"Medium\",\n            \"weight\": \"Bolder\"\n        },\n        {\n            \"type\": \"ColumnSet\",\n            \"columns\": [\n                {\n                    \"type\": \"Column\",\n                    \"items\": [\n                        {\n                            \"type\": \"Image\",\n                            \"url\": \"${creator.profileImage}\",\n                            \"altText\": \"${creator.name}\",\n                            \"size\": \"Small\",\n                            \"style\": \"Person\"\n                        }\n                    ],\n                    \"width\": \"auto\"\n                },\n                {\n                    \"type\": \"Column\",\n                    \"items\": [\n                        {\n                            \"type\": \"TextBlock\",\n                            \"text\": \"${creator.name}\",\n                            \"wrap\": true,\n                            \"weight\": \"Bolder\"\n                        },\n                        {\n                            \"type\": \"TextBlock\",\n                            \"text\": \"Created {{DATE(${createdUtc},SHORT)}}\",\n                            \"wrap\": true,\n                            \"spacing\": \"None\",\n                            \"isSubtle\": true\n                        }\n                    ]\n                }\n            ]\n        },\n        {\n            \"type\": \"TextBlock\",\n            \"text\": \"${description}\",\n            \"wrap\": true\n        },\n        {\n            \"type\": \"FactSet\",\n            \"facts\": [\n                {\n                    \"$data\": \"${properties}\",\n                    \"title\": \"${key}:\",\n                    \"value\": \"${value}\"\n                }\n            ]\n        }\n    ],\n    \"actions\": [\n        {\n            \"type\": \"Action.ShowCard\",\n            \"title\": \"Set due date\",\n            \"card\": {\n                \"type\": \"AdaptiveCard\",\n                \"body\": [\n                    {\n                        \"type\": \"Input.Date\",\n                        \"id\": \"dueDate\"\n                    },\n                    {\n                        \"type\": \"Input.Text\",\n                        \"id\": \"comment\",\n                        \"placeholder\": \"Add a comment\",\n                        \"isMultiline\": true\n                    }\n                ],\n                \"version\": \"1.6\",\n                \"actions\": [\n                    {\n                        \"type\": \"Action.Submit\",\n                        \"title\": \"OK\",\n                        \"associatedInputs\": \"auto\"\n                    }\n                ],\n                \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\"\n            }\n        },\n        {\n            \"type\": \"Action.OpenUrl\",\n            \"title\": \"View\",\n            \"url\": \"${viewUrl}\"\n        }\n    ],\n    \"version\": \"1.5\",\n    \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\"\n}\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A lightweight framework for building MS adaptive cards programmatically.",
    "version": "1.3.2",
    "project_urls": {
        "Homepage": "https://github.com/melquibrito/adaptive-cards"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4550f5ebba31fc1277c886902b01cb0615e861fad6b2abc6338e2209323d6f2c",
                "md5": "2c01adf7db49aa9a46e97e183215b1d3",
                "sha256": "b22e98edaa65b7b74ebfc81c3e1ce1c0ade4d5b3f972ab88054221e2899ecf0c"
            },
            "downloads": -1,
            "filename": "adaptive-cards-io-1.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "2c01adf7db49aa9a46e97e183215b1d3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 15383,
            "upload_time": "2024-08-11T23:56:19",
            "upload_time_iso_8601": "2024-08-11T23:56:19.792325Z",
            "url": "https://files.pythonhosted.org/packages/45/50/f5ebba31fc1277c886902b01cb0615e861fad6b2abc6338e2209323d6f2c/adaptive-cards-io-1.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-11 23:56:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "melquibrito",
    "github_project": "adaptive-cards",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "adaptive-cards-io"
}
        
Elapsed time: 0.36619s