### Install as Project
Source: https://github.com/medialab/quinoa-presentation-player/blob/master/README.md
Clones the repository and installs dependencies locally. Use this for development or direct project integration.
```bash
git clone https://github.com/medialab/quinoa-presentation-player
cd quinoa-presentation-player
npm install
npm run build-storybook
```
--------------------------------
### Start Storybook
Source: https://github.com/medialab/quinoa-presentation-player/blob/master/README.md
Starts a Storybook instance for live component testing. Explore various implementation scenarios in the ./stories folder.
```bash
npm run storybook
```
--------------------------------
### Install as Dependency
Source: https://github.com/medialab/quinoa-presentation-player/blob/master/README.md
Installs the Quinoa Presentation Player module as a dependency using npm. This is the recommended way to include it in your project.
```bash
npm install --save https://github.com/medialab/quinoa-presentation-player
```
--------------------------------
### Start at a specific slide
Source: https://context7.com/medialab/quinoa-presentation-player/llms.txt
Use the beginAt prop to set the initial slide index. The index is 0-based.
```jsx
import React from 'react';
import PresentationPlayer from 'quinoa-presentation-player';
function PresentationWithDeepLink({ presentation }) {
// Start at the third slide (index 2)
const startIndex = 2;
return (
);
}
// Parse slide index from URL hash
function PresentationFromUrl({ presentation }) {
const slideIndex = parseInt(window.location.hash.replace('#slide-', ''), 10) || 0;
return (
);
}
```
--------------------------------
### Full Quinoa Presentation Player Integration Example
Source: https://context7.com/medialab/quinoa-presentation-player/llms.txt
Demonstrates a complete integration of the Quinoa Presentation Player within a React application. It includes state management for the current slide, handling presentation end, and managing URL hash for slide navigation.
```jsx
import React, { useState, useEffect } from 'react';
import PresentationPlayer from 'quinoa-presentation-player';
function FullFeaturedPresentation({ presentationData }) {
const [currentSlide, setCurrentSlide] = useState(null);
const [hasEnded, setHasEnded] = useState(false);
// Parse initial slide from URL
const getInitialSlide = () => {
const hash = window.location.hash.replace('#', '');
const index = presentationData.order.indexOf(hash);
return index >= 0 ? index : 0;
};
const handleSlideChange = (slideId) => {
setCurrentSlide(slideId);
window.history.replaceState(null, '', `#${slideId}`);
// Track progress
const position = presentationData.order.indexOf(slideId);
const progress = ((position + 1) / presentationData.order.length) * 100;
console.log(`Progress: ${progress.toFixed(0)}%`);
};
const handleExit = (direction) => {
if (direction === 'bottom') {
setHasEnded(true);
console.log('Presentation completed');
}
};
const handleWheel = (event) => {
// Prevent parent scroll when inside presentation
event.stopPropagation();
};
return (
{hasEnded && (
Thank you for viewing!
)}
);
}
export default FullFeaturedPresentation;
```
--------------------------------
### Define Visualization Types
Source: https://context7.com/medialab/quinoa-presentation-player/llms.txt
Examples of how to define map, timeline, network, and SVG visualization types within the Quinoa model.
```javascript
// Visualization type is specified in the visualization metadata
const mapVisualization = {
"metadata": { "visualizationType": "map" },
"viewParameters": {
"cameraX": 48.82, // Latitude center
"cameraY": 2.27, // Longitude center
"cameraZoom": 14, // Zoom level
"tilesUrl": "http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png"
}
};
const timelineVisualization = {
"metadata": { "visualizationType": "timeline" },
"viewParameters": {
// Timeline-specific view parameters
}
};
const networkVisualization = {
"metadata": { "visualizationType": "network" },
"viewParameters": {
// Network graph view parameters
}
};
const svgVisualization = {
"metadata": { "visualizationType": "svg" },
"viewParameters": {
// SVG viewer parameters
}
};
```
--------------------------------
### Define a Quinoa Presentation Document
Source: https://context7.com/medialab/quinoa-presentation-player/llms.txt
A complete example of the Quinoa presentation JSON structure, including metadata, datasets, visualizations, slides, and settings.
```json
{
"type": "quinoa-presentation",
"id": "presentation-uuid",
"metadata": {
"title": "Historical Map Presentation",
"description": "An interactive journey through historical events",
"authors": ["Author Name"]
},
"datasets": {
"dataset-uuid": {
"metadata": {
"format": "csv",
"fileName": "events.csv",
"title": "Historical Events",
"description": "Data source description",
"license": "CC-BY"
},
"rawData": "Period,Event,latitude,longitude\n1871,Battle,48.825,2.276\n1870,Treaty,48.816,2.267"
}
},
"visualizations": {
"vis-uuid": {
"metadata": {
"visualizationType": "map"
},
"datasets": ["dataset-uuid"],
"data": {
"main": [
{
"Period": "1871",
"Event": "Battle",
"geometry": { "type": "Point", "coordinates": [48.825, 2.276] }
}
]
},
"dataMap": {
"main": {
"title": { "id": "title", "mappedField": "Event" },
"category": { "id": "category", "mappedField": "Period" }
}
},
"flattenedDataMap": {
"main": { "title": "Event", "category": "Period" }
},
"colorsMap": {
"default": "#d8d8d8",
"main": { "1871": "#ffd1bf", "1870": "#16a400" }
},
"viewParameters": {
"cameraX": 48.82,
"cameraY": 2.27,
"cameraZoom": 14,
"tilesUrl": "http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png"
}
}
},
"slides": {
"slide-1-uuid": {
"id": "slide-1-uuid",
"title": "Introduction",
"markdown": "Welcome to this **interactive** presentation.",
"views": {
"vis-uuid": {
"viewParameters": {
"cameraX": 48.82,
"cameraY": 2.27,
"cameraZoom": 14,
"colorsMap": { "main": { "1871": "#ffd1bf" } },
"shownCategories": { "main": ["1871", "1870"] }
}
}
}
}
},
"order": ["slide-1-uuid"],
"settings": {
"template": "stepper",
"css": ".custom-style { color: red; }"
}
}
```
--------------------------------
### Build Storybook
Source: https://github.com/medialab/quinoa-presentation-player/blob/master/README.md
Initializes Storybook. This is a prerequisite for running Storybook.
```bash
npm run build-storybook
```
--------------------------------
### Build Component
Source: https://github.com/medialab/quinoa-presentation-player/blob/master/README.md
Builds the component into the ./build directory. Use this script for production builds.
```bash
npm run build
```
--------------------------------
### Basic Usage with Stepper Template
Source: https://context7.com/medialab/quinoa-presentation-player/llms.txt
Render a presentation using the default stepper template. Slides are navigated via buttons and arrow keys. The presentation object follows the Quinoa document model structure.
```jsx
import React from 'react';
import PresentationPlayer from 'quinoa-presentation-player';
import myPresentation from './my-presentation.json';
function App() {
return (
);
}
// The presentation object follows the Quinoa document model structure:
// {
// "type": "quinoa-presentation",
// "id": "unique-id",
// "metadata": { "title": "My Presentation", "authors": ["Author Name"], "description": "..." },
// "datasets": { ... },
// "visualizations": { ... },
// "slides": { ... },
// "order": ["slide-id-1", "slide-id-2"],
// "settings": { "template": "stepper" }
// }
```
--------------------------------
### Create Custom Template Info
Source: https://context7.com/medialab/quinoa-presentation-player/llms.txt
Define metadata for a custom presentation template using a JSON file. This includes the template's ID, name, and a brief description.
```json
{
"id": "custom",
"name": "Custom Template",
"description": "A custom layout for presentations"
}
```
--------------------------------
### Import Presentation Player Component and Templates
Source: https://context7.com/medialab/quinoa-presentation-player/llms.txt
Import the main React player component and the templates object which contains metadata about available display templates.
```javascript
// Import the main player component
import PresentationPlayer from 'quinoa-presentation-player';
// Import template metadata
import { templates } from 'quinoa-presentation-player';
// templates is an array of template info objects:
// [
// { "id": "stepper", "name": "Stepper", "description": "Slides are browsed through buttons" },
// { "id": "scroller", "name": "Scroller", "description": "Slides are browsed through scrolling on the presentation" }
// ]
```
--------------------------------
### Presentation Settings Structure
Source: https://github.com/medialab/quinoa-presentation-player/blob/master/quinoa-presentation-document-model-description.md
Defines the settings for a Quinoa presentation, including the template to use for display and any custom CSS to be injected.
```json
{
"template": // the template to use to display the presentation
"css": // custom css to inject when displaying the presentation
}
```
--------------------------------
### Apply custom styling
Source: https://context7.com/medialab/quinoa-presentation-player/llms.txt
Customize the player container using the className and style props.
```jsx
import React from 'react';
import PresentationPlayer from 'quinoa-presentation-player';
import './custom-presentation.css';
function StyledPresentation({ presentation }) {
return (
);
}
// CSS classes applied: quinoa-presentation-player [template-name] [custom-class]
// Example result: class="quinoa-presentation-player stepper my-custom-presentation"
```
--------------------------------
### React Component API
Source: https://github.com/medialab/quinoa-presentation-player/blob/master/README.md
Details the properties and callbacks available for the QuinoaPresentationPlayer component.
```APIDOC
## React Component API
### Description
The main React component exported by the module for rendering data presentations.
### Parameters
#### Request Body (Props)
- **presentation** (object) - Required - The presentation data object.
- **options** (shape) - Optional - Global component configuration.
- **allowViewExploration** (bool) - Optional - Enables panning/zooming/navigation within the view.
- **onSlideChange** (func) - Optional - Callback triggered when navigation changes.
- **onExit** (func) - Optional - Callback triggered on exit events (e.g., scrolling past bounds).
- **onWheel** (func) - Optional - Callback for transmitting wheel events upstream.
```
--------------------------------
### Import Presentation Templates Metadata
Source: https://github.com/medialab/quinoa-presentation-player/blob/master/README.md
Imports the 'templates' object, which provides metadata about available presentation display templates. Use this to understand template options.
```javascript
import {templates} from 'quinoa-presentation-player';
```
--------------------------------
### Define template metadata in info.json
Source: https://github.com/medialab/quinoa-presentation-player/blob/master/README.md
Metadata file defining the template's unique identifier, display name, and a brief description.
```json
{
"id": "scroller",
"name": "Scroller",
"description": "Slides are browsed through scrolling on the presentation"
}
```
--------------------------------
### Add Build to Git
Source: https://github.com/medialab/quinoa-presentation-player/blob/master/README.md
Adds the build directory to the current Git record. Use this after a successful build.
```bash
npm run git-add-build
```
--------------------------------
### Import Presentation Player Component
Source: https://github.com/medialab/quinoa-presentation-player/blob/master/README.md
Imports the main React component for displaying presentations. This is the primary component to use in your application.
```javascript
import PresentationPlayer from 'quinoa-presentation-player';
```
--------------------------------
### Run Tests
Source: https://github.com/medialab/quinoa-presentation-player/blob/master/README.md
Runs Mocha tests on all *.spec.js files in the ./src directory. This is crucial for verifying component functionality.
```bash
npm run test
```
--------------------------------
### Visualization Structure
Source: https://github.com/medialab/quinoa-presentation-player/blob/master/quinoa-presentation-document-model-description.md
Outlines the structure of a visualization component in a Quinoa presentation, covering its metadata, data mappings, datasets used, color schemes, and view parameters.
```json
{
"metadata": {
"visualizationType": // the type of the visualization
}, //
"data":