diff --git a/playbook/app/pb_kits/playbook/pb_filter/Filter/FilterDouble.tsx b/playbook/app/pb_kits/playbook/pb_filter/Filter/FilterDouble.tsx index 7d15d84d12..ecb21b72ad 100644 --- a/playbook/app/pb_kits/playbook/pb_filter/Filter/FilterDouble.tsx +++ b/playbook/app/pb_kits/playbook/pb_filter/Filter/FilterDouble.tsx @@ -34,6 +34,7 @@ const FilterDouble = ({ maxHeight, minWidth, placement, + popoverProps, ...bgProps }: FilterDoubleProps): React.ReactElement => ( {children} diff --git a/playbook/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx b/playbook/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx index 4d8b285f01..950575006b 100644 --- a/playbook/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx +++ b/playbook/app/pb_kits/playbook/pb_filter/Filter/FilterSingle.tsx @@ -33,6 +33,7 @@ const FilterSingle = ({ maxHeight, minWidth, placement, + popoverProps, ...bgProps }: FilterSingleProps): React.ReactElement => { return ( @@ -52,6 +53,7 @@ const FilterSingle = ({ maxHeight={maxHeight} minWidth={minWidth} placement={placement} + popoverProps={popoverProps} > {children} diff --git a/playbook/app/pb_kits/playbook/pb_filter/Filter/FiltersPopover.tsx b/playbook/app/pb_kits/playbook/pb_filter/Filter/FiltersPopover.tsx index 72ce03420a..362915bcc0 100644 --- a/playbook/app/pb_kits/playbook/pb_filter/Filter/FiltersPopover.tsx +++ b/playbook/app/pb_kits/playbook/pb_filter/Filter/FiltersPopover.tsx @@ -2,6 +2,7 @@ import React, { ReactNode, useState } from 'react' import CircleIconButton from '../../pb_circle_icon_button/_circle_icon_button' import PbReactPopover from '../../pb_popover/_popover' +import { GenericObject } from '../../types' type FiltersPopoverProps = { children?: React.ReactChild[] | React.ReactChild | (({closePopover}: {closePopover: () => void}) => ReactNode), @@ -9,8 +10,9 @@ type FiltersPopoverProps = { maxHeight?: string, minWidth?: string, placement?: "top" | "right" | "bottom" | "left" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "right-start" | "right-end" | "left-start" | "left-end", + popoverProps?: GenericObject, } -const FiltersPopover = ({ children, dark, maxHeight, minWidth, placement = "bottom-start" }: FiltersPopoverProps): React.ReactElement => { +const FiltersPopover = ({ children, dark, maxHeight, minWidth, placement = "bottom-start", popoverProps }: FiltersPopoverProps): React.ReactElement => { const [hide, updateHide] = useState(true) const toggle = () => updateHide(!hide) @@ -33,6 +35,7 @@ const FiltersPopover = ({ children, dark, maxHeight, minWidth, placement = "bott reference={filterButton} shouldClosePopover={updateHide} show={!hide} + {...popoverProps} >
{typeof children === 'function' diff --git a/playbook/app/pb_kits/playbook/pb_filter/docs/_filter_popover_props.html.erb b/playbook/app/pb_kits/playbook/pb_filter/docs/_filter_popover_props.html.erb new file mode 100644 index 0000000000..da96315cce --- /dev/null +++ b/playbook/app/pb_kits/playbook/pb_filter/docs/_filter_popover_props.html.erb @@ -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 %> diff --git a/playbook/app/pb_kits/playbook/pb_filter/docs/_filter_popover_props.jsx b/playbook/app/pb_kits/playbook/pb_filter/docs/_filter_popover_props.jsx new file mode 100644 index 0000000000..d98bb00b04 --- /dev/null +++ b/playbook/app/pb_kits/playbook/pb_filter/docs/_filter_popover_props.jsx @@ -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 ( + + {({ closePopover }) => ( +
+ +