-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PLAY-1138] Icon kit: add a color prop (#3527)
**What does this PR do?** A clear and concise description with your runway ticket url. [PLAY-1138](https://runway.powerhrg.com/backlog_items/PLAY-1138) adds a color prop to the icon kit so that a dev can color an icon with one of the [Playbook color tokens](https://playbook.powerapp.cloud/visual_guidelines/colors). An Icon Color doc example section has been added to the Rails and React Icon kit pages showing how to add a color prop (and showing that it works with both playbook-icons and font awesome icons). The classname is updated to include "color_#{color_token}" when a color token is used. Tests have been added as well. In screenshot section see exploration into color cascade/css hierarchy within an isolated playbook section -> IRL for nitro-web the css in place and cascades/overrides seem to like they are set up with a bit more complexity (and ID specificity). **Screenshots:** Screenshots to visualize your addition/change Rails Icon Color Doc Example <img width="1190" alt="rails for PR" src="https://github.com/user-attachments/assets/29506a9b-6ef8-4c97-988d-37f39c79448a"> React Icon Color Doc Example <img width="1066" alt="react for PR" src="https://github.com/user-attachments/assets/9f57e814-f395-42dd-928a-81225e04b926"> Below is an example of expected/idealized color cascade/hierarchy. Three screenshots from within playbook with example code borrowed from nitro-web's Powerlife Did You Know section. Icon default color (no css wrapper or color prop applied) <img width="326" alt="copied nitro-web no imported styles icon is default color" src="https://github.com/user-attachments/assets/cad52b3b-f8d7-4220-a07a-ab16d0c5d907"> Icon takes color from css wrapper containing it and nearby text <img width="514" alt="copied nitro-web code no color prop but ability does not supersede wrapper" src="https://github.com/user-attachments/assets/c87ceeb9-529e-47f4-a65a-6a60c1b61d85"> Icon takes color from color prop <img width="536" alt="copied nitro-web code color prop supersedes wrapper" src="https://github.com/user-attachments/assets/ed5efb11-b5ea-4fa1-9101-328ed3a9d559"> **How to test?** Steps to confirm the desired behavior: 1. To see the Icon Color doc examples, go to the icon page in the [playbook review environment](https://pr3527.playbook.beta.gm.powerapp.cloud/kits/icon) and scroll down to the Icon Color doc example (or [go there directly](https://pr3527.playbook.beta.gm.powerapp.cloud/kits/icon#icon-color)). 4. See each doc example icon which uses different Playbook color tokens. Several of the icons are from playbook-icons and some are font awesome icons still - this works for them both. 5. To see evidence these changes do not break Nitro, go to the nitro-web review environment example pages [Rails (or go to /projects choose any project)](https://pr41186.nitro-web.beta.gm.powerapp.cloud/projects/3206553) and [React](https://pr41186.nitro-web.beta.gm.powerapp.cloud/user_profile/user_profile). 6. See colored icons on these pages (door-open icon on Door Builder button on Projects page for Rails; envelopes, tshirt, snowflake, boot, syringe, person-dress, utensils icons on User Profile page for React). #### Checklist: - [x] **LABELS** Add a label: `enhancement`, `bug`, `improvement`, `new kit`, `deprecated`, or `breaking`. See [Changelog & Labels](https://github.com/powerhome/playbook/wiki/Changelog-&-Labels) for details. - [x] **DEPLOY** I have added the `milano` label to show I'm ready for a review. - [x] **TESTS** I have added test coverage to my code.
- Loading branch information
1 parent
b458deb
commit e83c193
Showing
10 changed files
with
110 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
playbook/app/pb_kits/playbook/pb_icon/docs/_icon_color.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= pb_rails("flex", props: {orientation: "column"}) do %> | ||
<%= pb_rails("icon", props: { icon: "user", fixed_width: true, color: "primary", padding_bottom: "sm", size: "2x" }) %> | ||
<%= pb_rails("icon", props: { icon: "recycle", fixed_width: true, color: "data_4", padding_bottom: "sm", size: "2x" }) %> | ||
<%= pb_rails("icon", props: { icon: "roofing", fixed_width: true, color: "product_5_background", size: "2x" }) %> | ||
<% end %> |
34 changes: 34 additions & 0 deletions
34
playbook/app/pb_kits/playbook/pb_icon/docs/_icon_color.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React from "react" | ||
import Icon from "../_icon" | ||
|
||
const IconDefault = (props) => { | ||
return ( | ||
<div style={{ display: "flex", flexDirection: "column"}}> | ||
<Icon | ||
color="primary" | ||
fixedWidth | ||
icon="user" | ||
paddingBottom="sm" | ||
size="2x" | ||
{...props} | ||
/> | ||
<Icon | ||
color="data_4" | ||
fixedWidth | ||
icon="recycle" | ||
paddingBottom="sm" | ||
size="2x" | ||
{...props} | ||
/> | ||
<Icon | ||
color="product_5_background" | ||
fixedWidth | ||
icon="product-roofing" | ||
size="2x" | ||
{...props} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default IconDefault |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Pass any text, status, data, product, or category Playbook <a href="https://playbook.powerapp.cloud/visual_guidelines/colors" target="_blank">color token</a> to the `color` prop to change any icon's color. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters