EliteLoyaltyPill
Pill component for Elite and partner loyalty programs (e.g. Flipkart Black). Supports web and React Native.
Installation
npm install @cleartrip/ct-design-loyalty-pill
# or
pnpm add @cleartrip/ct-design-loyalty-pill
Peer dependencies
# Required for all targets
npm install react
npm install styled-components
# Web only
npm install react-dom
# React Native only
npm install react-native
npm install react-native-linear-gradient
Usage
Basic
import { EliteLoyaltyPill, EliteLoyaltyPillStateEnum, LoyaltyProgram } from '@cleartrip/ct-design-loyalty-pill';
function Example() {
return <EliteLoyaltyPill state={EliteLoyaltyPillStateEnum.UNLOCKED} onClick={() => console.log('clicked')} />;
}
With states
<EliteLoyaltyPill state={EliteLoyaltyPillStateEnum.LOGGED_OUT} />
<EliteLoyaltyPill state={EliteLoyaltyPillStateEnum.LOCKED} />
<EliteLoyaltyPill state={EliteLoyaltyPillStateEnum.UNLOCKED} />
<EliteLoyaltyPill state={EliteLoyaltyPillStateEnum.EXPIRING} />
Partner program (FK Black)
<EliteLoyaltyPill loyaltyProgram={LoyaltyProgram.FK_BLACK} href='/fk-black' />
With animation
<EliteLoyaltyPill state={EliteLoyaltyPillStateEnum.UNLOCKED} isVisible={lottieComplete} animate={lottieComplete} />
Props
| Prop |
Type |
Default |
Required |
Description |
state |
EliteLoyaltyPillState |
— |
No |
Elite pill state |
loyaltyProgram |
'ELITE' \| 'FK_BLACK' |
'ELITE' |
No |
Loyalty program; partner modes use image pill |
loading |
boolean |
false |
No |
Shows shimmer skeleton |
error |
Error \| null |
— |
No |
Error from data layer |
onClick |
() => void |
— |
No |
Click / press handler |
onIntersection |
() => void |
— |
No |
Fires once when pill enters viewport |
onHover |
(isHovered: boolean) => void |
— |
No |
Hover callback (web) |
animate |
boolean |
false |
No |
Slide-in animation |
isVisible |
boolean |
true |
No |
When false, pill is not rendered |
href |
string |
— |
No |
Link for partner pills |
className |
string |
— |
No |
Style override (web) |
ravenEventPrefix |
string |
'' |
No |
Prefix for Raven events |
ravenAttributes |
Record<string, string \| number> |
— |
No |
Extra Raven payload fields |
ravenPushCallback |
RavenPushCallback |
— |
No |
Raven push function |
States
LOGGED_OUT — Elite outline pill
LOCKED — Unlock Elite (filled)
UNLOCKED — Elite (filled)
EXPIRING — Elite + warning badge
SUSPENDED — Not rendered
Loyalty programs
ELITE — State-based Elite pill (default)
FK_BLACK — Partner image pill (href supported)
Accessibility
- Interactive Elite pill uses a button element
- Partner pills use a link when
href is provided
- Expiring warning badge is visually indicated
Migration
- import { LoyaltyPill } from '...'
+ import { EliteLoyaltyPill, EliteLoyaltyPillStateEnum, LoyaltyProgram } from '@cleartrip/ct-design-loyalty-pill';