@instructure/platform-submission-sticker
v0.1.1
Published
React component for adding stickers to student submissions in Canvas.
Readme
@instructure/platform-submission-sticker
React component for adding stickers to student submissions in Canvas.
Features
- 51 unique sticker designs (academic, sports, pandas, and more)
- Editable mode for teachers/graders
- Read-only mode with optional confetti effect for students
- Animated sparkle effects
- Accessible (screen reader support, keyboard navigation)
- InstUI components
- TanStack Query for data management
- Full TypeScript support
Installation
pnpm add @instructure/platform-submission-sticker @instructure/platform-canvas-fetchPeer Dependencies
{
"react": "^18.0.0",
"@instructure/ui-*": "^10.0.0",
"@tanstack/react-query": "^5.0.0"
}Usage
import { Sticker } from '@instructure/platform-submission-sticker'
import '@instructure/platform-submission-sticker/dist/style.css'
function GradeSubmission() {
const [submission, setSubmission] = useState({
id: '1',
courseId: '100',
assignmentId: '200',
sticker: null
})
return (
<Sticker
submission={submission}
editable={true}
size="medium"
confetti={false}
descriptions={stickerDescriptions}
translations={stickerTranslations}
liveRegion={() => document.getElementById('flash_screenreader_holder')}
onStickerChange={(sticker) => {
setSubmission({ ...submission, sticker })
}}
/>
)
}API
Props
submission: Submission- Submission data with sticker stateeditable: boolean- Whether user can change the stickersize: 'small' | 'medium' | 'large'- Sticker display sizeconfetti?: boolean- Show confetti explosion on click (read-only mode)descriptions: StickerDescriptions- Alt text for each stickertranslations: StickerTranslations- UI text translationsliveRegion: () => HTMLElement- Accessibility live region elementonStickerChange?: (sticker: Sticker) => void- Callback when sticker changes
Architecture
- No global state - All data passed via props
- TanStack Query - Used directly for mutations (no wrapper)
- InstUI components - Modal, Button, Alert, etc. (no abstractions)
- CSS Modules - Scoped styling
- canvas-fetch - Canvas-aware API client with Zod validation
Development
# Run tests
pnpm test
# Run tests with coverage
pnpm test --coverage
# Build
pnpm build
# Type check
pnpm type-checkTest Coverage
- 23/23 tests passing
- 95.35% statement coverage
- 93.12% branch coverage
- 84.84% function coverage
