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.


The LeaderBoardcomponent accepts the following props

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 '@questlabs/react-sdk/dist/style.css'
  • Import the TutorialComponent: Import the LeaderBoardcomponent from the @questlabs/react-sdk package.

  • 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, and entityId. and required props for the LeaderBoard component are userId, questId, token

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

Replace "your-token", "your-user-id", "your-questId" with your actual configuration details.

Code & Steps

import { QuestProvider, LeaderBoard } from '@questlabs/react-sdk';
import '@questlabs/react-sdk/dist/style.css'

function App() {
  return (
      <QuestProvider
        apiKey="your-apikey"
        entityId="your-entity-Id" 
        apiType= "PRODUCTION" // STAGING 
      >
        <LeaderBoard> </LeaderBoard>
      </QuestProvider>
  );
}

export default App;


Example Usage

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

import { QuestProvider, LeaderBoard } from '@questlabs/react-sdk';
import '@questlabs/react-sdk/dist/style.css'

function App() {
  return (
    <div>
      <QuestProvider
        apiKey="your-apikey"
        entityId="your-entity-Id" 
        apiType= "PRODUCTION" // STAGING 
      >
       <LeaderBoard 
          userId=""
          questId=""
          token=""
          uniqueUserId="your-unique-user-id"
        >
          <LeaderBoard.Header />
          <LeaderBoard.Content />
          <LeaderBoard.Footer />
        </LeaderBoard>
      </QuestProvider>
    </div>
  );
}

export default App;

The above example uses all the props.

Props of Leaderboard Component

The Leaderboard component accepts the following props:

Prop Name
Type
Required
Details

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 .

userLimit

number

optional

Limits the user

isXpImage

boolean

optional

Hide or show Xp image

DefaultImage

string

optional

To set default image

DefaultName

string

optional

To set default Nmae

FirstRankIconImage

string

optional

To set the image of first ranker

SecondRankIconImage

string

optional

To set the image of second ranker

ThirdRankIconImage

string

optional

To set the image of third ranker

IsTopRank

boolean

optional

To tell top rank or not

styleConfig = {{
    PresentUser: { },
    Description: { },
    Footer: {
        FooterIcon: { },
        FooterLink: "",
            FooterStyle: { },
        FooterText: "",
            FooterTextStyle: { }
    },
    Form: { },
    Heading: { },
    IconStyle: {
        color: ""
    },
    IndexBackground: { },
    IndexColor: { },
    InnerBackground: { },
    MainHeading: { },
    PointsBackground: { },
    PointsColor: { },
    ProgressBarColor: { }
}}

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.

You can customize the UI with type of styleConfig would be

Last updated