CreditsPopup Component

The CreditsPopup component is a React component that provides a customizable popup for displaying information, alerts, or notifications to users.

CreditsPopup Component Features

  1. Customizable Content: The component allows you to customize the heading text, description text, and button text to convey specific information to users.

  2. Closable Popup: You can enable or disable the close button to allow users to close the popup when needed.

  3. Continue Button: Optionally, you can include a continue button with a specified action when clicked.

CreditsPopup Component Props

The CreditsPopup component accepts the following props:

  • isOpen (boolean, required): Controls the visibility of the popup. If true, the popup is displayed. If false, it is hidden.

  • onClose (function, required): A callback function that is called when the user closes the popup. It is typically used to change the isOpen state in the parent component.

  • headingText (React.ReactNode, required): The content to be displayed as the heading text of the popup.

  • descText (React.ReactNode, required): The content to be displayed as the description text of the popup.

  • isCloseble (boolean, optional): Determines whether the close button is displayed. If true, the close button is shown. If false, it is hidden. Defaults to false.

  • continueButton (boolean, optional): Determines whether the continue button is displayed. If true, the button is shown. If false, it is hidden. Defaults to false.

  • buttonText (string, optional): The text to be displayed on the continue button. It is only visible if continueButton is true.

  • buttonFunction (function, optional): A callback function that is called when the continue button is clicked. It allows you to define a specific action to be performed when the button is pressed.

CreditsPopup Component Usage

To use the CreditsPopup component in your React application:

Import the component:

import {CreditsPopup} from '@questLabs/react-sdk';

Include the component in your JSX, passing the required props:

<CreditsPopup
  isOpen={true}
  onClose={() => handleClosePopup()}
  headingText="Popup Heading"
  descText="This is the popup description."
  isCloseble={true}
  continueButton={true}
  buttonText="Continue"
  buttonFunction={() => handleContinueButtonClick()}
/>
  1. Customize the content, visibility, and behavior of the popup by adjusting the props accordingly.

  2. Use state management to control the isOpen prop based on user interactions or application logic.

Example

Here's a simple example of how to use the CreditsPopup component in a React application:

import React, { useState } from 'react';
import {CreditsPopup} from '@questLabs/react-sdk';

function App() {
  const [isPopupOpen, setIsPopupOpen] = useState(false);

  const handleClosePopup = () => {
    setIsPopupOpen(false);
  };

  const handleOpenPopup = () => {
    setIsPopupOpen(true);
  };

  const handleContinueButtonClick = () => {
    // Define the action to be performed when the continue button is clicked
  };

  return (
    <div>
      <h1>Your Application</h1>
      <button onClick={handleOpenPopup}>Show Popup</button>
      <CreditsPopup
        isOpen={isPopupOpen}
        onClose={handleClosePopup}
        headingText="Popup Heading"
        descText="This is the popup description."
        isCloseble={true}
        continueButton={true}
        buttonText="Continue"
        buttonFunction={handleContinueButtonClick}
      />
    </div>
  );
}

export default App;

Last updated