{"id":306,"date":"2013-05-30T10:56:34","date_gmt":"2013-05-30T14:56:34","guid":{"rendered":"http:\/\/www.dontpapanic.com\/blog\/?p=306"},"modified":"2013-05-31T08:01:51","modified_gmt":"2013-05-31T12:01:51","slug":"make-app-icons-that-change-with-a-composed-look","status":"publish","type":"post","link":"https:\/\/www.dontpapanic.com\/blog\/?p=306","title":{"rendered":"Make App Icons that Change with a Composed Look"},"content":{"rendered":"<p><a href=\"http:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2013\/05\/Animated.gif\"><img loading=\"lazy\" decoding=\"async\" title=\"Animated\" style=\"float: left; margin: 0px 10px 0px 0px; display: inline\" alt=\"Animated\" align=\"left\" src=\"http:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2013\/05\/Animated_thumb.gif\" width=\"96\" height=\"96\" \/><\/a><\/p>\n<p>Recently a developer friend was wondering why all the built-in App Icons changed colors on his SharePoint 2013 site when he applied a different color scheme using the \u201cComposed Looks\u201d functionality,but Icons for custom apps he had deployed remained their original color.&#160; The screenshot below shows the Site Contents page both before (Left Side) and after a Theme has been applied using a Composed Look (Right Side).&#160; You can see that all the Icons on the page changed except the last one on the right.&#160; This is the App that I installed using the Visual Studio 2012 SharePoint Hosted App project.&#160; So the question is <em>Why do all the other Icons change?<\/em><\/p>\n<p><a href=\"http:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2013\/05\/Appssidebyside.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"Appssidebyside\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 10px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"Appssidebyside\" src=\"http:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2013\/05\/Appssidebyside_thumb.jpg\" width=\"644\" height=\"244\" \/><\/a><\/p>\n<p>The first theory was that the App Icons were being recolored using the Theme CSS support that has been available since SharePoint 2010.&#160; But the ability to recolor an image using CSS has always been limited to background images loaded through CSS.&#160; These Icons are loaded using an &lt;IMG&gt; element so there is no way to specify the image in CSS and no way to recolor it.<\/p>\n<p>After using IE\u2019s Developer toolbar to examine the HTML and CSS on the pages above I found that the image itself doesn\u2019t get recolored. But the &lt;a&gt; (anchor tag) that surrounds the Icon is a square rectangle occupying the space behind each image that has its background set to one of the theme colors.&#160; You can see in the screenshot below that the &lt;a&gt; tag has its background set to a class of \u201cms-storefront-appiconspan\u2019 which is set to an rgb color from a themable css file.&#160; <em>But why does changing the background behind the Icon change the color of the Icon?<\/em><\/p>\n<p><a href=\"http:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2013\/05\/appIconBackground.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"appIconBackground\" style=\"display: inline\" alt=\"appIconBackground\" src=\"http:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2013\/05\/appIconBackground_thumb.jpg\" width=\"1024\" height=\"238\" \/><\/a><\/p>\n<p>The trick is that the Icon file itself is a transparent PNG that is the same size, 90 X 90 pixels, as the anchor tag with the background color behind it.&#160; That way the background color shows through the Icon and appears to recolor the icon itself.&#160; So let\u2019s see what happens to my Visual Studio project if I replace the blue in my App Icon with a Transparent background.&#160; the image below shows the original Icon on the left and the new transparent Icon on the right after I cut the background out using <a href=\"http:\/\/www.getpaint.net\/download.html\" target=\"_blank\">Paint.Net<\/a>.<\/p>\n<p><a href=\"http:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2013\/05\/appIcons.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"appIcons\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"appIcons\" src=\"http:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2013\/05\/appIcons_thumb.jpg\" width=\"644\" height=\"324\" \/><\/a><\/p>\n<p>After uploading the new Icon image into my visual Studio project and redeploying the custom app you can see that the custom app Icon changes colors along with the Theme in the screenshot below.&#160; If you restrict your Icon to white images and text on a transparent background then your Icon should look like it fits no matter what Composed Look is applied to your site.<\/p>\n<p><a href=\"http:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2013\/05\/AppAfter.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"AppAfter\" style=\"border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px\" border=\"0\" alt=\"AppAfter\" src=\"http:\/\/www.dontpapanic.com\/blog\/wp-content\/uploads\/2013\/05\/AppAfter_thumb.jpg\" width=\"644\" height=\"484\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently a developer friend was wondering why all the built-in App Icons changed colors on his SharePoint 2013 site when he applied a different color scheme using the \u201cComposed Looks\u201d functionality,but Icons for custom apps he had deployed remained their original color.&#160; The screenshot below shows the Site Contents page both before (Left Side) and &hellip; <a href=\"https:\/\/www.dontpapanic.com\/blog\/?p=306\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Make App Icons that Change with a Composed Look<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[59,63,84],"tags":[19,60,23],"class_list":["post-306","post","type-post","status-publish","format-standard","hentry","category-sharepoint-2013","category-sharepoint-2013-dev","category-tips","tag-development","tag-sharepoint_2013","tag-tips"],"_links":{"self":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=306"}],"version-history":[{"count":1,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/306\/revisions"}],"predecessor-version":[{"id":309,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/306\/revisions\/309"}],"wp:attachment":[{"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dontpapanic.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}