npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

teams-view-builder

v0.0.1

Published

Teams view builder containing re-usable blocks to be used on any ms-teams app

Downloads

87

Readme

teams-view-builder

Getting started

This is a simple package that can be used to create the blocks and views required to interact with users on any Microsoft Teams Application.

Installation

 npm install --save teams-view-builder

Usage

Render a Text Block in an adaptive card

const TeamsViewBuilder = require("teams-view-builder");

renderTextBlock() {
    const body = [
        TeamsViewBuilder.Elements.textBlock({
            text: "Hello World!",
        })
    ]
    return TeamsViewBuilder.Cards.adaptiveCard({
        body
    })
}

// OR

const { Elements, Cards } = require("teams-view-builder");

renderTextBlock() {
    const body = [
        Elements.textBlock({
            text: "Hello World!",
        })
    ]
    return Cards.adaptiveCard({
        body
    })
}

Render an Image in an adaptive card

const TeamsViewBuilder = require("teams-view-builder");

renderImage() {
    const body = [
        TeamsViewBuilder.Elements.image({
            url: "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg",
            altText: "Matt Hidinger",
            size: TeamsViewBuilder.Elements.ImageSizes.small
        })
    ]
    return TeamsViewBuilder.Cards.adaptiveCard({
        body
    })
}

Render a ColumnSet in an adaptive card

const TeamsViewBuilder = require("teams-view-builder");

renderColumnSet() {
    const body = [
        TeamsViewBuilder.Containers.columnSet({
            columns: [
                TeamsViewBuilder.Containers.column({
                    items: [
                        TeamsViewBuilder.Elements.textBlock({
                            text: "Hello World!",
                        })
                    ]
                }),
                TeamsViewBuilder.Containers.column({
                    items: [
                        TeamsViewBuilder.Elements.image({
                            url: "https://pbs.twimg.com/profile_images/3647943215/d7f12830b3c17a5a9e4afcc370e3a37e_400x400.jpeg",
                            altText: "Matt Hidinger",
                            size: TeamsViewBuilder.Elements.ImageSizes.small
                        })
                    ]
                })
            ]
        })
    ]
    return TeamsViewBuilder.Cards.adaptiveCard({
        body
    })
}

Tag a user in the text block of an adaptive card

const TeamsViewBuilder = require("teams-view-builder");

tagUserInTextBlock(userName, userId) {
    const body = [
        TeamsViewBuilder.Elements.textBlock({
            text: `Hello <@${userName}>`,
        })
    ]
    return TeamsViewBuilder.Cards.adaptiveCard({
        body,
        entities: [
            TeamsViewBuilder.Entity.tag(userName, userId)
        ]
    })
}

// OR

tagUserInTextBlock(userName, userId) {
    const body = [
        TeamsViewBuilder.Elements.textBlock({
            text: `Hello ${TeamsViewBuilder.Entity.tagify(userName)}`,
        })
    ]
    return TeamsViewBuilder.Cards.adaptiveCard({
        body,
        entities: [
            TeamsViewBuilder.Entity.tag(userName, userId)
        ]
    })
}

Render a Text Block with Action Buttons in an adaptive card

const TeamsViewBuilder = require("teams-view-builder");

renderTextBlockWithActions() {
    const body = [
        TeamsViewBuilder.Elements.textBlock({
            text: "Hello World!",
        })
    ]

    const actions = [
        TeamsViewBuilder.Actions.submit({
            title: "Cancel",
            style: TeamsViewBuilder.Actions.ActionStyles.danger,
            data: {
                value: 'Cancel'
            }
        }),
        TeamsViewBuilder.Actions.openUrl({
            title: "Open Link",
            style: TeamsViewBuilder.Actions.ActionStyles.primary,
            url: "https://teams.microsoft.com/l/entity/ABCDE-12345-SAMPLE/tab"
        })
    ]

    return TeamsViewBuilder.Cards.adaptiveCard({
        body,
        actions
    })
}

// OR

renderTextBlockWithActions() {
    const body = [
        TeamsViewBuilder.Elements.textBlock({
            text: "Hello World!",
        }),
        TeamsViewBuilder.Containers.actionSet({
            actions: [
                TeamsViewBuilder.Actions.submit({
                    title: "Cancel",
                    style: TeamsViewBuilder.Actions.ActionStyles.danger,
                    data: {
                        value: 'Cancel'
                    }
                }),
                TeamsViewBuilder.Actions.openUrl({
                    title: "Open Link",
                    style: TeamsViewBuilder.Actions.ActionStyles.primary,
                    url: "https://teams.microsoft.com/l/entity/ABCDE-12345-SAMPLE/tab"
                })
            ]
        })
    ]
    return TeamsViewBuilder.Cards.adaptiveCard({
        body
    })
}

Render Select Dropdown in an adaptive card

const TeamsViewBuilder = require("teams-view-builder");

renderSelectDropDown() {
    const choices = [
        TeamsViewBuilder.Input.choice({
            title: "choice 1",
            value: "1"
        }),
        TeamsViewBuilder.Input.choice({
            title: "choice 2",
            value: "2"
        })
    ]

    const body = [
        TeamsViewBuilder.Input.select({
            choices,
            placeholder: 'Select a value',
            wrap: true,
            spacing: TeamsViewBuilder.Input.Spacing.small,
            value: 'value',
            id: 'selectDropDown'
        })
    ]

    return TeamsViewBuilder.Cards.adaptiveCard({
        body
    })
}

License

teams-view-builder is licensed under the MIT License.