Skip to content

Commit

Permalink
feat: [Modal] support btnVariant
Browse files Browse the repository at this point in the history
  • Loading branch information
akai committed Jul 19, 2022
1 parent 99cbd59 commit 0d86cde
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 31 deletions.
15 changes: 7 additions & 8 deletions src/components/Modal/Base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type ModalProps = {
overflow?: boolean;
actions?: ButtonProps[];
vertical?: boolean;
btnVariant?: ButtonProps['variant'];
bgColor?: string;
onClose?: () => void;
onBackdropClick?: () => void;
Expand All @@ -45,6 +46,7 @@ export const Base: React.FC<ModalProps> = (props) => {
overflow,
actions,
vertical = true,
btnVariant,
bgColor,
children,
onBackdropClick,
Expand Down Expand Up @@ -121,15 +123,12 @@ export const Base: React.FC<ModalProps> = (props) => {
</div>
<div className={clsx(`${baseClass}-body`, { overflow })}>{children}</div>
{actions && (
<div className={`${baseClass}-footer ${baseClass}-footer--${vertical ? 'v' : 'h'}`}>
<div
className={`${baseClass}-footer ${baseClass}-footer--${vertical ? 'v' : 'h'}`}
data-variant={btnVariant || 'round'}
>
{actions.map((item) => (
<Button
size="lg"
block={isPopup}
variant={!isPopup && vertical ? 'outline' : undefined}
{...item}
key={item.label}
/>
<Button size="lg" block={isPopup} variant={btnVariant} {...item} key={item.label} />
))}
</div>
)}
Expand Down
8 changes: 7 additions & 1 deletion src/components/Modal/Confirm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ import clsx from 'clsx';
import { Base, ModalProps } from './Base';

export const Confirm: React.FC<ModalProps> = ({ className, ...other }) => (
<Base baseClass="Modal" className={clsx('Confirm', className)} showClose={false} {...other} />
<Base
baseClass="Modal"
className={clsx('Confirm', className)}
showClose={false}
btnVariant="outline"
{...other}
/>
);
8 changes: 7 additions & 1 deletion src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React from 'react';
import { Base, ModalProps } from './Base';

export const Modal: React.FC<ModalProps> = (props) => <Base baseClass="Modal" {...props} />;
export const Modal: React.FC<ModalProps> = (props) => (
<Base
baseClass="Modal"
btnVariant={props.vertical === false ? undefined : 'outline'}
{...props}
/>
);
45 changes: 24 additions & 21 deletions src/components/Modal/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
.Modal-dialog {
position: relative;
z-index: @zindex-modal;
overflow: hidden;
width: @modal-width;
border-radius: @modal-border-radius;
background: @modal-bg;
Expand Down Expand Up @@ -55,38 +56,40 @@

.Modal-footer {
display: flex;

.Btn--outline {
padding-top: 10px;
padding-bottom: 10px;
border-width: 1px 0 0;
border-color: var(--gray-6);
border-radius: 0;

&:not(.Btn--primary) {
color: var(--gray-2);
}
}
}

.Modal-footer--h {
padding: 0 15px 18px;
&[data-variant='round'] {
padding: 0 15px 18px;

.Btn + .Btn {
margin-left: @modal-btn-x-spacing;
}
}
&[data-variant='outline'] {
.Btn + .Btn {
border-left-width: 1px;
}
}
.Btn {
flex: 1;
}
.Btn + .Btn {
margin-left: @modal-btn-x-spacing;
}
}

.Modal-footer--v {
flex-direction: column;

.Btn {
padding-top: 10px;
padding-bottom: 10px;
border: 0;
border-top: @modal-btn-y-border-width solid @modal-btn-y-border-color;
border-radius: 0;
background: @modal-btn-y-bg;
color: @modal-btn-y-color;

&:last-child {
border-radius: 0 0 @modal-border-radius @modal-border-radius;
}
}
.Btn--primary {
color: @modal-btn-y-primary-color;
}
}

// Confirm
Expand Down

0 comments on commit 0d86cde

Please sign in to comment.