-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(popover): add form pill button (#4018)
* feat(popover): add form pill button * chore: kristians fix * feat(popover): form pill final impl * feat(popover): added variant to FormPillGroup and created PopoverFormPillButton * feat(docs): update popover and FormPill docs for new variants * Apply suggestions from code review Co-authored-by: Sarah <[email protected]> * chore(docs): pr structure suggestion * chore(docs): addressing pr comments * chore(docs): addressing pr comments * chore(docs): typedocs * chore(docs): mention coming soon links --------- Co-authored-by: Kristian Antrobus <[email protected]> Co-authored-by: krisantrobus <[email protected]> Co-authored-by: Sarah <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
- Loading branch information
1 parent
0da577f
commit 8cdebfe
Showing
22 changed files
with
743 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@twilio-paste/form-pill-group": minor | ||
"@twilio-paste/core": minor | ||
--- | ||
|
||
[FormPillGroup] added a new variant 'tree' to support different interactions for FormPill where selecting the item triggers other flows instead of updating state directly. Reference Filters Pattern for in depth use case. |
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,7 @@ | ||
--- | ||
"@twilio-paste/codemods": minor | ||
"@twilio-paste/popover": minor | ||
"@twilio-paste/core": minor | ||
--- | ||
|
||
[Popover] Added a new button variant to trigger the popover PopoverFormPillButton, only to be used as part of complex filters pattern |
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
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
36 changes: 36 additions & 0 deletions
36
packages/paste-core/components/popover/src/PopoverFormPillButton.tsx
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,36 @@ | ||
import { FormPill } from "@twilio-paste/form-pill-group"; | ||
import { NonModalDialogDisclosurePrimitive } from "@twilio-paste/non-modal-dialog-primitive"; | ||
import * as React from "react"; | ||
|
||
import { PopoverContext } from "./PopoverContext"; | ||
import type { PopoverFormPillButtonProps } from "./types"; | ||
|
||
const PopoverFormPillButton = React.forwardRef<HTMLElement, PopoverFormPillButtonProps>( | ||
({ children, element = "POPOVER_FORM_PILL", ...popoverButtonProps }, ref) => { | ||
const popover = React.useContext(PopoverContext); | ||
|
||
return ( | ||
<NonModalDialogDisclosurePrimitive | ||
element={element} | ||
{...(popover as any)} | ||
{...popoverButtonProps} | ||
as={FormPill} | ||
ref={ref} | ||
onSelect={(e: React.MouseEvent<HTMLButtonElement>) => { | ||
// @ts-expect-error Property 'toggle' does not exist on type 'Partial<PopoverState>', but it is there as it comes form DialogActions prop. | ||
popover.toggle(); | ||
// Call the actual onsSelect function passed to the component | ||
if (popoverButtonProps.onSelect) { | ||
popoverButtonProps.onSelect(e); | ||
} | ||
}} | ||
baseId={popover.baseId} | ||
> | ||
{children} | ||
</NonModalDialogDisclosurePrimitive> | ||
); | ||
}, | ||
); | ||
|
||
PopoverFormPillButton.displayName = "PopoverFormPillButton"; | ||
export { PopoverFormPillButton }; |
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
Oops, something went wrong.