diff --git a/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_icon.jsx b/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_icon.jsx
new file mode 100644
index 0000000000..2e32877029
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_icon.jsx
@@ -0,0 +1,19 @@
+import React from 'react'
+import FormPill from '../_form_pill'
+
+const FormPillIcon = (props) => {
+ return (
+
+ {
+ alert('Click!')
+ }}
+ tabIndex={0}
+ text="icon and tag"
+ {...props}
+ />
+
+ )
+}
+export default FormPillIcon
diff --git a/playbook/app/pb_kits/playbook/pb_form_pill/docs/example.yml b/playbook/app/pb_kits/playbook/pb_form_pill/docs/example.yml
index 061f206217..65b8210ae4 100644
--- a/playbook/app/pb_kits/playbook/pb_form_pill/docs/example.yml
+++ b/playbook/app/pb_kits/playbook/pb_form_pill/docs/example.yml
@@ -5,10 +5,11 @@ examples:
- form_pill_size: Form Pill Size
- form_pill_tag: Form Pill Tag
- form_pill_example: Example
-
+ # - form_pill_icon: Form Pill Icon
react:
- form_pill_user: Form Pill User
- form_pill_size: Form Pill Size
- form_pill_tag: Form Pill Tag
- form_pill_example: Example
+ # - form_pill_icon: Form Pill Icon
diff --git a/playbook/app/pb_kits/playbook/pb_form_pill/docs/index.js b/playbook/app/pb_kits/playbook/pb_form_pill/docs/index.js
index 022d1bab00..71ee92e726 100644
--- a/playbook/app/pb_kits/playbook/pb_form_pill/docs/index.js
+++ b/playbook/app/pb_kits/playbook/pb_form_pill/docs/index.js
@@ -2,4 +2,4 @@ export { default as FormPillUser } from './_form_pill_user.jsx'
export { default as FormPillSize } from './_form_pill_size.jsx'
export { default as FormPillTag } from './_form_pill_tag.jsx'
export { default as FormPillExample } from './_form_pill_example.jsx'
-
+export { default as FormPillIcon } from './_form_pill_icon.jsx'
diff --git a/playbook/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb b/playbook/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb
index bb160b8b14..52f59e0362 100644
--- a/playbook/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb
+++ b/playbook/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb
@@ -1,12 +1,19 @@
<%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, tabindex: object.tabindex, **combined_html_options) do %>
<% if object.name.present? %>
<%= pb_rails("avatar", props: { name: object.name, image_url: object.avatar_url, size: "xs" }) %>
- <%= pb_rails("title", props: { text: object.name, size: 4, classname: "pb_form_pill_text" }) %>
- <% elsif object.text.present? %>
- <%= pb_rails("title", props: { text: object.text, size: 4, classname: "pb_form_pill_tag" }) %>
- <% end %>
-
- <%= pb_rails("body", props: { classname: "pb_form_pill_close" }) do %>
- <%= pb_rails("icon", props: { icon: 'times' , fixed_width: true }) %>
- <% end %>
- <% end %>
+ <%= pb_rails("title", props: { text: object.name, size: 4, classname: "pb_form_pill_text" }) %>
+ <% if object.icon.present? %>
+ <%= pb_rails("icon", props: { classname: "pb_form_pill_icon", icon: object.icon }) %>
+ <% end %>
+ <% elsif object.text.present? %>
+ <% if object.icon.present? %>
+ <%= pb_rails("icon", props: { classname: "pb_form_pill_icon", icon: object.icon }) %>
+ <% end %>
+ <% if object.text.present? %>
+ <%= pb_rails("title", props: { text: object.text, size: 4, classname: "pb_form_pill_tag" }) %>
+ <% end %>
+ <% end %>
+ <%= pb_rails("body", props: { classname: "pb_form_pill_close" }) do %>
+ <%= pb_rails("icon", props: { icon: 'times' , fixed_width: true }) %>
+ <% end %>
+<% end %>
diff --git a/playbook/app/pb_kits/playbook/pb_form_pill/form_pill.rb b/playbook/app/pb_kits/playbook/pb_form_pill/form_pill.rb
index 402a516750..7d47d44f02 100644
--- a/playbook/app/pb_kits/playbook/pb_form_pill/form_pill.rb
+++ b/playbook/app/pb_kits/playbook/pb_form_pill/form_pill.rb
@@ -15,9 +15,10 @@ class FormPill < Playbook::KitBase
values: %w[primary neutral],
default: "primary"
prop :tabindex
+ prop :icon
def classname
- generate_classname("pb_form_pill_kit", color, name, text, text_transform)
+ generate_classname("pb_form_pill_kit", color, icon_class, name, text, text_transform)
end
def display_text
@@ -27,6 +28,10 @@ def display_text
def size_class
size == "small" ? " small" : ""
end
+
+ def icon_class
+ icon ? "icon" : nil
+ end
end
end
end
diff --git a/playbook/spec/pb_kits/playbook/kits/form_pill_spec.rb b/playbook/spec/pb_kits/playbook/kits/form_pill_spec.rb
index 93a14afc41..affafc4e19 100644
--- a/playbook/spec/pb_kits/playbook/kits/form_pill_spec.rb
+++ b/playbook/spec/pb_kits/playbook/kits/form_pill_spec.rb
@@ -10,12 +10,14 @@
it { is_expected.to define_prop(:avatar_url) }
it { is_expected.to define_prop(:size) }
it { is_expected.to define_prop(:color) }
+ it { is_expected.to define_prop(:icon) }
describe "#classname" do
it "returns namespaced class name", :aggregate_failures do
expect(subject.new({}).classname).to eq "pb_form_pill_kit_primary_none"
expect(subject.new(classname: "additional_class").classname).to eq "pb_form_pill_kit_primary_none additional_class"
expect(subject.new(color: "neutral").classname).to eq "pb_form_pill_kit_neutral_none"
+ expect(subject.new(icon: "user").classname).to eq "pb_form_pill_kit_primary_icon_none"
end
end
end