-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PBNTR-595] Follow up to Fixed Width Filter issue on Templates (#3827)
**What does this PR do?** A clear and concise description with your runway ticket url. [PBNTR-595](https://runway.powerhrg.com/backlog_items/PBNTR-595) implements the popoverProps component on the Filter kit which will unblock PBNTR's template work by allowing the team to set an optimal Filter Popover width on our templates without using inline styling or a separate scss file. PopoverProps are connected to the embedded Popover within the Filter kit (by spreading the popoverProps prop React, and by merging popover_props to the rest of the props in Rails). A "Popover Props" doc example has been added to the Rails and React kit pages which shows using the popover prop to set a custom width on the filter popover. The Popover kit itself now accepts a width prop to allow us to achieve this - no doc example necessary at this time. This is associated with an [alpha PR here](linktocome) to demonstrate its use to prevent the Rails template popover width from jumping every time an item is added to the Filter's Typeahead. **Screenshots:** Screenshots to visualize your addition/change Rails Popover Props doc example <img width="1343" alt="for PR popover props doc ex rails" src="https://github.com/user-attachments/assets/042ee607-5353-43c5-a583-aca143663577"> React Popover Props doc example <img width="1338" alt="for PR popover props doc ex react" src="https://github.com/user-attachments/assets/bb2d7d15-f52b-4772-9aee-ece6906bc69e"> Rails Template with `popover_props` applying a set width to avoid the filter popover jumping with each additional typeahead entry desktop+mobile <img width="1530" alt="for PR rails template desktop filter fixed width" src="https://github.com/user-attachments/assets/a9545f90-af36-4f2a-9dcb-b9a3c25f44b2"> <img width="194" alt="for PR rails template mobile filter fixed width" src="https://github.com/user-attachments/assets/6e658743-4146-41e9-8e80-74f9c7494452"> **How to test?** Steps to confirm the desired behavior: 1. Go to the filter kit review env page, specifically to the Popover Props doc example ([rails](https://pr3827.playbook.beta.px.powerapp.cloud/kits/filter#popover-props), [react](https://pr3827.playbook.beta.px.powerapp.cloud/kits/filter/react#popover-props)) 2. Click on Filter popover button and see a smaller-than-usual Filter popover appear. Compare to other doc examples on the page (default, etc.) to see the difference. 3. Go to the [rails template page](https://pr43315.nitro-web.beta.hq.powerapp.cloud/dev_docs/playbook/templates/demos/basic_table/rails) in the review environment with alpha from this PR. 4. Open the Filter and add several items to the typeahead. The width of the popover should not jump with every additional entry. #### 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
d7b8e5e
commit a04ad24
Showing
14 changed files
with
139 additions
and
6 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
41 changes: 41 additions & 0 deletions
41
playbook/app/pb_kits/playbook/pb_filter/docs/_filter_popover_props.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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<%= | ||
pb_rails("filter", props: { | ||
id: "filter_popover_props", | ||
position: "top", | ||
filters: [ | ||
{ name: "name", value: "John Wick" }, | ||
{ name: "city", value: "San Francisco"} | ||
], | ||
sort_menu: [ | ||
{ item: "Popularity", link: "?q[sorts]=managers_popularity+asc", active: true, direction: "desc" }, | ||
{ item: "Mananger's Title", link: "?q[sorts]=managers_title+asc", active: false }, | ||
{ item: "Manager's Name", link: "?q[sorts]=managers_name+asc", active: false }, | ||
], | ||
template: "default", | ||
results: 1, | ||
popover_props: { width: "250px" }, | ||
}) do | ||
%> | ||
<% | ||
example_collection = [ | ||
OpenStruct.new(name: "USA", value: 1), | ||
OpenStruct.new(name: "Canada", value: 2), | ||
OpenStruct.new(name: "Brazil", value: 3), | ||
OpenStruct.new(name: "Philippines", value: 4), | ||
OpenStruct.new(name: "A galaxy far far away, like really far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far away...", value: 5) | ||
] | ||
%> | ||
<%= pb_rails("form", props: { form_system_options: { scope: :example, method: :get } }) do |form| %> | ||
<%= form.text_field :example_text_field, props: { label: true } %> | ||
<%= form.collection_select :example_collection_select, example_collection, :value, :name, props: {max_width: "sm", label: true } %> | ||
|
||
<%= form.actions do |action| %> | ||
<%= action.submit props: { | ||
text: "Apply", | ||
data: { | ||
disable_with: "pb_rails('icon', props: { icon: 'spinner', spin: true, fixed_width: true })Searching...".html_safe | ||
},}%> | ||
<%= action.button props: { type: "reset", text: "Clear", variant: "secondary" } %> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
71 changes: 71 additions & 0 deletions
71
playbook/app/pb_kits/playbook/pb_filter/docs/_filter_popover_props.jsx
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,71 @@ | ||
import React from 'react' | ||
import { Button, Filter, Flex, Select, TextInput } from 'playbook-ui' | ||
|
||
const FilterPopoverProps = (props) => { | ||
const options = [ | ||
{ value: 'USA' }, | ||
{ value: 'Canada' }, | ||
{ value: 'Brazil' }, | ||
{ value: 'Philippines' }, | ||
{ value: 'A galaxy far far away, like really far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far far away...' }, | ||
] | ||
|
||
const popoverProps = { | ||
width: "250px" | ||
} | ||
|
||
return ( | ||
<Filter | ||
{...props} | ||
double | ||
filters={{ | ||
'Full Name': 'John Wick', | ||
'City': 'San Francisco', | ||
}} | ||
popoverProps={popoverProps} | ||
results={1} | ||
sortOptions={{ | ||
popularity: 'Popularity', | ||
// eslint-disable-next-line | ||
manager_title: 'Manager\'s Title', | ||
// eslint-disable-next-line | ||
manager_name: 'Manager\'s Name', | ||
}} | ||
sortValue={[{ name: 'popularity', dir: 'desc' }]} | ||
> | ||
{({ closePopover }) => ( | ||
<form> | ||
<TextInput | ||
label="Example Text Field" | ||
placeholder="Enter Text" | ||
{...props} | ||
/> | ||
<Select | ||
blankSelection="Select One..." | ||
label="Example Collection Select" | ||
name="Collection Select" | ||
options={options} | ||
{...props} | ||
/> | ||
<Flex | ||
spacing="between" | ||
{...props} | ||
> | ||
<Button | ||
onClick={closePopover} | ||
text="Apply" | ||
{...props} | ||
/> | ||
<Button | ||
text="Clear" | ||
variant="secondary" | ||
{...props} | ||
/> | ||
</Flex> | ||
</form> | ||
)} | ||
</Filter> | ||
) | ||
} | ||
|
||
export default FilterPopoverProps |
1 change: 1 addition & 0 deletions
1
playbook/app/pb_kits/playbook/pb_filter/docs/_filter_popover_props_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 @@ | ||
This kit uses the [Popover kit](https://playbook.powerapp.cloud/kits/popover) under the hood for the Filter Popover which comes with its own set of props. If you want to apply certain Popover props to that underlying kit, you can do so by using the optional `popover_props` prop. This prop must be an object that contains valid Popover props. For a full list of Popover props, see [here](https://playbook.powerapp.cloud/kits/popover). |
1 change: 1 addition & 0 deletions
1
playbook/app/pb_kits/playbook/pb_filter/docs/_filter_popover_props_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 @@ | ||
This kit uses the [Popover kit](https://playbook.powerapp.cloud/kits/popover/react) under the hood for the Filter Popover which comes with its own set of props. If you want to apply certain Popover props to that underlying kit, you can do so by using the optional `popoverProps` prop. This prop must be an object that contains valid Popover props. For a full list of Popover props, see [here](https://playbook.powerapp.cloud/kits/popover/react). |
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
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