OfficeDev / BotBuilder-MicrosoftTeams

Microsoft Bot Builder extension library for developing bots for Microsoft Teams
MIT License
256 stars 150 forks source link

Please add simple "color" support to O365ConnectorCard.themeColor() #48

Open billbliss opened 7 years ago

billbliss commented 7 years ago

Request: add the special values good, warning, and danger as theme colors. Slack has these and it's a lot easier than looking up the hex values.

I'm not set up to build or test this, but this works in my own version. If you'd rather, I could just submit a PR but it's not very clear how to set up the build environment and run the tests. @robin-liao I'll contact you offline.

Suggested source:

    public themeColor(color: string): this {
        if (color) {
            color = color.toLowerCase();
            switch (color) {
              case "good":
                (<teams.IO365ConnectorCard>this.data.content).themeColor = "#2ea34e"; // Green
                break;
              case "warning":
                (<teams.IO365ConnectorCard>this.data.content).themeColor = "#de9d30"; // Yellow
                break;
              case "danger":
                (<teams.IO365ConnectorCard>this.data.content).themeColor = "#d50000"; // Red
                break;
              default:
                (<teams.IO365ConnectorCard>this.data.content).themeColor = color;
            }
            (<teams.IO365ConnectorCard>this.data.content).themeColor = color;
        } else {
            delete (<teams.IO365ConnectorCard>this.data.content).themeColor;
        }
        return this;
    }

Current source:

    public themeColor(color: string): this {
        if (color) {
            (<teams.IO365ConnectorCard>this.data.content).themeColor = color;
        } else {
            delete (<teams.IO365ConnectorCard>this.data.content).themeColor;
        }
        return this;
    }
majordamage commented 7 years ago

The documentation for themeColor appears to disallow such use. Quoting:

billbliss commented 7 years ago

That's nonsense. That's exactly what it's for.

billbliss commented 7 years ago

(That documentation is incorrect.)

majordamage commented 7 years ago

I suspect (although have no direct knowledge) that's why this property is named themeColor instead of simply color in the Slack style. Its usage parallels the ThemeColor class in SharePoint.

Having said that, I don't see any other candidate property that'd serve the purpose you propose, so...

RamjotSingh commented 7 years ago

Are we looking into this? Or has this been resolved?