-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PLAY-1750] Convert Kits to Use Pb_content_tag (#4106)
**What does this PR do?** A clear and concise description with your runway ticket url. Updated Button, Checkbox, DatePicker, and Dropdown kits to no longer use "content_tag" and use our new "pb_content_tag". Also added test for Dropdown kit. [Story 1750](https://runway.powerhrg.com/backlog_items/PLAY-1750) **Screenshots:** Screenshots to visualize your addition/change there should be no functional changes to any of these kits. Add Alpha testing locations to story notes #### 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
05887b5
commit 7f99558
Showing
8 changed files
with
72 additions
and
66 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
8 changes: 2 additions & 6 deletions
8
playbook/app/pb_kits/playbook/pb_date_picker/date_picker.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
19 changes: 7 additions & 12 deletions
19
playbook/app/pb_kits/playbook/pb_dropdown/dropdown.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
23 changes: 9 additions & 14 deletions
23
playbook/app/pb_kits/playbook/pb_dropdown/dropdown_container.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 |
---|---|---|
@@ -1,20 +1,15 @@ | ||
<%= content_tag(:div, | ||
aria: object.aria, | ||
class: object.classname, | ||
data: object.data, | ||
id: object.id, | ||
**combined_html_options) do %> | ||
<%= pb_content_tag do %> | ||
<%= pb_rails("list", props: {ordered: false, borderless: false}) do %> | ||
<% if content.present? %> | ||
<% if content.present? %> | ||
<%= content.presence %> | ||
<% else %> | ||
<% else %> | ||
<%= pb_rails("list/item", props: { | ||
display: "flex", | ||
justify_content: "center", | ||
padding:"xs", | ||
}) do %> | ||
display: "flex", | ||
justify_content: "center", | ||
padding:"xs", | ||
}) do %> | ||
<%= pb_rails("body", props: {text: "No option"}) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../../../../app/pb_kits/playbook/pb_dropdown/dropdown" | ||
|
||
RSpec.describe Playbook::PbDropdown::Dropdown do | ||
subject { Playbook::PbDropdown::Dropdown } | ||
|
||
it { is_expected.to define_array_prop(:options).with_default([]) } | ||
it { is_expected.to define_string_prop(:label) } | ||
it { is_expected.to define_string_prop(:name) } | ||
it { is_expected.to define_boolean_prop(:required).with_default(false) } | ||
it { is_expected.to define_string_prop(:blank_selection).with_default("") } | ||
it { is_expected.to define_enum_prop(:variant).with_values("default", "subtle").with_default("default") } | ||
it { is_expected.to define_boolean_prop(:separators).with_default(true) } | ||
it { is_expected.to define_string_prop(:default_value) } | ||
|
||
describe "#classname" do | ||
it "returns namespaced class name", :aggregate_failures do | ||
expect(subject.new({}).classname).to eq "pb_dropdown_default" | ||
expect(subject.new(dark: true).classname).to eq "pb_dropdown_default dark" | ||
expect(subject.new(margin: "lg").classname).to eq "pb_dropdown_default m_lg" | ||
expect(subject.new(classname: "additional_class").classname).to eq "pb_dropdown_default additional_class" | ||
end | ||
end | ||
|
||
describe "#options_with_blank" do | ||
it "includes blank selection option if blank_selection is present" do | ||
dropdown = subject.new(blank_selection: "Select an option", options: [{ id: 1, label: "Option 1", value: "1" }]) | ||
expect(dropdown.send(:options_with_blank)).to include({ id: "", value: "", label: "Select an option" }) | ||
end | ||
|
||
it "does not include blank selection option if blank_selection is not present" do | ||
dropdown = subject.new(options: [{ id: 1, label: "Option 1", value: "1" }]) | ||
expect(dropdown.send(:options_with_blank)).not_to include({ id: "", value: "", label: "" }) | ||
end | ||
end | ||
end |