Commit 06eeeeec by AlasdairSwan

Adding in React components

parent 1931c1bf
...@@ -21,14 +21,38 @@ class CircleChartLegend extends React.Component { ...@@ -21,14 +21,38 @@ class CircleChartLegend extends React.Component {
style={style} style={style}
aria-hidden="true"></div> aria-hidden="true"></div>
<span className="label">{label}</span> <span className="label">{label}</span>
<span className="percentage">{value}%</span> <span className="percentage">{this.getPercentage(value)}</span>
</li> </li>
); );
}); });
} }
getPercentage(value) {
const num = value * 100;
return `${num}%`;
}
renderList() {
return (
<ul className="legend-list">
{this.getList()}
</ul>
);
}
render() {
return (
<div className="legend">
{this.renderList()}
</div>
);
}
}
CircleChartLegend.propTypes = { CircleChartLegend.propTypes = {
data: PropTypes.array.isRequired data: PropTypes.array.isRequired
}; }
export default CircleChartLegend; export default CircleChartLegend;
/* global gettext */
import PropTypes from 'prop-types';
import React from 'react';
import ReactDOM from 'react-dom';
import CircleChart from './CircleChart';
import CircleChartLegend from './CircleChartLegend';
export function LearnerAnalyticsDashboard(props) {
console.log('props: ', props);
const data = [
{
color: '#7ab',
value: 0.15,
label: 'Chucky'
},
{
color: '#ebb90d',
value: 0.25,
label: 'Michael Myers'
},
{
color: 'hotpink',
value: 0.3,
label: 'Freddy Krueger'
},
{
color: '#73bde7',
value: 0.3,
label: 'Jason Vorhees'
}
];
return (
<div className="analytics-group">
<h2>Grading</h2>
<h3>Weight</h3>
<div className="grading-weight-wrapper">
<CircleChart
slices={data}
centerHole={true}
sliceBorder={{
strokeColor: '#fff',
strokeWidth: 1
}}
/>
</div>
<CircleChartLegend data={data} />
</div>
);
}
/* global gettext */
/* eslint one-var: ["error", "always"] */
/* eslint no-alert: "error" */
import PropTypes from 'prop-types';
import React from 'react';
import ReactDOM from 'react-dom';
class RenderPage extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="my-test-div">
<h2>A React App!!!</h2>
</div>
);
}
}
export class LearnerAnalyticsDashboard {
constructor(context) {
ReactDOM.render(
<RenderPage context={context} />,
document.getElementById('root'),
);
}
}
...@@ -52,6 +52,15 @@ from openedx.features.course_experience import course_home_page_title ...@@ -52,6 +52,15 @@ from openedx.features.course_experience import course_home_page_title
</div> </div>
</header> </header>
<div class="page-content"> <div class="page-content">
<div id="root" class="learner-analytics-dashboard">
${static.renderReact(
component="LearnerAnalyticsDashboard",
id="react-learner-analytics-dashboard",
props={
'data': 'data'
}
)}
</div>
</div> </div>
</div> </div>
</%block> </%block>
......
...@@ -25,7 +25,7 @@ module.exports = { ...@@ -25,7 +25,7 @@ module.exports = {
// LMS // LMS
SingleSupportForm: './lms/static/support/jsx/single_support_form.jsx', SingleSupportForm: './lms/static/support/jsx/single_support_form.jsx',
AlertStatusBar: './lms/static/js/accessible_components/StatusBarAlert.jsx', AlertStatusBar: './lms/static/js/accessible_components/StatusBarAlert.jsx',
LearnerAnalyticsDashboard: './lms/static/js/learner_analytics_dashboard/index.jsx', LearnerAnalyticsDashboard: './lms/static/js/learner_analytics_dashboard/LearnerAnalyticsDashboard.jsx',
// Features // Features
CourseGoals: './openedx/features/course_experience/static/course_experience/js/CourseGoals.js', CourseGoals: './openedx/features/course_experience/static/course_experience/js/CourseGoals.js',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment