Quinoa-presentation-player - data presentations player component
Quinoa-presentation-player
is a module that provides a react component for displaying quinoa's data presentations in read-only mode.
It is part of the quinoa
project family, a suite of digital storytelling tools tailored for the FORCCAST pedagogical program and médialab sciences po scientific activities.
An example of editing apps for making data presentations is bulgur.
Requirements
npm scripts
npm run build # builds component to ./build dir
npm run lint # lints code (auto fix on) according to linting settings in package.json
npm run comb # prettifies scss code
npm run test # run mocha testing on each *.spec.js files in ./src dir
npm run storybook # starts a storybook instance to live test the component in several implementation scenarii (see ./stories folder)
npm run build-storybook # initializes storybook
npm run git-add-build # adds build to the current git record
Installing the module as a dependency
npm install --save https://github.com/medialab/quinoa-presentation-player
Installing the module as a project
git clone https://github.com/medialab/quinoa-presentation-player
cd quinoa-presentation-player
npm install
npm run build-storybook
Development
The project uses storybook to visually test the possible implementations of the component.
npm run storybook
Module API
The module exports by default a react component.
It also exports a templates
object which exposes metadata about available templates to display presentations.
import PresentationPlayer from 'quinoa-presentation-player';
import {templates} from 'quinoa-presentation-player';
Presentation component API
QuinoaPresentationPlayer.propTypes = {
presentation: PropTypes.object.isRequired,
options: PropTypes.shape({
allowViewExploration: PropTypes.bool
}),
onSlideChange: PropTypes.func,
onExit: PropTypes.func,
onWheel: PropTypes.func,
};
Templating
The component wraps a display-related component which corresponds to a specific templates.
Current templates are :
stepper
: slides are displayed on a pannel on the left of the view, navigation is handled through buttonsscroller
: slides are displayed as blocks, navigation is handled through scrolling
Creating new templates
Creating a new template supposes to create a new folder within src/templates/
folder, and fill it with at least three files:
- an
info.json
file describing the metadata of the template - a scss file describing component default style
- a js script exposing a react component
Example of an info.json
:
{
"id": "scroller",
"name": "Scroller",
"description": "Slides are browsed through scrolling on the presentation"
}
The react component of the template must comply to the following API :
MyTemplate.propTypes = {
presentation: PropTypes.object.isRequired,
currentSlide: PropTypes.object,
activeViewsParameters: PropTypes.object,
viewDifferentFromSlide: PropTypes.bool,
datasets: PropTypes.object,
navigation: PropTypes.shape({
currentSlideId: PropTypes.string,
position: PropTypes.number,
firstSlide: PropTypes.bool,
lastSlide: PropTypes.bool
}),
setCurrentSlide: PropTypes.func,
stepSlide: PropTypes.func,
toggleAside: PropTypes.func,
gui: PropTypes.shape({
asideVisible: PropType.bool,
interactionMode: PropType.oneOf(["read", "explore"])
}),
options: PropTypes.shape({
allowViewExploration: PropTypes.bool
}),
resetView: PropTypes.func,
onUserViewChange: PropTypes.func,
toggleInteractionMode: PropTypes.func,
onExit: PropTypes.func
}
Pre-commit hook
The project uses a precommit hook before each commit to ensure the code remains clean at all times. Check out the package.json
to learn more about it.