Skip to content

Commit f5bfd9b

Browse files
committed
docs: update JSDoc comments
1 parent 463fe56 commit f5bfd9b

File tree

2 files changed

+44
-22
lines changed

2 files changed

+44
-22
lines changed

src/components/modal/CModal.tsx

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
44
import classNames from 'classnames'
55
import { CSSTransition } from 'react-transition-group'
66

7-
import { CModalBackdrop } from './CModalBackdrop'
7+
import { CBackdrop } from '../backdrop/CBackdrop'
88
import { CModalContent } from './CModalContent'
99
import { CModalDialog } from './CModalDialog'
1010

@@ -15,6 +15,11 @@ export interface CModalProps extends HTMLAttributes<HTMLDivElement> {
1515
* @default 'top'
1616
*/
1717
alignment?: 'top' | 'center'
18+
/**
19+
* Apply a backdrop on body while modal is open. [docs]
20+
* @default true
21+
*/
22+
backdrop?: boolean
1823
/**
1924
* A string of all className you want applied to the base component. [docs]
2025
*/
@@ -29,9 +34,18 @@ export interface CModalProps extends HTMLAttributes<HTMLDivElement> {
2934
*/
3035
fullscreen?: boolean | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'
3136
/**
32-
* TODO: Does the modal dialog itself scroll, or does the whole dialog scroll within the window. [docs]
37+
* Closes the modal when escape key is pressed. [docs]
38+
* @default true
39+
*/
40+
keyboard?: boolean
41+
/**
42+
* Method called before the dissmiss animation has started. [docs]
3343
*/
3444
onDismiss?: () => void
45+
/**
46+
* TODO: [docs]
47+
*/
48+
portal?: boolean
3549
/**
3650
* Create a scrollable modal that allows scrolling the modal body. [docs]
3751
*/
@@ -53,10 +67,13 @@ export interface CModalProps extends HTMLAttributes<HTMLDivElement> {
5367
export const CModal: FC<CModalProps> = ({
5468
children,
5569
alignment,
70+
backdrop = true,
5671
className,
5772
duration = 150,
5873
fullscreen,
74+
keyboard = true,
5975
onDismiss,
76+
portal = true,
6077
scrollable,
6178
size,
6279
transition = true,
@@ -112,7 +129,7 @@ export const CModal: FC<CModalProps> = ({
112129

113130
const handleKeyDown = useCallback(
114131
(event) => {
115-
if (event.key === 'Escape') {
132+
if (event.key === 'Escape' && keyboard) {
116133
return handleDismiss()
117134
}
118135
},
@@ -121,28 +138,30 @@ export const CModal: FC<CModalProps> = ({
121138

122139
const modal = (ref?: React.Ref<HTMLDivElement>, transitionClass?: string) => {
123140
return (
124-
<div
125-
className={classNames(_className, transitionClass)}
126-
tabIndex={-1}
127-
role="dialog"
128-
ref={ref}
129-
>
130-
<CModalDialog
131-
alignment={alignment}
132-
fullscreen={fullscreen}
133-
scrollable={scrollable}
134-
size={size}
135-
onClick={(event) => event.stopPropagation()}
141+
<>
142+
<div
143+
className={classNames(_className, transitionClass)}
144+
tabIndex={-1}
145+
role="dialog"
146+
ref={ref}
136147
>
137-
<CModalContent>{children}</CModalContent>
138-
</CModalDialog>
139-
</div>
148+
<CModalDialog
149+
alignment={alignment}
150+
fullscreen={fullscreen}
151+
scrollable={scrollable}
152+
size={size}
153+
onClick={(event) => event.stopPropagation()}
154+
>
155+
<CModalContent>{children}</CModalContent>
156+
</CModalDialog>
157+
</div>
158+
{backdrop && <CBackdrop visible={visible} />}
159+
</>
140160
)
141161
}
142162

143163
return (
144164
<div onClick={handleDismiss} onKeyDown={handleKeyDown}>
145-
{visible && <CModalBackdrop className="show" />}
146165
<CSSTransition
147166
in={visible}
148167
timeout={!transition ? 0 : duration}
@@ -152,8 +171,8 @@ export const CModal: FC<CModalProps> = ({
152171
>
153172
{(state) => {
154173
const transitionClass = getTransitionClass(state)
155-
return typeof window
156-
? 'undefined' && createPortal(modal(ref, transitionClass), document.body)
174+
return typeof window !== 'undefined' && portal
175+
? createPortal(modal(ref, transitionClass), document.body)
157176
: modal(ref, transitionClass)
158177
}}
159178
</CSSTransition>

src/components/offcanvas/COffcanvas.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ export interface COffcanvasProps extends HTMLAttributes<HTMLDivElement> {
3131
*/
3232
placement: 'start' | 'end' | 'top' | 'bottom'
3333
/**
34-
* Toggle the visibility of offcanvas component. [docs]
34+
* Generates modal using createPortal. [docs]
3535
*/
3636
portal?: boolean
37+
/**
38+
* Toggle the visibility of offcanvas component. [docs]
39+
*/
3740
visible?: boolean
3841
}
3942

0 commit comments

Comments
 (0)