|Kit

Geodesic badges

Faceted solids that show where a learner stands on a module, project, exam, activity or skill. One shape per level, one colour per status.

The context badges from the Figma frame "Badges — 4 statuses, 4 levels" (42 UI Kit V3). Each kind of thing a learner works on has its own solid, and each status has its own colour, so a badge says what it is and where it stands at a glance.

import { GiftToken, ModuleBadge, ProjectBadge } from "@42-central/ui-react/geodesic";
import "@42-central/ui-react/geodesic/styles.css";

<ModuleBadge status="in-progress" progress={50} label="Graphics, in progress" />
<ProjectBadge status="done" size={48} />
<GiftToken hue="orange" icon={<Coffee />} />

The badges need their own stylesheet, @42-central/ui-react/geodesic/styles.css: it carries the status transitions and the progress fill.

Playground

Component

Loading preview

Props

Code

<Component
  status="in-progress"
  progress={50}
  size={96}
  label="Graphics, in progress"
/>

The grammar

  • One shape per level. The geodesic sphere is a module (ModuleBadge), the cube a project (ProjectBadge), the square slab on its square tile an exam (ExamBadge), the octahedron an activity (ActivityBadge), the 7-sided crystal a skill (SkillBadge). A gift is a box in a pentagon (GiftBoxBadge), social is three small spheres in an octagon (SocialBadge).
  • One colour per status. locked is neutral, available purple, in-progress pink. done takes the shape's own colour: module green, project purple, exam blue, activity blue (you take part in an activity, you don't validate it), skill brand, gift orange, social cyan. failed is red on every shape: the solid stays unlit, but the tile closes and glows, since the attempt is over.
  • One progression everywhere. A wireframe, then half lit, then full with a closed tile and a glow. Locked shows a padlock over a dotted silhouette. The module and the exam keep their wireframe instead.
lockedavailablein-progressdonefailed
Module
Project
Exam
Activity
Skill
Gift
Social

Code

<ModuleBadge status="locked" label="Graphics, locked" />
<ModuleBadge status="available" label="Graphics, available" />
<ModuleBadge status="in-progress" progress={50} label="Graphics, in progress" />
<ModuleBadge status="done" label="Graphics, validated" />
<ModuleBadge status="failed" label="Graphics, failed" />
{/* …and the same five for ProjectBadge, ExamBadge, ActivityBadge,
    SkillBadge, GiftBoxBadge and SocialBadge */}

Progress

Every statused badge takes progress (0 to 100) while in-progress. The solid fills like a liquid, from the bottom up: each face fills from its own base through a long, soft gradient, so every percent moves the fill. The exam fills its own way: its sides light up and a square grows on its top from the front corner, its side tracking progress. The 0 to 100 range is drawn as 15 to 100% of the fill, so started work never reads as merely available. Changes animate, and a badge fills up when it mounts.

Progress

Code

<ExamBadge status="in-progress" progress={progress} />

Gift token

GiftToken is a received gift: a lit hexagon in its orbit, with the gift's glyph inside. It has no status, it takes a hue. Pass remaining (0 to 1) and the orbit drains clockwise from the top, the satellite riding its end.

Code

<GiftToken hue="orange" icon={<Coffee />} />
<GiftToken hue="pink" icon={<Flower2 />} remaining={0.6} />
<GiftToken hue="yellow" icon={<Sparkles />} remaining={0.25} />
<GiftToken hue="red" icon={<Rocket />} />

For a glyph in a tinted square instead, use ThemeIcon.

Planet

Planet is a learner's level: a finer geodesic sphere, lit like an in-progress badge (same bottom-up order, floor and pink tones), but swept smoothly, the lit edge gliding through whole faces. It is 240px by default and takes any CSS length as size. planetLevelOffset(progress) gives the lit edge's height as a fraction of that size, to line a readout's leader up with it.

Progress

Code

<Planet progress={62} size={200} />

Sizes

Badges are 64px by default; size takes any number of pixels. The solids are drawn in a 64-unit box, so their lines scale with the badge, while a slotted glyph keeps a 1.5px stroke.

Code

<ProjectBadge status="done" size={24} />
<ProjectBadge status="done" size={32} />
<ProjectBadge status="done" size={48} />
<ProjectBadge status="done" size={64} />
<ProjectBadge status="done" size={96} />

API

Every statused badge (ModuleBadge, ProjectBadge, ExamBadge, ActivityBadge, SkillBadge, GiftBoxBadge, SocialBadge) takes the same props, BadgeBaseProps:

Prop

Type

GiftToken:

Prop

Type

Planet:

Prop

Type

Accessibility

A badge with a label is one image (role="img" with that name); without one it is decoration and stays out of the accessibility tree. Name a badge whenever it carries information the text around it does not, for instance "Graphics, in progress".

Reduced motion turns the status transitions and the fill animation off. The badges follow the system setting, and also data-motion="reduced" on <html>, for apps that let people choose in-app.

How the shapes are made

The Figma frame is flattened, so the solids are rebuilt from math. packages/react/scripts/generate-geometry.ts builds each mesh, poses it, projects it, and writes the result to geometry.ts: the facets turned to the viewer, a light bucket and a bottom-up rank per facet, edge paths, and the silhouette. The camera never moves, so none of this runs in the browser. After changing a solid, run pnpm --filter @42/ui-react generate:geodesic; a test fails if the committed data drifts from the script.

Changelog

v0.26.0
  • A shared failed badge status, in red, on every badge

    #450
  • fill="corner" on BadgeFrame: a square that grows from the front corner as progress rises

    #450
  • ExamBadge follows Figma: a square slab on a square tile, blue when passed, with a corner progress fill

    #450
v0.23.0
  • New geodesic badges: ModuleBadge, ProjectBadge, ExamBadge, ActivityBadge, SkillBadge, GiftBoxBadge, SocialBadge, GiftToken and Planet, with an opt-in geodesic/styles.css

    #434

On this page