question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Themeable icons/glyphs

See original GitHub issue

Summary

Today, it’s impossible to author a card that has icon images within it that works on both a dark and light background.

Light theme
Dark theme

Neither is the card theme aware. If it were, we could allow users to provide multiple images for light mode or dark mode.

Requirements

  • P0: Author can provide different images for light and dark themes

    • We could solve this with requires (say requires dark theme, then fallback to different image). But we’ll wait for more requests.
  • P0: Author can provide a tintable image that automatically themes

  • P1: Author can specify semantic tint colors (accent, attention, good, etc)

  • P1: Author can provide a set of icons so that each icon isn’t a separate http request

Spec/schema

https://github.com/microsoft/AdaptiveCards/pull/3092/files

Proposal options

  • Option 1: PNGs with tint property

    • Author provides a PNG that’s tintable, all non-transparent pixels get tinted the color.
  • Option 2: SVGs with tint property

    • Author provides a SVG that’s tintable, all non-transparent vectors get tinted the color.
  • Option 3: Icon fonts

    • Author provides icon font and uses font characters from that font.

PNGs
SVGs
Icon fonts
Authoring story
Developer creates and provides a PNG
Developer creates and provides a SVG
Developer creates and provides the icon font files (multiple files) at their top-level card and then references that font
Authoring simplicity
Simple until you worry about scaling
Somewhat complex, need to be able to produce SVGs
Complex, need to produce your icons as SVGs and then use tooling to produce a font out of that
Scalability
Doesn’t scale
Scales
Scales
Download size
< 0.5 KB per icon
< 0.5 KB per icon
200 KB for ALL of Material Icons

of requests

1 per icon
1 per icon
1 per icon set
Allows custom fonts
No
No
Yes, there’s no way for us to tell if they’re using it as intended for icons, or using it for text
Web
Complex, have to manipulate pixels
Moderately complex, would have to modify SVG XML and replace the fill colors
Simple
Android
Simple (tint property)
Simple (tint property)
Simple
UWP
Complex, manipulate pixels
Complex, modify SVG XML
Simple

What do people say on SVG vs Icon Fonts?

Option 1: PNGs with tint property

Very straightforward for anyone to use, even those who don’t have access to Adobe software. However, images aren’t scalable. This also requires lots of work on renderers.

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "Image",
            "url": "https://user-images.githubusercontent.com/13246069/59642306-4a673b00-9119-11e9-8408-b0b96fd64dd6.png",
            "size": "Small",
            "tint": "accent"
        }
    ],
    "version": "1.0"
}

Option 2: SVGs with tint property

Mostly straightforward for anyone to use, but does require SVG software like Adobe software. Results in scalable images. However, requires work on renderers.

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "Svg",
            "url": "https://user-images.githubusercontent.com/13246069/59642306-4a673b00-9119-11e9-8408-b0b96fd64dd6.svg",
            "size": "Small",
            "tint": "accent"
        }
    ],
    "version": "1.0"
}

Option 3: Icon fonts

Not the most straightforward, requires SVG software like Adobe software and also software to generate an icon font from the SVG. Results in scalable images. Minimal work on renderers.

UWP uses the TTF file

{
  "type": "AdaptiveCard",
  "customFontFamilies": {
    "myIcons": {
      "eot": "https://example.com/fonts/font.eot",
      "woff": "https://example.com/fonts/font.woff",
      "woff2": "https://example.com/fonts/font.woff2",
      "truetype": "https://example.com/fonts/font.ttf",
      "svg": "https://example.com/fonts/font.svg"
    }
  },
  "body": [
      {
          "type": "FontIcon",
          "text": "󥎉",
          "fontFamily": "myIcons",
          "size": "Small",
          "tint": "accent"
      }
  ],
  "version": "1.0"
}

Proposed changes (based on png option)

Add a tint property to Image, which takes any of our foreground semantic colors (like good, default, etc)

Add an icon property to Action (and deprecate iconUrl), which has two properties…

  • url

  • tintable boolean (in actions, authors don’t get to pick semantic colors since it’s controlled by the host)

Example

In body matching accent color

Sometimes you need icon images to match the accent color… (Look at the plane icons)

Cortana
Teams

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "items": [
                        {
                            "type": "Image",
                            "url": "https://user-images.githubusercontent.com/13246069/59642306-4a673b00-9119-11e9-8408-b0b96fd64dd6.png",
                            "size": "Small",
                            "tint": "accent"
                        }
                    ],
                    "width": "auto"
                }
            ]
        }
    ],
    "version": "1.0"
}

On actions

Notice that it’s not even just white vs black… it’s actually white and Teams purple… every host can have their own tints

Light theme
Dark theme

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "FactSet",
            "facts": [
                {
                    "title": "Board:",
                    "value": "Adaptive Card"
                }
            ]
        }
    ],
    "actions": [
        {
            "type": "Action.Submit",
            "title": "Set due date",
            "icon": {
                "url": "https://cdn3.iconfinder.com/data/icons/computers-programming/512/datepicker-512.png",
                "tintable": true
            },
            "data": "submitData"
        },
        {
            "type": "Action.OpenUrl",
            "title": "View",
            "icon": {
                "url": "https://cdn2.iconfinder.com/data/icons/picol-vector/32/view-512.png",
                "tintable": true
            },
            "url": "http://adaptivecards.io"
        }
    ],
    "version": "1.0"
}

Host Config

New property, actions.iconTint, which takes a hex color string. This is so that a separate tint can be specified on actions (like the purple Teams tint). Other images will get the default color tint.

    "actions": {
        "maxActions": 6,
        "spacing": "Default",
        "buttonSpacing": 8,
        "iconTint": "#FFFFFF",
        "showCard": {
            "actionMode": "Inline",
            "inlineTopMargin": 16,
            "style": "emphasis"
        },
        "preExpandSingleShowCardAction": false,
        "actionsOrientation": "Horizontal",
        "actionAlignment": "Left"
    },

Down-level impact

Medium. For Image elements, no worse than today 😃 But for actions, since the property changed, they have to be aware of adding the old property if they want their icon to appear in old versions.

Host burden

Small. Simply provide the action tint color.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bandtankcommented, Feb 12, 2023

Did this happen? I can’t find documentation, but it says completed in the issue’s history.

0reactions
msftbot[bot]commented, Dec 6, 2019

This issue has been automatically marked as stale because it has not had any activity for 5 days.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Themeable Icons/Glyphs Support in AdaptiveCards
A new way for developers to exchange card content in a common and consistent way. - Themeable Icons/Glyphs Support in AdaptiveCards ...
Read more >
icons/glyphs by marcelo pérez
... examples - A collection of design inspiration titled icons/glyphs by marcelo pérez. ... Flippi Android Icons camera china icons miui sanityd sms...
Read more >
UI: Icons & Glyphs
Jan 14, 2017 - Explore Alex's board "UI: Icons & Glyphs" on Pinterest. See more ideas about icon design, icon, pictogram.
Read more >
Theme Icon - Download in Glyph Style
Just download this Theme icon in Glyph style. Available in SVG, PNG, ICO, ICNS, EPS and AI formats. Change colors, strokes, and add...
Read more >
Glyph Icons Social Media Set
Jan 12, 2019 - Our Social set (50 Glyph icons) is a part of our discounted mega bundle --- We are excited to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found