-
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.
[PBNTR-576] Tooltip for Truncated Form Pills (#3856)
**What does this PR do?** A clear and concise description with your runway ticket url. [PBNTR-576](https://runway.powerhrg.com/backlog_items/PBNTR-576) follows up [PBNTR-550](https://runway.powerhrg.com/backlog_items/PBNTR-550) by adding a Tooltip containing text or tag content in full of a truncated Form Pill. This PR does the following: - Adds a Tooltip to the text, tag, or avatar name component of a truncated Form Pill. The Tooltip contains the entirety of the text content (does not include avatar image or icon) - Expands upon PBNTR-550 by adding the truncate prop to Rails Form Pills as well - all Rails Typeaheads With Pills are react-rendered-rails, so this expands the behavior so React/Rails are consistent. (**Note**: there are no solo rails form pills in use in [Nitro](https://github.com/search?q=repo%3Apowerhome%2Fnitro-web+pb_rails%28%22form_pill&type=code)). For Rails Tooltips, an id must be included; if not included, the Form Pill will be truncated but no Tooltip will appear (this is not necessary for React, nor for react-rendered-rails Typeahead). - Updates the Truncated Text Rails and React doc examples to include several form pill variations (an avatar, an icon+text tag, and a text tag only) within a Card of a small width to demonstrate the truncation/tooltip in a non-Typeahead environment. Locally I tested many variations (including truncation on a small Form Pill, or one with customized color). **Screenshots:** Screenshots to visualize your addition/change React Truncated Text doc example screenshots showing Tooltip <img width="1497" alt="react doc ex typeahead" src="https://github.com/user-attachments/assets/89aa1fc6-0ebd-43af-b108-9b85c77b11b5"> <img width="1491" alt="react doc ex formpill" src="https://github.com/user-attachments/assets/920ec0c5-107d-447d-9604-76664a99d3eb"> Rails Truncated Text doc example screenshots showing Tooltip <img width="1388" alt="for PR rails updated typeahead doc ex" src="https://github.com/user-attachments/assets/cc40eca6-068b-4023-8760-1e4c45f09b0d"> <img width="1395" alt="for PR rails updated formpill doc ex" src="https://github.com/user-attachments/assets/2a9a3837-70e5-4f18-8f7a-a7dc5886f193"> **How to test?** Steps to confirm the desired behavior: 1. Go to the truncated text doc example ([rails](https://pr3856.playbook.beta.px.powerapp.cloud/kits/form_pill/rails#truncated-text)/[react](https://pr3856.playbook.beta.px.powerapp.cloud/kits/form_pill/react#truncated-text)). 2. Go to the Typeahead in the "Truncation Within Typeahead" section and select a name. Hover over the Form Pill that appears with their truncated name and observe the Tooltip in action displaying their full name. 3. Hover over one/all of the truncated Form Pills in the "Form Pill Truncation" section. Observe the Tooltip in action. For the last Form Pill in the Rails doc ex, note that no Tooltip will appear because it does not have an id. #### 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.~~
- Loading branch information
1 parent
3b17776
commit 50fc9f6
Showing
8 changed files
with
135 additions
and
40 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
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
1 change: 0 additions & 1 deletion
1
playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.md
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_rails.md
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,3 @@ | ||
For Form Pills with longer text, the truncate global prop can be used to truncate the label within each Form Pill. See [here](https://playbook.powerapp.cloud/visual_guidelines/truncate) for more information on the truncate global prop. | ||
|
||
__NOTE__: For Rails Form Pills (not ones embedded within a React-rendered Typeahead or MultiLevelSelect), a unique `id` is required to enable the Tooltip functionality displaying the text or tag section of the Form Pill. |
1 change: 1 addition & 0 deletions
1
playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_react.md
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 @@ | ||
For Form Pills with longer text, the `truncate` global prop can be used to truncate the label within each Form Pill. Hover over the truncated Form Pill and a Tooltip containing the text or tag section of the Form Pill will appear. See [here](https://playbook.powerapp.cloud/visual_guidelines/truncate) for more information on the truncate global prop. |
54 changes: 46 additions & 8 deletions
54
playbook/app/pb_kits/playbook/pb_form_pill/form_pill.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,19 +1,57 @@ | ||
<%= 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: "xxs" }) %> | ||
<%= pb_rails("title", props: { text: object.name, size: 4, classname: "pb_form_pill_text" }) %> | ||
<% if object.truncate %> | ||
<div> | ||
<%= pb_rails("title", props: { | ||
classname: "pb_form_pill_text truncate_#{object.truncate}", | ||
id: object.id, | ||
size: 4, | ||
text: object.name, | ||
}) %> | ||
<% if object.id.present? %> | ||
<%= pb_rails("tooltip", props: { | ||
position: "top", | ||
tooltip_id: "tooltip-#{object.id}", | ||
trigger_element_selector: "##{object.id}" | ||
}) do %> | ||
<%= object.name %> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
<% else %> | ||
<%= pb_rails("title", props: { classname: "pb_form_pill_text", id: object.id, size: 4, text: object.name }) %> | ||
<% end %> | ||
<% if object.icon.present? %> | ||
<%= pb_rails("icon", props: { classname: "pb_form_pill_icon", color: object.color, icon: object.icon }) %> | ||
<% end %> | ||
<% elsif object.text.present? %> | ||
<% if object.icon.present? %> | ||
<%= pb_rails("icon", props: { classname: "pb_form_pill_icon", color: object.color, icon: object.icon }) %> | ||
<% end %> | ||
<% if object.text.present? %> | ||
<%= pb_rails("title", props: { text: object.text, size: 4, classname: "pb_form_pill_tag" }) %> | ||
<% end %> | ||
<% if object.icon.present? %> | ||
<%= pb_rails("icon", props: { classname: "pb_form_pill_icon", color: object.color, icon: object.icon }) %> | ||
<% end %> | ||
<% if object.truncate %> | ||
<div> | ||
<%= pb_rails("title", props: { | ||
classname: "pb_form_pill_tag truncate_#{object.truncate}", | ||
id: object.id, | ||
size: 4, | ||
text: object.text, | ||
}) %> | ||
<% if object.id.present? %> | ||
<%= pb_rails("tooltip", props: { | ||
position: "top", | ||
tooltip_id: "tooltip-#{object.id}", | ||
trigger_element_selector: "##{object.id}" | ||
}) do %> | ||
<%= object.text %> | ||
<% end %> | ||
<% end %> | ||
</div> | ||
<% else %> | ||
<%= pb_rails("title", props: { classname: "pb_form_pill_tag", id: object.id, size: 4, text: object.text, }) %> | ||
<% end %> | ||
<% end %> | ||
<%= pb_rails("body", props: { classname: "pb_form_pill_close" }) do %> | ||
<%= pb_rails("icon", props: { icon: 'times', fixed_width: true, size: object.close_icon_size }) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> |