Leaderboard Component

The Leaderboard component efficiently displays and manages leaderboards in React, offering customizable styling. Users can easily monitor progress and compete through its clear interface.

Component Visuals

To unlock early access to the component Get Access

Installation

To install the Quest react-sdk into your project, follow these steps:

  • Open your terminal/command prompt.

  • Navigate to your project's root directory using the cd command if you're not already there.

  • Run the following command to install the quest-sdk package using npm:

npm install @questlabs/react-sdk

This command will download and install the package and its dependencies into your project.

Make sure your project has npm and Node.js installed, and that you have the necessary permissions to install packages in your project directory.

Features

  • Customizable Styling: Users can customize the appearance of the leaderboard to align with their platform's branding or design preferences. This includes options to adjust colors, fonts, and layout, providing a seamless integration into the overall user interface.

  • Versatile Leaderboard Component: Integrate a comprehensive leaderboard feature into your app, enabling dynamic tracking and visualization of user standings based on accumulated points or experience. Tailor the leaderboard to suit diverse engagement scenarios and foster competition and community interaction within your platform.

Props of Leaderboard Component

The Leaderboard component accepts the following props:

Prop NameTypeRequiredDetails

token

string

required

An authentication token or API key necessary for accessing Leaderboard or quest data.

userId

string

required

The unique identifier of the user.

styleConfig

object

optional

An object containing CSS properties for styling various components within the Leaderboard process, including main heading, heading, descriptions, points color,,points background,inner background, index color, index background , progressbar color, and icon style .

You can customize the UI with type of styleConfig would be

  styleConfig?: {{
Form?:CSSProperties;
  MainHeading?: CSSProperties;
  Heading?: CSSProperties;
  Description?: CSSProperties;
  PointsBackground?:CSSProperties
  PointsColor?: CSSProperties;
  InnerBackground?:CSSProperties;
  IndexColor?:CSSProperties;
  IndexBackground?:CSSProperties;
  ProgressBarColor?: CSSProperties;
  IconStyle?:{
    color? :string;
  }
  Footer?: {
    FooterStyle?: CSSProperties;
    FooterText?: CSSProperties;
    FooterIcon?: CSSProperties;
  };

Usage

To integrate the Leaderboard component into your React application, follow these steps:

  • Import the CSS: In your JavaScript or TypeScript file where you're using the Leaderboard, import the CSS styles for the component. This ensures that the component's styling is applied correctly.

  • Import the QuestProvider Component: Import the QuestProvider component from the @questlabs/react-sdk package.

import { QuestProvider, LeaderBoard } from '@questlabs/react-sdk';
  • Pass the Required Props: Pass the required props to the QuestProvider. The required props are apiKey, apiSecret, apiType and entityId. Additionally, include an optional themeConfig. and required props for the Leaderboard component are userId,token , with an optional prop styleConfig .

<QuestProvider
  apiKey="your-api-key"
  apiSecret="your-api-secret"
  entityId="your-entity-id"
  apiType={"STAGING" or "PRODUCTION"}
  themeConfig={{
          backgroundColor: CSSProperties;
          borderColor: CSSProperties;
          buttonColor:CSSProperties;
          primaryColor: CSSProperties;
          secondaryColor: CSSProperties;
          fontFamily:CSSProperties;
        }}  
>
  <LeaderBoard
    userId="your user-id"
    token="your-token"
    styleConfig={{
    Form?:CSSProperties;
    MainHeading?: CSSProperties;
    Heading?: CSSProperties;
    Description?: CSSProperties;
    InnerBackground?:CSSProperties;
    IndexColor?:CSSProperties;
    IndexBackground?:CSSProperties;
    PointsBackground?:CSSProperties;
    PointsColor?: CSSProperties;
    ProgressBarColor?: CSSProperties;
    Footer?: CSSProperties;
    IconStyle?:{
    color? :string;
  }
    }}
  />
</QuestProvider>

Replace "your-api-key","apiSecret" and "your-entity-id" with your actual Quest API credentials

Replace "your -userId" and "your-token" with your actual configuration details.

Example Usage

Here's an example of how to use the Leaderboard component within your React application

import { QuestProvider}, LeaderBoard from '@questlabs/react-sdk';

function App() {
  return (
    <div>
      <QuestProvider
        apiKey="k-xc-ac8f-x1-xxx8b-a175xx"
        apiSecret="s-7xxx-2xe4-4xx1-ax07-3xxxx358a-d9xd-xx76-bx4x-a0xxdd36"
        entityId="e-xxxx-b75b-xxxx-be9a-ee11f0f0xxxx"
        apiType={"STAGING" or "PRODUCTION"}
         themeConfig={{
          backgroundColor: "green",
          borderColor:"blue",
          buttonColor:"blue",
          primaryColor:"green"
          secondaryColor: "yellow"
          fontFamily:"sarif"
        }} 
      >
       <LeaderBoard
          token="<your jwt user token>"
          userId="your userId"
          styleConfig={{
            Description: {},
            Footer: { FooterStyle: {}, FooterText: {}, FooterIcon: {} },
            Form: {},
            Heading: {},
            IconStyle: {},
            IndexBackground: {},
            IndexColor: {},
            InnerBackground: {},
            MainHeading: {},
            PointsBackground: {},
            PointsColor: {},
            ProgressBarColor: {},
          }}
        />
      </QuestProvider>
    </div>
  );
}

export default App;

The above example uses all the props.

Last updated