2.1.0 • Published 1 month ago

@lg-chat/message-feedback v2.1.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
1 month ago

Message Feedback

npm (scoped)

View on MongoDB.design

Installation

Yarn

yarn add @leafygreen-ui/message-feedback

NPM

npm install @leafygreen-ui/message-feedback

Examples

InlineMessageFeedback

<InlineMessageFeedback {...props} />

PopoverMessageFeedback

const triggerRef = useRef(null);
const [isActive, setIsActive] = useState<boolean>(false);

const closePopover = () => setIsActive(false);

const handleRatingChange: ChangeEventHandler<HTMLInputElement> = e => {
  const rating = e.target.value as MessageRatingValue;
  setIsActive(rating === 'disliked');
};


return (
  <>
    <MessageRating
      ref={triggerRef}
      onChange={handleRatingChange}
    />
    <PopoverMessageFeedback
      popoverProps={{
        ...popoverProps,
        active: isActive,
        refEl: triggerRef,
      }}
      onCancel={closePopover}
      onSubmit={closePopover}
    />
  </>
);

Properties

InlineMessageFeedback

Properties

PropTypeDescriptionDefault
cancelButtonTextstringText displayed inside the cancel Button'Cancel'
onCancelMouseEventHandler<HTMLElement>Click event handler for the cancel Button
cancelButtonPropsButtonPropsOverride props for the cancel Button
submitButtonTextstringText displayed inside the submit Button
submitButtonPropsButtonPropsOverride props for the submit Button
onSubmitFormEventHandler<HTMLFormElement>Event handler called when the form is submitted
textareaPropsTextAreaPropsProps passed directly to the Textarea
isSubmittedbooleanIndicates if the component should render in its submitted statefalse
submittedMessagestringMessage rendered in submitted state'Submitted! Thanks for your feedback.'
labelTextAreaProps['label']
onClosestringEvent handler called on close button click. Close button will not be rendered when undefined. This is mainly for internal use as most instances of InlineMessageFeedback should be closed solely by onCancel.

PopoverMessageFeedback

PropTypeDescriptionDefault
popoverZIndexnumberZ-index of the Popover

PopoverMessageFeedback extends all InlineMessageFeedback props excluding isSubmitted and submittedMessage. To provide feedback to the end user after a successful submit, refer to our design guidelines for the appropriate design pattern.

PopoverMessageFeedback also extends all Popover props excluding children.