Skip to main content

Grade

The Grade component displays grade information in a clean, pressable card format.

Import

import { Grade } from 'papillon-ui';

Basic Usage

<Grade
  title="Mathematics Test"
  date={Date.now()}
  score={16.5}
  outOf={20}
  color="#4A90E2"
  onPress={() => {}}
/>

Props

title
string
required
Grade title or description
date
number
required
Date timestamp (milliseconds)
score
number
required
Grade score value
outOf
number
required
Maximum possible score
color
string
Grade color (hex)
disabled
boolean
default:false
Disabled state (shows status instead of score)
status
string
Status text (shown when disabled)
skeleton
boolean
default:false
Loading skeleton state
onPress
() => void
Press handler callback

Positioning

isFirst
boolean
default:false
Adds rounded corners at the top
isLast
boolean
default:false
Adds rounded corners at the bottom and bottom margin

Examples

Standard Grade

<Grade
  title="Physics Quiz"
  date={Date.now()}
  score={18}
  outOf={20}
  color="#10B981"
  onPress={() => showDetails()}
/>

Disabled Grade

<Grade
  title="Upcoming Test"
  date={Date.now()}
  score={0}
  outOf={20}
  disabled
  status="Non noté"
  color="#6B7280"
/>

Grade List

function GradeList({ grades }) {
  return (
    <View>
      {grades.map((grade, index) => (
        <Grade
          key={grade.id}
          isFirst={index === 0}
          isLast={index === grades.length - 1}
          title={grade.title}
          date={grade.date}
          score={grade.score}
          outOf={grade.outOf}
          color={grade.color}
          onPress={() => navigate('GradeDetail', { id: grade.id })}
        />
      ))}
    </View>
  );
}

Skeleton Loading

<Grade
  title=""
  date={Date.now()}
  score={0}
  outOf={20}
  skeleton
/>

Build docs developers (and LLMs) love