Skip to content

Commit

Permalink
use classnames util in KoboModal
Browse files Browse the repository at this point in the history
  • Loading branch information
magicznyleszek committed Jul 9, 2024
1 parent 417d66f commit 8eaae02
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions jsapp/js/components/modals/koboModal.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React from 'react';
import Modal from 'react-modal';
import cx from 'classnames';
import bem, {makeBem} from 'js/bem';
import './koboModal.scss';

bem.KoboModal = makeBem(null, 'kobo-modal');

type KoboModalSize = 'large' | 'medium';

const DEFAULT_SIZE: KoboModalSize = 'medium';

interface KoboModalProps {
/** For displaying the modal. */
isOpen: boolean;
Expand All @@ -23,16 +26,14 @@ interface KoboModalProps {
}

export default function KoboModal(props: KoboModalProps) {
const modalSize: KoboModalSize = props.size || 'medium';

const modalClassNames = ['kobo-modal', `kobo-modal--size-${modalSize}`];
const modalSize: KoboModalSize = props.size || DEFAULT_SIZE;

return (
<Modal
ariaHideApp
isOpen={props.isOpen}
onRequestClose={props.onRequestClose}
className={modalClassNames.join(' ')}
className={cx('kobo-modal', `kobo-modal--size-${modalSize}`)}
overlayClassName='kobo-modal-overlay'
shouldCloseOnOverlayClick={props.isDismissableByDefaultMeans}
shouldCloseOnEsc={props.isDismissableByDefaultMeans}
Expand Down

0 comments on commit 8eaae02

Please sign in to comment.