Skip to content

Instantly share code, notes, and snippets.

@colorfield
Created May 30, 2017 17:45
Show Gist options
  • Save colorfield/d6bdff7a4a66b6fd3f737fff059c15af to your computer and use it in GitHub Desktop.
Save colorfield/d6bdff7a4a66b6fd3f737fff059c15af to your computer and use it in GitHub Desktop.
AudioGuide demo - AudioContentPage React component
@import '../variables.css';
@import '../Page/Page.css';
import React from 'react';
import PropTypes from 'prop-types';
import ReactAudioPlayer from 'react-audio-player';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import { REST_HOST_NAME } from '../../constants';
import Page from '../Page';
import Link from '../Link';
import s from './AudioContentPage.css';
class AudioContentPage extends Page {
static propTypes = {
// @todo
};
render() {
const { node, mp3File } = this.props;
const mp3URL = `${REST_HOST_NAME}/${mp3File.data.attributes.url}`;
return (
<div className={s.root}>
<div className={s.container}>
<Link className="button" to="/">List</Link>
<h1>{ node.data.attributes.field_id }</h1>
<h2>{ node.data.attributes.title }</h2>
<div
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: node.data.attributes.body.value }}
/>
<ReactAudioPlayer
src={mp3URL}
autoPlay
controls
/>
</div>
</div>
);
}
}
export default withStyles(s)(AudioContentPage);
{
"name": "AudioContentPage",
"version": "0.0.0",
"private": true,
"main": "./AudioContentPage.js"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment