Skip to content

Commit 2bee7dc

Browse files
committed
add cancel text prop to modal
1 parent 4adc5cc commit 2bee7dc

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

.github/workflows/components.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Use Node.js
1515
uses: actions/setup-node@v1
1616
with:
17-
node-version: 14.17.6
17+
node-version: 16.14.0
1818
- name: install
1919
run: npm install
2020
- name: yarn

.github/workflows/pr.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ jobs:
66
runs-on: ubuntu-20.04
77
steps:
88
- uses: actions/checkout@v2
9-
- name: Use Node.js 14.17.6
9+
- name: Use Node.js 16.14.0
1010
uses: actions/setup-node@v1
1111
with:
12-
node-version: 14.17.6
12+
node-version: 16.14.0
1313
- name: install
1414
run: npm install
1515
- name: yarn

components/Modal/Modal.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const Modal: React.FC<{
6262
confirmText?: string;
6363
onConfirm?: () => void | Promise<void> | boolean | Promise<boolean>;
6464
onCancel?: () => void | boolean;
65+
cancelText?: string;
6566
disabled?: boolean;
6667
hideCloseIcon?: boolean;
6768
hideFooter?: boolean;
@@ -71,6 +72,7 @@ const Modal: React.FC<{
7172
setIsOpen,
7273
children,
7374
confirmText = "Submit",
75+
cancelText = "Cancel",
7476
onConfirm,
7577
onCancel,
7678
disabled = false,
@@ -145,13 +147,15 @@ const Modal: React.FC<{
145147
<ModalFooter>
146148
{error && <ErrorMessage>{error}</ErrorMessage>}
147149
{loading && <Loading>Loading...</Loading>}
148-
<Button
149-
onClick={onCancelClick}
150-
type="secondary"
151-
disabled={loading}
152-
>
153-
Cancel
154-
</Button>
150+
{cancelText && (
151+
<Button
152+
onClick={onCancelClick}
153+
type="secondary"
154+
disabled={loading}
155+
>
156+
{cancelText}
157+
</Button>
158+
)}
155159
<ConfirmButton
156160
onClick={onConfirmClick}
157161
type="primary"

0 commit comments

Comments
 (0)