import React, {FC, ReactNode, useCallback} from "react"; import {ColorOption, ColorOptionWithCustomTint, groupHover, hover, request, useColor} from "./Color"; import classNames from "classnames"; import {CouponsPlus} from "../globals"; import {LegacyTestableGroupMode} from "./testableGroupTypes"; export type ActionType = LegacyTestableGroupMode | string export type RightContextButtonProps = ColorOptionWithCustomTint & { type: ActionType, label: string | ((buttonIsHovered: boolean) => ReactNode), onClick: () => void, onRightButtonHoverStart?: (type: ActionType) => void, onRightButtonHoverEnd?: (type: ActionType) => void, thickness?: number, bringButtonToFrontOnHover?: boolean, uppercased?: boolean, labelSize?: string, direction?: 'horizontal' | 'vertical', scope?: 'offer' | 'testables' // default is testables,, } export const RightContextButton: FC = ({ type, color, label, onClick, onRightButtonHoverStart, onRightButtonHoverEnd, thickness, bringButtonToFrontOnHover = true, uppercased = true, labelSize, direction = 'horizontal', scope = 'testables', }) => { const [buttonIsHovered, setButtonIsHovered] = React.useState(false) /* if (scope === 'testables' && !CouponsPlus.implementations.engine.testableComposite) { return null } */ const handleClick = useCallback((e) => { e.stopPropagation() onClick() }, [onClick]) const renderedLabel = typeof label === 'function' ? label(buttonIsHovered) : label return
; }