Skip to content

Commit a82b862

Browse files
authored
Merge pull request #61 from FrameMuse/51-add-indicators-to-modalwindow
51 add indicators to modalwindow
2 parents 638024b + 42bc3b7 commit a82b862

File tree

7 files changed

+40
-33
lines changed

7 files changed

+40
-33
lines changed

coverage/clover.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<coverage generated="1677037862849" clover="3.2.0">
3-
<project timestamp="1677037862849" name="All files">
2+
<coverage generated="1677109566641" clover="3.2.0">
3+
<project timestamp="1677109566641" name="All files">
44
<metrics statements="114" coveredstatements="83" conditionals="68" coveredconditionals="36" methods="40" coveredmethods="30" elements="222" coveredelements="149" complexity="0" loc="114" ncloc="114" packages="1" files="8" classes="8"/>
55
<file name="container.new.tsx" path="/home/kotto/github/react-modal-global/src/container.new.tsx">
66
<metrics statements="13" coveredstatements="13" conditionals="16" coveredconditionals="15" methods="4" coveredmethods="4"/>
@@ -14,9 +14,9 @@
1414
<line num="24" count="62" type="stmt"/>
1515
<line num="25" count="62" type="cond" truecount="2" falsecount="0"/>
1616
<line num="29" count="62" type="cond" truecount="2" falsecount="0"/>
17-
<line num="34" count="62" type="stmt"/>
18-
<line num="46" count="47" type="stmt"/>
19-
<line num="47" count="2" type="stmt"/>
17+
<line num="35" count="62" type="stmt"/>
18+
<line num="47" count="47" type="stmt"/>
19+
<line num="48" count="2" type="stmt"/>
2020
</file>
2121
<file name="container.tsx" path="/home/kotto/github/react-modal-global/src/container.tsx">
2222
<metrics statements="10" coveredstatements="0" conditionals="14" coveredconditionals="0" methods="4" coveredmethods="0"/>

coverage/lcov.info

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ TN:
22
SF:src/container.new.tsx
33
FN:14,ModalContainer
44
FN:16,(anonymous_1)
5-
FN:46,(anonymous_2)
6-
FN:46,(anonymous_3)
5+
FN:47,(anonymous_2)
6+
FN:47,(anonymous_3)
77
FNF:4
88
FNH:4
99
FNDA:62,ModalContainer
@@ -20,9 +20,9 @@ DA:22,62
2020
DA:24,62
2121
DA:25,62
2222
DA:29,62
23-
DA:34,62
24-
DA:46,47
25-
DA:47,2
23+
DA:35,62
24+
DA:47,47
25+
DA:48,2
2626
LF:13
2727
LH:13
2828
BRDA:17,0,0,28
@@ -35,12 +35,12 @@ BRDA:25,3,0,30
3535
BRDA:25,3,1,32
3636
BRDA:29,4,0,31
3737
BRDA:29,4,1,31
38-
BRDA:36,5,0,62
39-
BRDA:36,5,1,23
40-
BRDA:40,6,0,62
41-
BRDA:40,6,1,31
42-
BRDA:48,7,0,1
43-
BRDA:48,7,1,1
38+
BRDA:37,5,0,62
39+
BRDA:37,5,1,23
40+
BRDA:41,6,0,62
41+
BRDA:41,6,1,31
42+
BRDA:49,7,0,1
43+
BRDA:49,7,1,1
4444
BRF:16
4545
BRH:15
4646
end_of_record

src/__tests__/__snapshots__/useModalContext.spec.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`useModalContext should return isClosed: false 1`] = `
3+
exports[`useModalContext should return \`closed\`: false 1`] = `
44
<div>
55
<div
66
aria-hidden="false"
@@ -18,7 +18,7 @@ exports[`useModalContext should return isClosed: false 1`] = `
1818
</div>
1919
`;
2020

21-
exports[`useModalContext should return isClosed: true 1`] = `
21+
exports[`useModalContext should return \`closed\`: true 1`] = `
2222
<div>
2323
<div
2424
aria-hidden="true"

src/__tests__/useModalContext.spec.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ describe("useModalContext", () => {
2424
expectToThrow(renderCallback, /useModalContext must be used within a modalContext/)
2525
})
2626

27-
it("should return isClosed: false", () => {
27+
it("should return `closed`: false", () => {
2828
function ComponentWithModalContext() {
29-
const { isClosed: closed } = useModalContext()
29+
const { closed: closed } = useModalContext()
3030

3131
return <span>{String(closed)}</span>
3232
}
@@ -40,9 +40,9 @@ describe("useModalContext", () => {
4040
expect(container).toMatchSnapshot()
4141
})
4242

43-
it("should return isClosed: true", () => {
43+
it("should return `closed`: true", () => {
4444
function ComponentWithModalContext() {
45-
const { isClosed: closed } = useModalContext()
45+
const { closed: closed } = useModalContext()
4646

4747
return <span>{String(closed)}</span>
4848
}

src/container.new.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ export function ModalContainer(props: ModalContainerProps) {
2828
// This is the only way to make the modal work with the current implementation
2929
const contextValue: ModalWindow | null = focusedModal ? {
3030
...focusedModal,
31-
isClosed: !modal.isOpen,
31+
closed: !modal.isOpen,
32+
focused: true
3233
} : null
3334

3435
return (

src/controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export class ModalController {
8989
}
9090

9191
const params: ModalParams & P = { ...DEFAULT_PARAMS, ...modalParams as P }
92-
const modal: ModalWindow<P> = { component, params, close, isClosed: false }
92+
const modal: ModalWindow<P> = { component, params, close, closed: false, focused: true }
9393

9494
this.add(modal as ModalWindow<unknown>)
9595

src/types.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,22 @@ export interface ModalWindow<P = unknown> {
6464
close: () => void
6565
/**
6666
* Indicates that the `close` method has been called and the modal window is going to be removed.
67+
*
68+
* @default
69+
* false
6770
*/
68-
isClosed: boolean
69-
// /**
70-
// * Indicates that the modal is currently active.
71-
// *
72-
// * @note
73-
// *
74-
// * This is not the same as `!isClosed` because the modal may be not closed but still be in the queue.
75-
// */
76-
// isActive: boolean
71+
closed: boolean
72+
/**
73+
* Indicates that the modal is currently active.
74+
*
75+
* @note
76+
*
77+
* This is not the same as `!closed` because the modal may be not closed but still be in the queue.
78+
*
79+
* @default
80+
* true
81+
*/
82+
focused: boolean
7783
}
7884

7985
/**

0 commit comments

Comments
 (0)