Skip to content

Commit 0d86cde

Browse files
committed
feat: [Modal] support btnVariant
1 parent 99cbd59 commit 0d86cde

File tree

4 files changed

+45
-31
lines changed

4 files changed

+45
-31
lines changed

src/components/Modal/Base.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export type ModalProps = {
2121
overflow?: boolean;
2222
actions?: ButtonProps[];
2323
vertical?: boolean;
24+
btnVariant?: ButtonProps['variant'];
2425
bgColor?: string;
2526
onClose?: () => void;
2627
onBackdropClick?: () => void;
@@ -45,6 +46,7 @@ export const Base: React.FC<ModalProps> = (props) => {
4546
overflow,
4647
actions,
4748
vertical = true,
49+
btnVariant,
4850
bgColor,
4951
children,
5052
onBackdropClick,
@@ -121,15 +123,12 @@ export const Base: React.FC<ModalProps> = (props) => {
121123
</div>
122124
<div className={clsx(`${baseClass}-body`, { overflow })}>{children}</div>
123125
{actions && (
124-
<div className={`${baseClass}-footer ${baseClass}-footer--${vertical ? 'v' : 'h'}`}>
126+
<div
127+
className={`${baseClass}-footer ${baseClass}-footer--${vertical ? 'v' : 'h'}`}
128+
data-variant={btnVariant || 'round'}
129+
>
125130
{actions.map((item) => (
126-
<Button
127-
size="lg"
128-
block={isPopup}
129-
variant={!isPopup && vertical ? 'outline' : undefined}
130-
{...item}
131-
key={item.label}
132-
/>
131+
<Button size="lg" block={isPopup} variant={btnVariant} {...item} key={item.label} />
133132
))}
134133
</div>
135134
)}

src/components/Modal/Confirm.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,11 @@ import clsx from 'clsx';
33
import { Base, ModalProps } from './Base';
44

55
export const Confirm: React.FC<ModalProps> = ({ className, ...other }) => (
6-
<Base baseClass="Modal" className={clsx('Confirm', className)} showClose={false} {...other} />
6+
<Base
7+
baseClass="Modal"
8+
className={clsx('Confirm', className)}
9+
showClose={false}
10+
btnVariant="outline"
11+
{...other}
12+
/>
713
);

src/components/Modal/Modal.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
import React from 'react';
22
import { Base, ModalProps } from './Base';
33

4-
export const Modal: React.FC<ModalProps> = (props) => <Base baseClass="Modal" {...props} />;
4+
export const Modal: React.FC<ModalProps> = (props) => (
5+
<Base
6+
baseClass="Modal"
7+
btnVariant={props.vertical === false ? undefined : 'outline'}
8+
{...props}
9+
/>
10+
);

src/components/Modal/style.less

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
.Modal-dialog {
2626
position: relative;
2727
z-index: @zindex-modal;
28+
overflow: hidden;
2829
width: @modal-width;
2930
border-radius: @modal-border-radius;
3031
background: @modal-bg;
@@ -55,38 +56,40 @@
5556

5657
.Modal-footer {
5758
display: flex;
59+
60+
.Btn--outline {
61+
padding-top: 10px;
62+
padding-bottom: 10px;
63+
border-width: 1px 0 0;
64+
border-color: var(--gray-6);
65+
border-radius: 0;
66+
67+
&:not(.Btn--primary) {
68+
color: var(--gray-2);
69+
}
70+
}
5871
}
5972

6073
.Modal-footer--h {
61-
padding: 0 15px 18px;
74+
&[data-variant='round'] {
75+
padding: 0 15px 18px;
6276

77+
.Btn + .Btn {
78+
margin-left: @modal-btn-x-spacing;
79+
}
80+
}
81+
&[data-variant='outline'] {
82+
.Btn + .Btn {
83+
border-left-width: 1px;
84+
}
85+
}
6386
.Btn {
6487
flex: 1;
6588
}
66-
.Btn + .Btn {
67-
margin-left: @modal-btn-x-spacing;
68-
}
6989
}
7090

7191
.Modal-footer--v {
7292
flex-direction: column;
73-
74-
.Btn {
75-
padding-top: 10px;
76-
padding-bottom: 10px;
77-
border: 0;
78-
border-top: @modal-btn-y-border-width solid @modal-btn-y-border-color;
79-
border-radius: 0;
80-
background: @modal-btn-y-bg;
81-
color: @modal-btn-y-color;
82-
83-
&:last-child {
84-
border-radius: 0 0 @modal-border-radius @modal-border-radius;
85-
}
86-
}
87-
.Btn--primary {
88-
color: @modal-btn-y-primary-color;
89-
}
9093
}
9194

9295
// Confirm

0 commit comments

Comments
 (0)