From 37e8f29458391eb39272e844f562cd4043355d1c Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Sun, 25 Feb 2024 17:37:58 -0800 Subject: [PATCH] Merge pull request #443 from xmtp-labs/02-25-Redesign_Frames_buttons --- .../components/Frame/Frame.tsx | 125 +++++++++++++++--- 1 file changed, 105 insertions(+), 20 deletions(-) diff --git a/src/component-library/components/Frame/Frame.tsx b/src/component-library/components/Frame/Frame.tsx index bb81389f..8816a83c 100644 --- a/src/component-library/components/Frame/Frame.tsx +++ b/src/component-library/components/Frame/Frame.tsx @@ -1,5 +1,7 @@ -import { GhostButton } from "../GhostButton/GhostButton"; +import { ArrowCircleRightIcon } from "@heroicons/react/outline"; import type { FrameButton } from "../../../helpers/frameInfo"; +import { classNames } from "../../../helpers"; +import { ButtonLoader } from "../Loaders/ButtonLoader"; type FrameProps = { image: string; @@ -15,6 +17,101 @@ type FrameProps = { interactionsEnabled: boolean; }; +const FrameButtonContainer = ({ + label, + isExternalLink, + isFullWidth, + isLoading, + isDisabled, + testId = "", + clickHandler, +}: { + testId?: string; + label: string; + isExternalLink: boolean; + isFullWidth: boolean; + isLoading: boolean; + isDisabled: boolean; + clickHandler: () => void; +}) => { + const columnWidth = isFullWidth ? "col-span-2" : "col-span-1"; + + const icon = isExternalLink ? : null; + return ( + + ); +}; + +const ButtonsContainer = ({ + frameButtonUpdating, + buttons, + handleClick, +}: Pick) => { + if (buttons.length < 1 || buttons.length > 4) { + return null; + } + // If there is only one button make it full-width + const gridColumns = buttons.length === 1 ? "grid-cols-1" : "grid-cols-2"; + return ( +
+ {buttons.map((button, index) => { + const clickHandler = () => { + void handleClick(button.buttonIndex, button.action); + }; + const isFullWidth = buttons.length === 3 && index === 2; + return ( + 0} + clickHandler={clickHandler} + /> + ); + })} +
+ ); +}; + export const Frame = ({ image, title, @@ -25,7 +122,7 @@ export const Frame = ({ frameButtonUpdating, interactionsEnabled, }: FrameProps) => ( -
+
{title} {!!textInput && interactionsEnabled && ( )}
- {interactionsEnabled ? ( - buttons.map((button) => { - if (!button) { - return null; - } - const handlePress = () => { - void handleClick(button.buttonIndex, button.action); - }; - return ( - 0} - /> - ); - }) + {interactionsEnabled && buttons.length ? ( + ) : ( Frame interactions not supported )}