Skip to content

Commit

Permalink
Code and doc example cleanup, playbook tokens work
Browse files Browse the repository at this point in the history
  • Loading branch information
ElisaShapiro committed Jul 17, 2024
1 parent d381937 commit bfff9ed
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 68 deletions.
58 changes: 1 addition & 57 deletions playbook/app/pb_kits/playbook/pb_icon/_icon.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import "../tokens/colors";

// All the merges below create $icon_colors, a map of all color tokens in colors.scss
$merge_kits1: map-merge($status_colors, $category_colors);
$merge_kits2: map-merge($merge_kits1, $product_colors);
$merge_kits3: map-merge($merge_kits2, $text_colors);
Expand All @@ -15,70 +16,13 @@ $merge_kits12: map-merge($merge_kits11, $status_color_text);
$merge_kits13: map-merge($merge_kits12, $status_color_text_dark);
$icon_colors: map-merge($merge_kits13, $colors);


// @mixin apply-color-from-class($class-name) {
// $hash-index: str-index($class-name, '#');
// $hexcode: str-slice($class-name, $hash-index + 1, $hash-index + 7);
// color: unquote("#{$hexcode}");
// }
// @mixin apply-color($hexcode) {
// color: $hexcode;
// }

// @function sanitize-hex($hex) {
// @return str-slice($hex, 2);
// }

// @use "sass:selector";

// @mixin extractColor($className){
// // $startIndex: str-index($className, "color_#") + 7;
// // $hexCode: str-slice($className, $startIndex, 7);
// $startIndex: str-index($className, "color_#") + 6;
// $hexCode: str-slice($className, $startIndex);
// color: #{$hexCode};
// }

// [class^=pb_custom_icon]
// [class*=pb_icon_kit] {
.pb_custom_icon, .pb_icon_kit {
@each $color_name, $color_value in $icon_colors {
&[class*="#{$color_name}"] {
color: $color_value;
}
// &.#{$color_name} {
// color: $color_value;
// }
}
// @mixin dynamic-color($color) {
// .color_##{$color} {
// @include apply-color($color);
// }
// }
// .pb_custom_icon, .pb_icon_kit {
// &[class*="color_#"] {
// @debug selector.parse(".color_#");
// @debug "color: $hexCode";
// @include extractColor(&);
// @include extractColor($hexCode);
// color: #{$hexCode};
// color: #FF0000;
// }
// &[class*="color_#"] {
// // @include extractColor(&)
// // @include apply-color-from-class(($class-name))
// $current-class: &;
// @include apply-color-from-class($current-class);
// }
}
// Testing if the str- functions work
// $className: "color_#FF0000";
// $startIndex: str-index($className, "color_#") + 6;
// $hexCode: str-slice($className, $startIndex);
// [class*="color_#FF0000"] {
// color: #{$hexCode};
// }


// Rails custom icon styles
svg.pb_custom_icon {
Expand Down
11 changes: 7 additions & 4 deletions playbook/app/pb_kits/playbook/pb_icon/docs/_icon_color.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<%= pb_rails("icon", props: { icon: "user", fixed_width: true, color: "primary" }) %>
<%= pb_rails("icon", props: { icon: "user", fixed_width: true, color: "#FF0000" }) %>
<%= pb_rails("icon", props: { icon: "vial", fixed_width: true, color: "text_lt_lighter" }) %>
<%= pb_rails("icon", props: { icon: "vial", fixed_width: true, color: "#FF0000" }) %>
<%= pb_rails("flex", props: {orientation: "column"}) do %>
<%= pb_rails("icon", props: { icon: "user", fixed_width: true, color: "primary", size: "2x" }) %>
<%= pb_rails("icon", props: { icon: "recycle", fixed_width: true, color: "info", size: "2x" }) %>
<%= pb_rails("icon", props: { icon: "frog", fixed_width: true, color: "data_4", size: "2x" }) %>
<%= pb_rails("icon", props: { icon: "vial", fixed_width: true, color: "text_lt_lighter", size: "2x" }) %>
<%= pb_rails("icon", props: { icon: "roofing", fixed_width: true, color: "product_roofing", size: "2x" }) %>
<% end %>
23 changes: 17 additions & 6 deletions playbook/app/pb_kits/playbook/pb_icon/docs/_icon_color.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,40 @@ import Icon from "../_icon"

const IconDefault = (props) => {
return (
<div>
<div style={{ display: "flex", flexDirection: "column"}}>
<Icon
color="primary"
fixedWidth
icon="user"
size="2x"
{...props}
/>
<Icon
color="#FF0000"
color="info"
fixedWidth
icon="user"
icon="recycle"
size="2x"
{...props}
/>
<Icon
color="success"
color="data_4"
fixedWidth
icon="frog"
size="2x"
{...props}
/>
<Icon
color="text_lt_lighter"
fixedWidth
icon="vial"
size="2x"
{...props}
/>
<Icon
color="#FF0000"
color="roofing"
fixedWidth
icon="vial"
icon="product-roofing"
size="2x"
{...props}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion playbook/app/pb_kits/playbook/pb_icon/docs/_icon_color.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Pass any hex code or 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.
Pass any 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.

0 comments on commit bfff9ed

Please sign in to comment.