microsoft / AdaptiveCards

A new way for developers to exchange card content in a common and consistent way.
https://adaptivecards.io
MIT License
1.74k stars 543 forks source link

font colours different on slack and Telegram #1112

Closed yogiderek closed 5 years ago

yogiderek commented 6 years ago

Bot Info

Issue Description

In Web Chat my adaptive card correctly shows notification text related to today and tomorrow in red and 2 days from today in yellow. However, in Slack and Telegram, the notification text colour is swapped around i.e. text related to today and tomorrow is yellow and 2 days from today is now red.

Note also that the alignment of images is correct in both Slack and Telegram but not in Chat.

Code Example

        int numDays = (int)(kvp.Key - DateTime.Today).TotalDays;
        string days = string.Format("{0} days' time.", numDays);
        AdaptiveTextColor color = AdaptiveTextColor.Default;
        AdaptiveTextWeight weight = AdaptiveTextWeight.Default;
        bool isSubtle = true;
        if (numDays == 0)
        {
            days = "Today";
            color = AdaptiveTextColor.Warning;
            weight = AdaptiveTextWeight.Bolder;
            isSubtle = false;
        }
        else if (numDays == 1)
        {
            days = "Tomorrow";
            color = AdaptiveTextColor.Warning;
            weight = AdaptiveTextWeight.Bolder;
            isSubtle = false;
        }
        else if (numDays == 2)
        {
            color = AdaptiveTextColor.Attention;
            weight = AdaptiveTextWeight.Bolder;
            isSubtle = false;
        }
        else
        {
        }

Expected Behaviour

Text colour to be consistent across all channels.

Actual Results

Red is now yellow and yellow is now red in the Slack and Telegram channels. See screenshots, image order is Web Chat, Slack, Telegram.

chat slack telegram

dclaux commented 6 years ago

While each host is free to pick its preferred colors for the various named colors Adaptive provides, it does seem that Slack and Telegram should invert the attention and warning colors as red is usually the better color for a "warning"

yogiderek commented 6 years ago

With some help from Slack, the following link message-attachments defines the colours used as good (green), warning (orange) and danger (red) whereas the adaptive cards use good (green), attention (yellow) and warning (red). According to slack technical the colours should, "exactly match the color wording in Slack."

If I am right then the first two columns show what happens just now and the last column shows what it should be to map to Slacks colours.

Slack                                MS Bot (Now)                    MS Bot (Corrected)
----------------------        --------------------             -------------------------
good (green)                     Good (green)                    Good (green)
warning (orange)              Attention (yellow)             Warning (yellow)
danger (red)                      Warning (red)                    Danger (red)
matthidinger commented 6 years ago

Hi @yogiderek thanks for reporting this. Looks like we've got the colors swapped.

@eanders-MS FYI

eanders-ms commented 6 years ago

Hm, I will check the host configs of each channel....

dclaux commented 6 years ago

Adaptive doesn't have a "danger" color though. I'm not sure I'm following here.

yogiderek commented 6 years ago

You are right, AdaptiveCards does not define the Danger colour. Perhaps this explains it better....

According to slack, the colour names must match the slack colour names exactly.

the 'good' names match exactly, so text colour is green (slacks definition)

the switch happens here 'warning' names match so the text colour is orange (slacks definition) 'Attention' name is not defined by slack so it is possible that slack defaults to red in an error condition if the string is not found.

Although the slack docs state that you can define a custom hex colour, Attention is a string and not a hex value.

I could not find anything in the Telegram docs defining what colours they use.

dclaux commented 6 years ago

To clarify things: Adaptive Cards are rendered server-side as images in Slack and Telegram. The color scheme Slack documents is therefore irrelevant in this context. As @matthidinger was suggesting, it looks like our image renderer has the warning and attention colors swapped.

eanders-ms commented 6 years ago

The Host Config in use by the Bot Framework for server-side rendering looks correct. As previously mentioned, the colors might be getting swapped in the WPF renderer.

andrewleader commented 5 years ago

Seems like this is fixed in WPF now as of 1.2 (and potentially earlier)