Skip to content

Commit

Permalink
feat(WebexMeetingInfo): add className prop
Browse files Browse the repository at this point in the history
  • Loading branch information
adamweeks committed Mar 20, 2020
1 parent 08ca8ec commit 26bf668
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/WebexMeetingInfo/WebexMeetingInfo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import {format} from 'date-fns';
import {Spinner} from '@momentum-ui/react';

Expand Down Expand Up @@ -31,9 +32,13 @@ export function formatMeetingTime(startDate, endDate) {
* @param {object} props
* @returns {object} JSX of the component
*/
export default function WebexMeetingInfo({meetingID}) {
export default function WebexMeetingInfo({className, meetingID}) {
const {ID, startTime, endTime, title} = useMeeting(meetingID);
let infoComponent;
const mainClasses = {
[`${WEBEX_COMPONENTS_CLASS_PREFIX}-meeting-info`]: true,
[className]: !!className,
};

if (ID) {
const meetingTime = startTime ? <h3>{formatMeetingTime(new Date(startTime), new Date(endTime))}</h3> : null;
Expand All @@ -53,9 +58,14 @@ export default function WebexMeetingInfo({meetingID}) {
);
}

return <div className={`${WEBEX_COMPONENTS_CLASS_PREFIX}-meeting-info`}>{infoComponent}</div>;
return <div className={classNames(mainClasses)}>{infoComponent}</div>;
}

WebexMeetingInfo.propTypes = {
className: PropTypes.string,
meetingID: PropTypes.string.isRequired,
};

WebexMeetingInfo.defaultProps = {
className: '',
};
4 changes: 4 additions & 0 deletions src/components/WebexMeetingInfo/WebexMeetingInfo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ describe('Webex Meeting Info component', () => {
expect(shallow(<WebexMeetingInfo meetingID="scheduledMeeting" />)).toMatchSnapshot();
});

test('matches snapshot of scheduled meeting with custom CSS class', () => {
expect(shallow(<WebexMeetingInfo className="my-custom-class" meetingID="scheduledMeeting" />)).toMatchSnapshot();
});

test('matches snapshot of one on one meeting', () => {
expect(shallow(<WebexMeetingInfo meetingID="oneOnOneMeeting" />)).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ exports[`Webex Meeting Info component snapshot matches snapshot of scheduled mee
</div>
`;

exports[`Webex Meeting Info component snapshot matches snapshot of scheduled meeting with custom CSS class 1`] = `
<div
className="wxc-meeting-info my-custom-class"
>
<h2>
Our Scheduled Meeting
</h2>
</div>
`;

exports[`Webex Meeting Info component snapshot matches snapshot of space meeting 1`] = `
<div
className="wxc-meeting-info"
Expand Down

0 comments on commit 26bf668

Please sign in to comment.