From f8db614fd5b9e913b47405a00cee91c1d58360d9 Mon Sep 17 00:00:00 2001
From: Gary Kang <42440452+kangaree@users.noreply.github.com>
Date: Thu, 31 Oct 2024 15:22:49 -0400
Subject: [PATCH 1/4] [PLAY-1485] Fix overflow container bug by using padding
instead of outline (#3807)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
**What does this PR do?**
In [PLAY-829](https://runway.powerhrg.com/backlog_items/PLAY-829), we
removed the buffer to fix content alignment issues and added an outline
so the content would not 'jump' (which was handled originally by the
buffer).
- Fix overflow container bug by using padding instead of outline
- Subtract 1px of padding in the selected label container to account for
the extra 1px border of selected label
- Do this for all padding sizes xxs to xl
- For "selectable cards", keep an outline as the content is different (a
padding 0 div wrapped around flex and cards)
- Fix the dark mode for rails and apply it to the card
**Screenshots:** Screenshots to visualize your addition/change
![Screenshot 2024-10-30 at 10 25
07 AM](https://github.com/user-attachments/assets/68b7efcf-3775-4d15-b70d-cce39b40f698)
![Screenshot 2024-10-23 at 9 15
54 AM](https://github.com/user-attachments/assets/a447bd7b-2bbb-4aa0-97b8-d7804bc7a19c)
**How to test?** Steps to confirm the desired behavior:
1. Go to the Playbook Website
2. Go to the Selectable Card kit
3. Click the cards
4. Make sure the content does not "jump" or shift around and stays in
place
5. Go to the Nitro test env
6. Use the Impersonation Flyout
7. Search by title so multiple results show (e.g., "Nitro Quality
Ninja")
8. The selected card should not be cut off
9. If you select a card, the content should not "jump" or shift around
10. Since there are multiple employees, everything should fit in the
overlay- the impersonate and cancel button should fit on the overlay and
not be below a scroll.
#### 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.
---
.../pb_kits/playbook/pb_card/_card_mixin.scss | 3 +-
.../pb_selectable_card/_selectable_card.scss | 68 ++++++++++++++++++-
.../pb_selectable_card/_selectable_card.tsx | 1 +
.../selectable_card.html.erb | 2 +-
.../pb_selectable_card/selectable_card.rb | 6 +-
5 files changed, 75 insertions(+), 5 deletions(-)
diff --git a/playbook/app/pb_kits/playbook/pb_card/_card_mixin.scss b/playbook/app/pb_kits/playbook/pb_card/_card_mixin.scss
index a3781bf2ac..f15d002ee0 100755
--- a/playbook/app/pb_kits/playbook/pb_card/_card_mixin.scss
+++ b/playbook/app/pb_kits/playbook/pb_card/_card_mixin.scss
@@ -28,8 +28,7 @@ $pb_card_header_colors: map-merge(map-merge($product_colors, $additional_colors)
@mixin pb_card_selected($border_color: $primary) {
border-color: $border_color;
- border-width: $pb_card_border_width;
- outline: 1px solid $border_color;
+ border-width: $pb_card_border_width * 2;
}
@mixin pb_card_selected_dark {
diff --git a/playbook/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss b/playbook/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss
index f2dda25c0d..e84ccb6d81 100644
--- a/playbook/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss
+++ b/playbook/app/pb_kits/playbook/pb_selectable_card/_selectable_card.scss
@@ -10,6 +10,24 @@
$pb_selectable_card_indicator_size: 22px;
$pb_selectable_card_border: 2px;
+$pb_selectable_space_classes: (
+ xxs: $space_xxs,
+ xs: $space_xs,
+ sm: $space_sm,
+ md: $space_md,
+ lg: $space_lg,
+ xl: $space_xl,
+);
+$pb_selectable_paddings: (
+ p: "padding",
+ pr: "padding-right",
+ pl: "padding-left",
+ pt: "padding-top",
+ pb: "padding-bottom",
+ px: ("padding-left", "padding-right"),
+ py: ("padding-top", "padding-bottom")
+);
+
[class^=pb_selectable_card_kit] {
display: block;
margin-bottom: 0;
@@ -28,7 +46,6 @@ $pb_selectable_card_border: 2px;
padding: $space_sm;
margin-bottom: $space_sm;
cursor: pointer;
- outline: 1px solid transparent;
@media (hover:hover) {
&:hover {
@@ -74,6 +91,7 @@ $pb_selectable_card_border: 2px;
position: relative;
@include pb_card_selected;
+ padding: calc(#{$space_sm} - 1px);
transition-property: none;
transition-duration: 0s;
@@ -88,6 +106,54 @@ $pb_selectable_card_border: 2px;
background-color: $royal;
}
}
+
+ // Selected card has 1px more border
+ // Remove 1px so content does not "jump"
+ @each $position_name,
+ $position in $pb_selectable_paddings {
+ @each $space_name,
+ $space in $pb_selectable_space_classes {
+ ~ label.#{$position_name}_#{$space_name} {
+ @if type-of($position)=="list" {
+ @each $coordinate in $position {
+ #{$coordinate}: calc(#{$space} - 1px) !important;
+ }
+ }
+
+ @else {
+ #{$position}: calc(#{$space} - 1px) !important;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ &.display_input {
+ input[type="checkbox"],
+ input[type="radio"] {
+ &:checked {
+ ~label {
+ border-width: $pb_card_border_width;
+ outline: 1px solid $primary;
+ }
+
+ }
+ }
+
+ > label {
+ outline: 1px solid transparent;
+ padding: $space_sm;
+ }
+
+ &.dark {
+ input[type="checkbox"],
+ input[type="radio"] {
+ &:checked ~ label {
+ border-width: $pb_card_border_width;
+ outline: 1px solid $primary;
+ }
+ }
}
}
diff --git a/playbook/app/pb_kits/playbook/pb_selectable_card/_selectable_card.tsx b/playbook/app/pb_kits/playbook/pb_selectable_card/_selectable_card.tsx
index 923f602710..8b53177f62 100644
--- a/playbook/app/pb_kits/playbook/pb_selectable_card/_selectable_card.tsx
+++ b/playbook/app/pb_kits/playbook/pb_selectable_card/_selectable_card.tsx
@@ -67,6 +67,7 @@ const SelectableCard = (props: SelectableCardProps) => {
'disabled': disabled,
'enabled': !disabled,
}),
+ variant === 'displayInput' ? 'display_input' : '',
{ error },
dark ? 'dark' : '',
className
diff --git a/playbook/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb b/playbook/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb
index 0618d35d17..e3f997a773 100644
--- a/playbook/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb
+++ b/playbook/app/pb_kits/playbook/pb_selectable_card/selectable_card.html.erb
@@ -25,7 +25,7 @@
<% end %>
- <%= pb_rails("card", props: { padding: "sm", status: object.status, border_none: true }) do %>
+ <%= pb_rails("card", props: { padding: "sm", status: object.status, border_none: true, dark: object.dark }) do %>
<% if content.nil? %>
<%= pb_rails("body", props: { text: object.text }) %>
<% else %>
diff --git a/playbook/app/pb_kits/playbook/pb_selectable_card/selectable_card.rb b/playbook/app/pb_kits/playbook/pb_selectable_card/selectable_card.rb
index a9934da1d4..6b6b2e6158 100644
--- a/playbook/app/pb_kits/playbook/pb_selectable_card/selectable_card.rb
+++ b/playbook/app/pb_kits/playbook/pb_selectable_card/selectable_card.rb
@@ -25,7 +25,7 @@ class SelectableCard < Playbook::KitBase
def classname
[
- generate_classname_without_spacing("pb_selectable_card_kit", checked_class, enable_disabled_class),
+ generate_classname_without_spacing("pb_selectable_card_kit", checked_class, enable_disabled_class) + display_input_class,
error_class,
dark_props,
].compact.join(" ")
@@ -79,6 +79,10 @@ def enable_disabled_class
def error_class
error ? "error" : nil
end
+
+ def display_input_class
+ variant == "display_input" ? " display_input" : ""
+ end
end
end
end
From b85fa1e0b9e07e57430c8b802571d1f81bce12bd Mon Sep 17 00:00:00 2001
From: Mark Rosenberg <38965626+markdoeswork@users.noreply.github.com>
Date: Fri, 1 Nov 2024 14:21:32 -0400
Subject: [PATCH 2/4] [PLAY-1571] Add dependencies to getting started page
(#3864)
**What does this PR do?** A clear and concise description with your
runway ticket url.
Runway https://runway.powerhrg.com/backlog_items/PLAY-1571
Find all the dependancies for our kits and put them on a page
Some of them need the plabyook consumer to add a library to their app,
others ship with playbook
check it out
https://pr3864.playbook.beta.px.powerapp.cloud/guides/getting_started/dependencies
![screenshot-pr3864_playbook_beta_px_powerapp_cloud-2024_10_30-15_11_44](https://github.com/user-attachments/assets/52deb7b1-ad74-47d0-8474-15ca37efba5f)
---
.../guides/getting_started/dependencies.md | 52 +++++++++++++++++++
.../config/initializers/global_variables.rb | 7 +--
2 files changed, 56 insertions(+), 3 deletions(-)
create mode 100644 playbook-website/app/views/guides/getting_started/dependencies.md
diff --git a/playbook-website/app/views/guides/getting_started/dependencies.md b/playbook-website/app/views/guides/getting_started/dependencies.md
new file mode 100644
index 0000000000..3323271988
--- /dev/null
+++ b/playbook-website/app/views/guides/getting_started/dependencies.md
@@ -0,0 +1,52 @@
+---
+title: Dependencies
+icon: code
+description: Some of our kits require additional libraries to run properly.
+---
+
+## Unbundled Dependencies
+
+These kits require you to install additional libraries to get full functionality.
+
+To install them add them to your project using `yarn add`, `npm install`, or manually add them to your `package.json` file.
+
+| Kit | Kit Link | NPM Link(s) | Dependency(s) |
+|---------------------|-----------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|---------------------------------------------|
+| **Icon** | [Icon](https://playbook.powerapp.cloud/kits/icon/react) | [fontawesome-free](https://www.npmjs.com/package/fontawesome-free) | fontawesome-free |
+| **Icon Circle** | [Icon Circle](https://playbook.powerapp.cloud/kits/icon_circle/react) | [fontawesome-free](https://www.npmjs.com/package/fontawesome-free) | fontawesome-free |
+| **Icon Stat Value** | [Icon Stat Value](https://playbook.powerapp.cloud/kits/icon_stat_value/react) | [fontawesome-free](https://www.npmjs.com/package/fontawesome-free) | fontawesome-free |
+| **Icon Value** | [Icon Value](https://playbook.powerapp.cloud/kits/icon_value/react) | [fontawesome-free](https://www.npmjs.com/package/fontawesome-free) | fontawesome-free |
+| **Map** | [Map](https://playbook.powerapp.cloud/kits/map/react) | [maplibre-gl](https://www.npmjs.com/package/maplibre-gl) | maplibre-gl |
+| **Rich Text Editor**
(TipTap Editor) | [Rich Text Editor](https://playbook.powerapp.cloud/kits/rich_text_editor/react) | - [@tiptap/core](https://www.npmjs.com/package/@tiptap/core)
- [@tiptap/react](https://www.npmjs.com/package/@tiptap/react)
- [@tiptap/starter-kit](https://www.npmjs.com/package/@tiptap/starter-kit)
- [@tiptap/extension-document](https://www.npmjs.com/package/@tiptap/extension-document)
- [@tiptap/extension-highlight](https://www.npmjs.com/package/@tiptap/extension-highlight)
- [@tiptap/extension-horizontal-rule](https://www.npmjs.com/package/@tiptap/extension-horizontal-rule)
- [@tiptap/extension-link](https://www.npmjs.com/package/@tiptap/extension-link)
- [@tiptap/extension-paragraph](https://www.npmjs.com/package/@tiptap/extension-paragraph)
- [@tiptap/extension-text](https://www.npmjs.com/package/@tiptap/extension-text)
- [@tiptap/pm](https://www.npmjs.com/package/@tiptap/pm) | - @tiptap/core
- @tiptap/react
- @tiptap/starter-kit
- @tiptap/extension-document
- @tiptap/extension-highlight
- @tiptap/extension-horizontal-rule
- @tiptap/extension-link
- @tiptap/extension-paragraph
- @tiptap/extension-text
- @tiptap/pm |
+
+## Bundled Dependencies
+
+These kits use dependencies that are bundled with them; no additional installation is required.
+
+| Kit | Kit Link | NPM Link(s) | Dependency(s) |
+|------------------------|-----------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|-----------------------------------------|
+| **Advanced Table** | [Advanced Table](https://playbook.powerapp.cloud/kits/advanced_table/react) | [@tanstack/react-table](https://www.npmjs.com/package/@tanstack/react-table) | @tanstack/react-table |
+| **Bar Graph** | [Bar Graph](https://playbook.powerapp.cloud/kits/bar_graph/react) | [highcharts](https://www.npmjs.com/package/highcharts),
[highcharts-react-official](https://www.npmjs.com/package/highcharts-react-official) | highcharts,
highcharts-react-official |
+| **Circle Chart** | [Circle Chart](https://playbook.powerapp.cloud/kits/circle_chart/react) | [highcharts](https://www.npmjs.com/package/highcharts),
[highcharts-react-official](https://www.npmjs.com/package/highcharts-react-official) | highcharts,
highcharts-react-official |
+| **Date Picker** | [Date Picker](https://playbook.powerapp.cloud/kits/date_picker/react) | [flatpickr](https://www.npmjs.com/package/flatpickr) | flatpickr |
+| **Dialog** | [Dialog](https://playbook.powerapp.cloud/kits/dialog/react) | [react-modal](https://www.npmjs.com/package/react-modal) | react-modal |
+| **File Upload** | [File Upload](https://playbook.powerapp.cloud/kits/file_upload/react) | [react-dropzone](https://www.npmjs.com/package/react-dropzone) | react-dropzone |
+| **Filter** | [Filter](https://playbook.powerapp.cloud/kits/filter/react) | [react-popper](https://www.npmjs.com/package/react-popper) | react-popper |
+| **Gauge** | [Gauge](https://playbook.powerapp.cloud/kits/gauge/react) | [highcharts](https://www.npmjs.com/package/highcharts),
[highcharts-react-official](https://www.npmjs.com/package/highcharts-react-official) | highcharts,
highcharts-react-official |
+| **Highlight** | [Highlight](https://playbook.powerapp.cloud/kits/highlight/react) | [react-highlight-words](https://www.npmjs.com/package/react-highlight-words) | react-highlight-words |
+| **LightBox** | [LightBox](https://playbook.powerapp.cloud/kits/lightbox/react) | [react-zoom-pan-pinch](https://www.npmjs.com/package/react-zoom-pan-pinch) | react-zoom-pan-pinch |
+| **Line Graph** | [Line Graph](https://playbook.powerapp.cloud/kits/line_graph/react) | [highcharts](https://www.npmjs.com/package/highcharts),
[highcharts-react-official](https://www.npmjs.com/package/highcharts-react-official) | highcharts,
highcharts-react-official |
+| **Multi Level Select** | [Multi Level Select](https://playbook.powerapp.cloud/kits/multi_level_select/react) | [lodash](https://www.npmjs.com/package/lodash) | lodash |
+| **Passphrase** | [Passphrase](https://playbook.powerapp.cloud/kits/passphrase/react) | [react-popper](https://www.npmjs.com/package/react-popper) | react-popper |
+| **Phone Number Input** | [Phone Number Input](https://playbook.powerapp.cloud/kits/phone_number_input/react) | [intl-tel-input](https://www.npmjs.com/package/intl-tel-input) | intl-tel-input |
+| **Popover** | [Popover](https://playbook.powerapp.cloud/kits/popover/react) | [lodash](https://www.npmjs.com/package/lodash),
[react-popper](https://www.npmjs.com/package/react-popper) | lodash,
react-popper |
+| **Rich Text Editor**
(Trix Editor) | [Rich Text Editor](https://playbook.powerapp.cloud/kits/rich_text_editor/react) | [trix](https://www.npmjs.com/package/trix),
[react-trix](https://www.npmjs.com/package/react-trix) | trix,
react-trix |
+| **Tooltip** | [Tooltip](https://playbook.powerapp.cloud/kits/tooltip/react) | [@floating-ui/react](https://www.npmjs.com/package/@floating-ui/react) | @floating-ui/react |
+| **Treemap Chart** | [Treemap Chart](https://playbook.powerapp.cloud/kits/treemap_chart/react) | [highcharts](https://www.npmjs.com/package/highcharts),
[highcharts-react-official](https://www.npmjs.com/package/highcharts-react-official) | highcharts,
highcharts-react-official |
+| **Typeahead** | [Typeahead](https://playbook.powerapp.cloud/kits/typeahead/react) | [react-select](https://www.npmjs.com/package/react-select),
[lodash](https://www.npmjs.com/package/lodash) | react-select,
lodash |
+| **Walkthrough** | [Walkthrough](https://playbook.powerapp.cloud/kits/walkthrough/react) | [react-joyride](https://www.npmjs.com/package/react-joyride) | react-joyride |
+
+## Notes
+**Rich Text Editor**: This kit supports two different editors:
+**TipTap Editor**: Requires manual installation of `tiptap` and various `@tiptap/*` extensions (listed above under Unbundled Dependencies).
+**Trix Editor**: Dependencies (`trix` and `react-trix`) are bundled with the kit; no extra installation is needed.
diff --git a/playbook-website/config/initializers/global_variables.rb b/playbook-website/config/initializers/global_variables.rb
index 68052286d5..ca695bca59 100644
--- a/playbook-website/config/initializers/global_variables.rb
+++ b/playbook-website/config/initializers/global_variables.rb
@@ -69,10 +69,11 @@
],
}
-# Move HTML figma to the end
+# Move these pages to the end of the Getting Started page
+page_names = ["HTML&_CSS", "figma_setup", "how_to_theme", "dependencies"]
-move_pages = navigation[:getting_started][:pages].select { |page| ["HTML&_CSS", "figma_setup", "how_to_theme"].include?(page[:page_id]) }
-navigation[:getting_started][:pages].reject! { |page| ["HTML&_CSS", "figma_setup", "how_to_theme"].include?(page[:page_id]) }
+move_pages = navigation[:getting_started][:pages].select { |page| page_names.include?(page[:page_id]) }
+navigation[:getting_started][:pages].reject! { |page| page_names.include?(page[:page_id]) }
navigation[:getting_started][:pages].concat(move_pages)
DOCS = navigation
From 3b17776cd4a398985a5069db28992ba231b82c40 Mon Sep 17 00:00:00 2001
From: Gary Kang <42440452+kangaree@users.noreply.github.com>
Date: Fri, 1 Nov 2024 14:30:48 -0400
Subject: [PATCH 3/4] [PLAY-1618] Font Awesome Setup Documentation - Phase 1
(#3865)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
**What does this PR do?**
Add Font Awesome setup docs for Ruby on Rails asset pipeline.
[PLAY-1618](https://runway.powerhrg.com/backlog_items/PLAY-1618)
**Screenshots:** Screenshots to visualize your addition/change
![Screenshot 2024-10-31 at 8 12
12 AM](https://github.com/user-attachments/assets/70af7291-6f8d-49c0-997c-578281c97790)
**How to test?** Steps to confirm the desired behavior:
1. Go to /guides/getting_started
2. Click Font Awesome
3. Review the doc
#### 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.
---------
Co-authored-by: Mark
Co-authored-by: Mark Rosenberg <38965626+markdoeswork@users.noreply.github.com>
---
.../guides/getting_started/font_awesome.md | 73 +++++++++++++++++++
.../config/initializers/global_variables.rb | 2 +-
2 files changed, 74 insertions(+), 1 deletion(-)
create mode 100644 playbook-website/app/views/guides/getting_started/font_awesome.md
diff --git a/playbook-website/app/views/guides/getting_started/font_awesome.md b/playbook-website/app/views/guides/getting_started/font_awesome.md
new file mode 100644
index 0000000000..732a79757b
--- /dev/null
+++ b/playbook-website/app/views/guides/getting_started/font_awesome.md
@@ -0,0 +1,73 @@
+---
+title: Font Awesome Setup
+description: Playbook seamlessly integrates with Font Awesome, a leading icon library known for its extensive collection of high-quality, scalable icons. This integration not only enhances the visual appeal of websites and applications but also improves overall usability.
+icon: font-awesome
+---
+
+Playbook seamlessly integrates with [Font Awesome](https://fontawesome.com/), a leading icon library known for its extensive collection of high-quality, scalable icons. This integration not only enhances the visual appeal of websites and applications but also improves overall usability.
+
+Some Font Awesome benefits:
+
+**1. Wide Range of Icons:** Font Awesome offers a vast selection of icons to suit a variety of needs. You can easily find the perfect icon for your project through their [icon search](https://fontawesome.com/search).
+**2. Ease of Use:** The icons are straightforward to implement. With just a few lines of code, you can quickly and easily add visual elements to your web projects. Note, a Pro subscription is required for access to a wider range of icons beyond the [Free set](https://fontawesome.com/search?o=r&m=free&s=regular).
+**3. Visual Appeal:** Incorporating these icons can improve the aesthetic of your site or application, making it more attractive to users. With Playbook, you have the flexibility to customize color, size, and animations.
+**4. User-Friendliness:** Icons can help users navigate and understand your website or application more efficiently, enhancing their overall experience. Font Awesome icons are web fonts compatible with most browsers and are optimized for performance and accessibility.
+
+Integrating Font Awesome with Playbook ensures that you have access to these benefits, making your projects more polished and professional.
+
+![fontawesome](https://github.com/user-attachments/assets/638b63ad-56d3-4819-8e05-fcbb175bedc7)
+
+## Ruby on Rails Setup (default with asset pipeline)
+
+**Make sure you are on Rails 7 or higher.**
+
+**1.** Follow the [Ruby on Rails Setup getting started page](/guides/getting_started/ruby_on_rails_setup) to setup Playbook with your Rails project.
+
+**2.** Setup Pro or Free Font Awesome to use our Icon Component.
+
+**Pro:**
+
+```rb
+# app/assets/stylesheets/application.scss
+ @import "font-awesome-pro";
+ @import "font-awesome-pro/solid";
+ @import "font-awesome-pro/regular";
+ @import "playbook";
+```
+
+```rb
+# app/Gemfile
+ source "https://token:TOKEN@dl.fontawesome.com/basic/fontawesome-pro/ruby/" do
+ gem "font-awesome-pro-sass", "6.2.0"
+ end
+```
+
+**Free:**
+
+*Currently only [Free Regular](https://fontawesome.com/search?o=r&m=free&s=regular) icons are supported in our icon component structure.*
+
+```rb
+# app/assets/stylesheets/application.scss
+ @import "font-awesome";
+```
+
+```rb
+# app/Gemfile
+ source "https://token:TOKEN@dl.fontawesome.com/basic/fontawesome-pro/ruby/" do
+ gem "font-awesome-pro-sass", "6.2.0"
+ end
+```
+
+**3.** Bundle all the things!
+
+```sh
+bundle install
+```
+
+**4.** **Go build awesome stuff!**
+
+Refer to our [Icon kit](/kits/icon) to get started with Font Awesome icons in Playbook.
+
+```rb
+<%= pb_rails("icon", props: { icon: "font-awesome", fixed_width: true }) %>
+```
diff --git a/playbook-website/config/initializers/global_variables.rb b/playbook-website/config/initializers/global_variables.rb
index ca695bca59..c88293355d 100644
--- a/playbook-website/config/initializers/global_variables.rb
+++ b/playbook-website/config/initializers/global_variables.rb
@@ -70,7 +70,7 @@
}
# Move these pages to the end of the Getting Started page
-page_names = ["HTML&_CSS", "figma_setup", "how_to_theme", "dependencies"]
+page_names = ["HTML&_CSS", "figma_setup", "how_to_theme", "dependencies", "font_awesome"]
move_pages = navigation[:getting_started][:pages].select { |page| page_names.include?(page[:page_id]) }
navigation[:getting_started][:pages].reject! { |page| page_names.include?(page[:page_id]) }
From 50fc9f6a058a5281c634b342d23e1122b7dac83d Mon Sep 17 00:00:00 2001
From: Elisa Shapiro <83474365+ElisaShapiro@users.noreply.github.com>
Date: Tue, 5 Nov 2024 08:59:22 -0500
Subject: [PATCH 4/4] [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
Rails Truncated Text doc example screenshots showing Tooltip
**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.~~
---
.../playbook/pb_form_pill/_form_pill.scss | 8 ++-
.../playbook/pb_form_pill/_form_pill.tsx | 56 ++++++++++---------
.../docs/_form_pill_truncated_text.html.erb | 25 ++++++++-
.../docs/_form_pill_truncated_text.jsx | 27 ++++++++-
.../docs/_form_pill_truncated_text.md | 1 -
.../docs/_form_pill_truncated_text_rails.md | 3 +
.../docs/_form_pill_truncated_text_react.md | 1 +
.../playbook/pb_form_pill/form_pill.html.erb | 54 +++++++++++++++---
8 files changed, 135 insertions(+), 40 deletions(-)
delete mode 100644 playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.md
create mode 100644 playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_rails.md
create mode 100644 playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_react.md
diff --git a/playbook/app/pb_kits/playbook/pb_form_pill/_form_pill.scss b/playbook/app/pb_kits/playbook/pb_form_pill/_form_pill.scss
index 87f00ef302..2541ef05f8 100644
--- a/playbook/app/pb_kits/playbook/pb_form_pill/_form_pill.scss
+++ b/playbook/app/pb_kits/playbook/pb_form_pill/_form_pill.scss
@@ -142,7 +142,9 @@ $form_pill_colors: map-merge($status_color_text, map-merge($data_colors, $produc
height: 12px !important;
width: 12px !important;
padding-right: $space_xs;
- + .pb_form_pill_text, + .pb_form_pill_tag {
+ + .pb_form_pill_text, + .pb_form_pill_tag,
+ + .pb_tooltip_kit .pb_form_pill_text, + .pb_tooltip_kit .pb_form_pill_tag,
+ + div .pb_form_pill_text, + div .pb_form_pill_tag {
padding-left: 0;
}
}
@@ -169,7 +171,9 @@ $form_pill_colors: map-merge($status_color_text, map-merge($data_colors, $produc
}
.pb_form_pill_icon {
padding-right: $space_xxs;
- + .pb_form_pill_text, + .pb_form_pill_tag {
+ + .pb_form_pill_text, + .pb_form_pill_tag,
+ + .pb_tooltip_kit .pb_form_pill_text, + .pb_tooltip_kit .pb_form_pill_tag,
+ + div .pb_form_pill_text, + div .pb_form_pill_tag {
padding-left: 0;
}
}
diff --git a/playbook/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx b/playbook/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx
index 9cbff71a4c..0ea0f7d02b 100644
--- a/playbook/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx
+++ b/playbook/app/pb_kits/playbook/pb_form_pill/_form_pill.tsx
@@ -3,6 +3,7 @@ import classnames from 'classnames'
import Title from '../pb_title/_title'
import Icon from '../pb_icon/_icon'
import Avatar from '../pb_avatar/_avatar'
+import Tooltip from '../pb_tooltip/_tooltip'
import { globalProps, GlobalProps } from '../utilities/globalProps'
import { buildDataProps, buildHtmlProps } from '../utilities/props'
@@ -62,6 +63,30 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
const dataProps = buildDataProps(data)
const htmlProps = buildHtmlProps(htmlOptions)
+ const renderTitle = (content: string, className: string) => {
+ const titleComponent = (
+
+ )
+ if (props.truncate) {
+ return (
+
+ {titleComponent}
+
+ )
+ }
+ return titleComponent
+ }
+
return (
{
size="xxs"
status={null}
/>
-
+ {renderTitle(name, "pb_form_pill_text")}
>
)}
{((name && icon && !text) || (name && icon && text)) && (
@@ -93,12 +113,7 @@ const FormPill = (props: FormPillProps): React.ReactElement => {
size="xxs"
status={null}
/>
-
+ {renderTitle(name, "pb_form_pill_text")}
{
color={color}
icon={icon}
/>
-
+ {renderTitle(text, "pb_form_pill_tag")}
>
)}
- {(!name && !icon && text) && (
-
- )}
+ {(!name && !icon && text) && renderTitle(text, "pb_form_pill_tag")}
{
)
}
+
export default FormPill
diff --git a/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.html.erb b/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.html.erb
index 3e66bb7446..a298f19a09 100644
--- a/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.html.erb
+++ b/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.html.erb
@@ -13,7 +13,30 @@
id: "typeahead-form-pill",
is_multi: true,
options: names,
- label: "Names",
+ label: "Truncation Within Typeahead",
pills: true,
truncate: 1,
}) %>
+
+<%= pb_rails("caption", props: { text: "Form Pill Truncation" }) %>
+<%= pb_rails("card", props: { max_width: "xs" }) do %>
+ <%= pb_rails("form_pill", props: {
+ name: "Princess Amelia Mignonette Grimaldi Thermopolis Renaldo",
+ avatar_url: "https://randomuser.me/api/portraits/women/44.jpg",
+ tabindex: 0,
+ truncate: 1,
+ id: "truncation-1"
+ }) %>
+ <%= pb_rails("form_pill", props: {
+ icon: "badge-check",
+ text: "icon and a very long tag to show truncation",
+ tabindex: 0,
+ truncate: 1,
+ id: "truncation-2"
+ }) %>
+ <%= pb_rails("form_pill", props: {
+ text: "form pill long tag no tooltip show truncation",
+ tabindex: 0,
+ truncate: 1,
+ }) %>
+<% end %>
\ No newline at end of file
diff --git a/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.jsx b/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.jsx
index b599017782..51a8a3e2a5 100644
--- a/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.jsx
+++ b/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.jsx
@@ -1,5 +1,5 @@
import React from 'react'
-import Typeahead from '../../pb_typeahead/_typeahead'
+import { Card, Caption, FormPill, Typeahead } from 'playbook-ui'
const names = [
{ label: 'Alexander Nathaniel Montgomery', value: 'Alexander Nathaniel Montgomery' },
@@ -15,11 +15,34 @@ const FormPillTruncatedText = (props) => {
+
+
+ alert('Click!')}
+ tabIndex={0}
+ truncate={1}
+ />
+ {alert('Click!')}}
+ tabIndex={0}
+ text="icon and a very long tag to show truncation"
+ truncate={1}
+ />
+ {alert('Click!')}}
+ tabIndex={0}
+ text="form pill with a very long tag to show truncation"
+ truncate={1}
+ />
+
>
)
}
diff --git a/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.md b/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.md
deleted file mode 100644
index e960dc2deb..0000000000
--- a/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text.md
+++ /dev/null
@@ -1 +0,0 @@
-For 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.
\ No newline at end of file
diff --git a/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_rails.md b/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_rails.md
new file mode 100644
index 0000000000..fc0593464e
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_rails.md
@@ -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.
\ No newline at end of file
diff --git a/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_react.md b/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_react.md
new file mode 100644
index 0000000000..5b35756d8c
--- /dev/null
+++ b/playbook/app/pb_kits/playbook/pb_form_pill/docs/_form_pill_truncated_text_react.md
@@ -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.
\ No newline at end of file
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 b9ddf68b86..4e42ddabb6 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,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 %>
+
+ <%= 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 %>
+
+ <% 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 %>
+
+ <%= 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 %>
+
+ <% 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 %>
\ No newline at end of file