Commit 2f87abd7 by Matt Tuchfarber

Add accessible modal

parent 4f7c83eb
...@@ -2,7 +2,7 @@ import React from 'react'; ...@@ -2,7 +2,7 @@ import React from 'react';
import Modal from '@edx/paragon/src/Modal/index'; import Modal from '@edx/paragon/src/Modal/index';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
class ModalWrapper extends React.Component { export class InstructorBioModal extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
...@@ -30,33 +30,18 @@ class ModalWrapper extends React.Component { ...@@ -30,33 +30,18 @@ class ModalWrapper extends React.Component {
body={this.props.body} body={this.props.body}
onClose={this.resetModalWrapperState} onClose={this.resetModalWrapperState}
/> />
<Button <button className="btn btn-primary" onClick={this.openModal} ref={(button)=>{this.button=button}}>
onClick={this.openModal} {gettext('View Bio')}
label="Click me to open a modal!" </button>
buttonType="light"
inputRef={(input) => { this.button = input; }}
/>
</div> </div>
); );
} }
} }
ModalWrapper.propTypes = { InstructorBioModal.propTypes = {
title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired, title: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,
body: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired, body: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,
}; };
ModalWrapper.defaultProps = { InstructorBioModal.defaultProps = {
open: false, open: false,
}; };
export class Modalx extends React.Component{
render(){
return (
<ModalWrapper
title="Matt's Modal"
body="This is Matt's Bio"
/>
)
}
}
\ No newline at end of file
...@@ -338,17 +338,13 @@ endorser_org = endorser_position.get('organization_name') or corporate_endorseme ...@@ -338,17 +338,13 @@ endorser_org = endorser_position.get('organization_name') or corporate_endorseme
% if instructors: % if instructors:
<hr class="thick_rule"> <hr class="thick_rule">
<div id="instructors" class="row"> <div id="instructors" class="row">
${static.renderReact(
component="Modalx",
id="container-id",
props={
'title': 'bar'
}
)}
<div class="col-12"> <div class="col-12">
<h2>${_('Instructors')}</h2> <h2>${_('Instructors')}</h2>
</div> </div>
% for instructor in instructors: % for instructor in instructors:
<%
instructor_hash = hash(instructor['name'])
%>
<div class="col-12 col-sm-6 col-md-4 instructor"> <div class="col-12 col-sm-6 col-md-4 instructor">
<div> <div>
<img alt="" src="${instructor['image']}"/> <img alt="" src="${instructor['image']}"/>
...@@ -363,9 +359,14 @@ endorser_org = endorser_position.get('organization_name') or corporate_endorseme ...@@ -363,9 +359,14 @@ endorser_org = endorser_position.get('organization_name') or corporate_endorseme
<div class="instructor-bio"> <div class="instructor-bio">
${HTML(instructor.get('bio'))} ${HTML(instructor.get('bio'))}
</div> </div>
<button class="btn btn-primary"> ${static.renderReact(
${_('View Bio')} component="InstructorBioModal",
</button> id="container-id-" + str(instructor_hash),
props={
'title': instructor['name'],
'body': HTML(instructor.get('bio'))
}
)}
</div> </div>
% endif % endif
</div> </div>
......
...@@ -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',
Modalx: './lms/static/js/accessible_components/Modal.jsx', InstructorBioModal: './lms/static/js/accessible_components/InstructorBioModal.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