Skip to content

Commit 2d2eba3

Browse files
[PLAY-1858] Icon Button Sizes (#4218)
**What does this PR do?** A clear and concise description with your runway ticket url. This PR adds the `size` prop to the `icon_button_kit` in Rails and allows the developer to specify the size of an Icon Button. [Story](https://runway.powerhrg.com/backlog_items/PLAY-1858) **Screenshots:** Screenshots to visualize your addition/change ![Screenshot 2025-02-03 at 1 17 55 PM](https://github.com/user-attachments/assets/ab429e1f-1c0a-4e61-9e95-a384fadbb21c) **How to test?** Steps to confirm the desired behavior: 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See addition/change #### 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. - [ ] **TESTS** I have added test coverage to my code.
1 parent f38de91 commit 2d2eba3

File tree

6 files changed

+38
-6
lines changed

6 files changed

+38
-6
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
<%= pb_rails("icon_button") %>
2-
</br>
3-
<%= pb_rails("icon_button", props: {variant: "link"}) %>
2+
<%= pb_rails("icon_button", props: {variant: "link", margin_top: "md" }) %>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<%= pb_rails("flex", props: { align: "center"}) do %>
2+
<%= pb_rails("icon_button", props: {size: "lg"}) %> <span>Large</span>
3+
<% end %>
4+
5+
<%= pb_rails("flex", props: { align: "center" }) do %>
6+
<%= pb_rails("icon_button", props: {size: "sm"}) %> <span>Small</span>
7+
<% end %>
8+
9+
<%= pb_rails("flex", props: { align: "center" }) do %>
10+
<%= pb_rails("icon_button", props: {size: "xs"}) %> <span>XSmall</span>
11+
<% end %>
12+
13+
<%= pb_rails("flex", props: { align: "center", margin_top: "md" }) do %>
14+
<%= pb_rails("icon_button", props: {size: "1x"}) %> <span>1x</span>
15+
<% end %>
16+
17+
<%= pb_rails("flex", props: { align: "center" }) do %>
18+
<%= pb_rails("icon_button", props: {size: "2x"}) %> <span>2x</span>
19+
<% end %>
20+
21+
<%= pb_rails("flex", props: { align: "center" }) do %>
22+
<%= pb_rails("icon_button", props: {size: "3x"}) %> <span>3x</span>
23+
<% end %>
24+
25+
<%= pb_rails("flex", props: { align: "center" }) do %>
26+
<%= pb_rails("icon_button", props: {size: "4x"}) %> <span>4x</span>
27+
<% end %>

playbook/app/pb_kits/playbook/pb_icon_button/docs/example.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ examples:
22

33
rails:
44
- icon_button_default: Default
5-
6-
7-
5+
- icon_button_sizes: Sizes

playbook/app/pb_kits/playbook/pb_icon_button/icon_button.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<%= pb_rails("icon", props: { icon: object.icon,
99
fixed_width: true,
1010
dark: object.dark,
11-
size: "2x",
11+
size: object.size,
1212
color: "text_lt_default",
1313
classname: "icon_button_icon",
1414
padding_x: "xxs", padding_y: "xs" }) %>

playbook/app/pb_kits/playbook/pb_icon_button/icon_button.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class IconButton < ::Playbook::KitBase
1414
prop :variant, type: Playbook::Props::Enum,
1515
values: %w[default link],
1616
default: "default"
17+
prop :size, type: Playbook::Props::Enum,
18+
values: %w[1x 2x 3x 4x 5x 6x 7x 8x 9x 10x xs sm lg],
19+
default: "2x"
1720
def classname
1821
generate_classname("pb_icon_button_kit", variant)
1922
end

playbook/spec/pb_kits/playbook/kits/icon_button_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
.with_default("default")
2020
.with_values("default", "link")
2121
}
22+
it {
23+
is_expected.to define_enum_prop(:size)
24+
.with_default("2x")
25+
.with_values("1x", "2x", "3x", "4x", "5x", "6x", "7x", "8x", "9x", "10x", "xs", "sm", "lg")
26+
}
2227

2328
# Test classname generation
2429
describe "#classname" do

0 commit comments

Comments
 (0)